Hacker Newsnew | past | comments | ask | show | jobs | submit | more BiteCode_dev's commentslogin

You don't need to write "import pandas; pandas.bla()", you can do "from pandas import *; anything_in_pandas()" if you want quick and dirty.


And if you want you and your team mates to hate you when they need to work on your code later, and you’ve got random, mystery functions all over the place.


I like Nim, and probably will learn it at some point.

But no, Nim is not everything "python should/want to be".

The name case insensitivity and the implicit imports on the global namespaces are perfect examples of stuff that are better in Python.


I've been using nim for a few years. I wouldn't have made either design choice (i always do qualified imports, it's just a few extra characters of typing). That said, there is a reason these superficial things always come up in HN threads. If you haven't used a language before, syntax is the only thing you can talk about. It's the equivalent of low effort political banter and the dopamine hit you get from junk food or watching a tiktok. These things melted away after my first 30 minutes with the language, and that's about when the real work began.


> If you haven't used a language before

This just feels like gatekeeping. I like nim, I've used it, talked to Dom and the author a few times in chat, filed some small bug reports. But even if I hadn't, I'd still hate the case insensitivity; I'm an experienced developer and I don't need to have used a language to know I will like or dislike some aspect of it.


To me it feels more like gate opening: if you feel discouraged to try a language by this specific feature that you do not like, do not fear, come in and try it since as far as we know no people actually using the language suffered from this feature


I don't think Nim has anything that I'd call a "global namespace". By default importing a module will include its exported symbols into the local module, but that doesn't impact anything globally.

In my opinion, this is the correct default, at least for Nim. Operator overloading and UFCS (https://en.wikipedia.org/wiki/Uniform_Function_Call_Syntax) don't really work if I have to prefix everything with a module name, and the static nature of Nim means that I'll get a compiler error if there's any ambiguity. There are downsides as well, but language design is all about tradeoffs, and I think Nim got this one right.

Regarding the case insensitivity, I was initially put off by this as well, but in 2 years of using Nim as my primary language, I have never, ever, encountered a real-life issue with it. I've never seen a Nim code base that uses mixed casing, and never encountered or heard of a bug caused by this behaviour. However, it has allowed my own code bases to stay 100% consistent, regardless of the code style of my dependencies, even when those dependencies written in other languages. Contrast this with Python where the `logging` module uses different casing than everything else, so you're forced to use an inconsistent style if you want to consume it. This type of thing is a non-issue in Nim. I think a case sensitive Nim would still be a fine language, but in my experience the pros of being mostly insensitive outweigh the cons.

In the end you may still disagree with both of these decisions, which is fine. Just understand that it's a nuanced discussion, and there's some solid reasoning behind their choices.


Implicit imports on the global namespaces? What do you mean?

Case insensitivity is somewhat complex topic in Nim, as there are some places where the case actually matters, plus there are some more rules for equivalence of identifiers (related to `_` IIRC). In any case, it was never a problem for me in practice; nimsuggest works quite well.


> Implicit imports on the global namespaces? What do you mean?

Not OP, but they are referring to `import std/strformat` (from homepage). That just imported things into the global namespace. Maybe that isn't required and its just for short examples, I don't know.

Go and Python can both import into the global namespace too (`from thing import *` and `import . somepackage`), but they are pretty frowned upon in most projects.


> Not OP, but they are referring to `import std/strformat` (from homepage).

> That just imported things into the global namespace.

That's what tripped me up: there's definitely no such thing as importing into GLOBAL namespace. That's an import into a top-level (true) namespace of a MODULE. In Python, if you put something into the dict returned from `globals()`, you are indeed importing into global namespace, but I've never seen it actually done. Anyway, that might seem like nitpicking, but it's an important distinction. [EDIT: C `#include`s are an example of actually importing into global namespace]

With that out of the way: the wildcard imports are frowned upon for a reason. What reason? Basically, it's hard to tell a) what identifiers were imported, b) if any of them are still used in the module (ie. if it's safe to remove the import). With multiple wildcard imports in one file you also get c) hard to tell where a given identifier comes from.

Now, none of these problems apply to Nim. Nim is statically typed. The compiler and the tooling knows exactly which identifier comes from where. If you delete all the places you used identifiers from a wildcard import, the compiler and the tooling will tell you that it's safe to delete the import. Another problem with wildcard imports is that the imported modules can change, leading to disasters like silently shadowing an identifier imported from somewhere else. Again, this cannot happen in Nim - it simply won't compile.

Every single linguistic feature has its pros and cons, but you have to remember to only weigh those in the particular context they're used in. What I mean is that wildcard imports in Python and Nim are very, very different beasts, and shouldn't be directly compared, if at all. It would make more sense to compare Nim to Elixir or Scala in this regard.

Note: obviously, Nim also has selective imports and whole module imports, too.


Cool thanks for the info.

Nim having selective imports solves any annoyances I would have.

But you mentioned all the reasons it was ok in Nim. But the answer is always that the compiler knows. That isn’t why I personally dislike this type of import. I dislike it as a user. I find it super annoying not knowing where an identifier is coming from.

I love having ‘fmt.Printf()’ instead of ‘Printf()’. Trivial example I know. I’m sure everything becomes fine once you are familiar with the ecosystem though.


There's a reason why wildcard/selective[1] imports are favored in Nim. It's because of the uniform function call syntax[2]. In short, this:

    split("a string", " ")
is exactly the same thing as this:

    "a string".split(" ")
`split` here is a normal function, not any kind of method. This means that you can chain normal functions as if they were methods on objects:

    "a string".split(" ").join("\n")
now, if you imported modules instead of functions themselves, how would that look like?

    sequtils.join(strutils.split("a string", " ") "\n")
or, if you wanted to keep uniform call syntax, you'd have to invent some new syntax:

    "a string".split<strutils>(" ").join<sequtils>("\n")
Which also doesn't look very appealing.

So, there are trade-offs here, and you obviously might not like the choices made by Nim, which is fine! But, there are reasons for the design decisions made by the language implementers, and they are almost never predicated on a single feature: all the features of a language interact with each other, sometimes in very strange and unpredictable ways. So it makes sense to consider the features your interested in the proper context :)

[1] `import modname` and `from modname import fun1, fun2`

[2] https://en.wikipedia.org/wiki/Uniform_Function_Call_Syntax


Great explanation, that makes total sense.

Thanks for giving the insight.


C++ somewhat solved this using Koenig lookup https://en.wikipedia.org/wiki/Argument-dependent_name_lookup


IMO people really should stop comparing it to Python, it's a very different language.


I don't mind the comparison but do wish the comparison wouldn't so often be "it's a better Python."

I've been programming Python 14+ years and I've dabbled in Nim and I agree it's a very different language. Yes, there are similarities, but my expectations about it being a lot like Python from the community and docs actually led to some significant frustration and discouragement.

"Inspired by"..."borrows concepts from" are better descriptors IMO. But it would be better if an unqualified "it's like Python" disappeared.


Your opinion contradicts the official description of Nim on the language's home page:

> Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula.

Also, the "Features" page contains "Inspired by Python" twice, and "concepts from Ada and Modula" once.


If you have 'myvar' and 'myVar' in some code there are three things you could do.

1) The compiler gives you an error, this would be my preferred solution though I'm not aware of any language that does that.

2) These end up referring to the same variable with no error. Nim's solution.

3) These are actually different variables with no error. The common solution.

Again, I would prefer (1) but I think that (2) is a safer way of handling the situation than (3).


As much as I hate it for correctness, 2 is better than 3 indeed. No sane developer encodes meaning in the case of the name of the variables, in the overwhelming majority of cases it's a typo.


In the C world ALL_CAPS very often signify preprocessor macro identifiers (or some other "class" of identifier), but, yeah..they may all be "insane". ;-)


OMG, what if C did significant case because of that? I mean, it's fine to write "#import", why didn't K&R use a special syntax for macros, like $MACRO or something and left the uppercase as a convention?


I am no C historian, but I believe part of the idea was to be able to have macro wrappers around proper language symbols like "#define sin(x) real_sin(x, 1e-7)" or some such, for example. The "warning character" (what you used `$` for) was thus only for introduction (#define) not for reference. Whether the initial intent or not, this idea certainly came to become an application, also invoked via compiler command line "-Dsin=real_sin" style definition. With this you want the case conventions/sensitivity to be the same in the preproc/macro language as the base language.

FWIW, I do think that the late 1960s saw a broad "new prog lang" evolution away from case insensitive (often ALL CAPS due to low resolution dot matrix printers/display devices) stylistic tendencies in, e.g. LISP and FORTRAN, towards case sensitivity and lowercase. So, I suspect this was the salient driver - "We have lowercase now/text is more legible! Let's use it!". (Yes, mechanical typewriters/typesetting had it for decades to centuries, but programming was not done on those, but with printers and punch cards and just starting to be on CRTs.) There are analogies with Unicode in PLs these days (though there are obviously also other motivations these days/decades with the compute world i18n).


player = Player()

all the time in Python.

date = new Date()

all the time in JS.

Those are just the two languages I spend the most time in, but, but I'm sure it's trivial to find numerous examples of cases carying meaning in case-sensitive languages. Especially ones which encourage camel casing.


`player` and `Player` are different in Nim. Ditto for `date` and `Date`.


There is a difference between variables and types.

For instance, in C#, with capital-case convention for variables, it is common to give a variable the same name as the type.

eg `public Player Player;`


The 3rd solution is terrible, because:

    ForMid = 4 # padding for middle box in px
And:

    FormId = 3 # ID of the form in the user process
Should definitely not be resolved as the same variable.


The only thing worse than 3 is 2.


I don’t remember the exact options, but there’s a way to make Nim emit warnings (and perhaps errors) for inconsistent capitalization.

It isn’t the default, though.


The options are nim c --styleCheck:hint --styleCheck:usages (you need both). Though not on by default you could put it in your config.nims or nim.cfg's to make it on by default for you or for your code.


The global namespacing is what allows UFCS to work. You can rewrite parseInt("6") to "6".parseInt, but you can't rewrite strutils.parseInt("6") to anything.


Yes, you have listed the two things that have stopped me from giving Nim a chance. I especially dislike the global namespaces, it makes it very hard to understand where a function is defined.


Use go-to-definition in your editor.


It doesn't matter where you are on the scale if the scale of "helping dictators with malicious intents".

Don't get me wrong, I don't think facebook or any big tech companies has any kind of moral upper hand, given they all spy on people, lie, engage in corruption, monopoly abuses, and so on. And they all have weapon dealers in their portfolio, which sell arms to the same people using pegasus.


> It doesn't matter where you are on the scale

imho it does. In the "IG Farben" example the managers were held accountable (correctly) because they should have known better, but not the ppl producing/packing/shipping some chemicals.


They had to explicitly pass through the DoD certifications and contracts requirements, and probably had to implement some custom features on Windows for it.

So hes, they are.

Now, the question is: would you rather have lived the cold war without a nuclear deterrent in your country?

It's a harder question to answer.


You can't eat a smartphone, you can't sleep in an internet connection, you can't do your nursing job through a computer.

Formal education is more expensive. A balanced diet is harder to get, and more expensive. Housing is more expensive near your work. But gas as well if you live far from it.

Today's people debt is higher, and you can't easily work one job, raise a family, and afford education plus buy a home.

It was more common in the 70'.


Oh come on. People were literally starving in the US in the 60s-70s. Not really something that is easy to happen nowadays, even if it is difficult to get a balanced diet.


One in 9 people in the US suffers from food insecurity (not having regular access to adequate meals). During the height of the disruptions from the pandemic last year, one in 4 households experienced food insecurity.

Sources:

https://sail.gmu.edu/program/hunger-banquet-2021/hunger https://www.npr.org/2020/09/27/912486921/food-insecurity-in-...


Why are you bringing up "food insecurity" rather than deaths by starvation which is an objective measure of food shortness, and what the person you replied to is talking about?

How many people starve to death in the United States?


Let's not forget securities. Today most people live in some state of constant existential dread, because they know, if they somehow lose the flat, they can't afford a new contract; they can't plan long term, as their job isn't safe (although, that point is in interesting turmoil right now, /r/antiwork and all); they can't work towards a pension plan; ...

The promise of salvation past generations had with their working lifestyle doesn't hold truth anymore. I think that's why we see more "new religions" popping up right now, like conspiracy narratives, new nationalism, "white man identities" (the group without a distinct identity in the past; their self-efficacy experiences seem to be in decline, too), the MLM-fantasy of self-employment/all-in hacks/dire fight for "untapped markets" (podcasts, porn, stock market ...).

Late stage capitalism.


I really love the wave of new tools that are gaining traction in the Python world: tqdm, rich (and soon textual), fastpi, typer, pydantic, shiv, toga, doit, diskcache...

With the better error messages in 3.10 and 11, plus the focus on speed, it's a fantastic era for the language and it's a ton of fun.

I didn't expect to find back the feeling of "too-good-to-be-true" I had when starting with 2.4, and yet.

In fact, being a dev is kinda awesome right now, no matter where you look. JS and PHP are getting more ergonomics, you get a load of new low level languages to sharpen your hardware, Java is modern now, C# runs on Unix, the Rust and Go communities are busy with shipping fantastic tools (ripgrep, fdfind, docker, cue, etc), windows has a decent terminal and WSL, my mother is actually using Linux and Apple came up with the M1. IDEs and browsers are incredible, and they do eat a lot of space, but I have a 32 Go RAM + 1TO SSD laptop that's as slim as a sheet of paper.

Not to mention there is a lot of money to be made.

I know it's trendy right now to say everything is bad in IT, but I disagree, overall, we have it SO good.


I had to look these up (just me doing Google searches):

- tqdm: progress bars (https://tqdm.github.io/)

- rich: text formatting (https://github.com/willmcgugan/rich)

- textual: TUI, using rich (https://github.com/willmcgugan/textual)

- fastpi: Rest APIs (https://fastapi.tiangolo.com/)

- typer: CLI Library, uses Click (https://typer.tiangolo.com/)

- pydantic: Custom data types (https://pydantic-docs.helpmanual.io/)

- shiv: Create Python zipapps (https://shiv.readthedocs.io/en/latest/)

- toga: GUI Toolkit (https://toga.readthedocs.io/en/latest/)

- doit: Task runner (https://pydoit.org/)

- diskcache: A disk cache (https://github.com/grantjenks/python-diskcache/)


You can find most of those here: https://taoofmac.com/space/dev/python.

Those that aren't should be there momentarily :)


Just wanted to add Austin: Python frame stack sampler for CPython written in pure C (https://github.com/P403n1x87/austin)


Thanks for the links!

FWIW python has a built-in disk cache—- shelve ( https://docs.python.org/3/library/shelve.html )


Diskcache has the amazing benefit of transparent sharding, so you can use it in multithreading and multiprocessing programs.


Damn, so many goodies to play with. Thanks for the list.


TQDM isn't all that new, it's one of the first things I started to play with when learning to write code. That said, it is an amazing tool.


New features get added and these posts are a nice reminder to check the docs on a tool I literally never need to do that for because it's so habitual to wrap any long-running iterable inside of a `tqdm()`.

TIL tqdm now has a dead simple telegram hook https://tqdm.github.io/docs/contrib.telegram/


It never occurred to me that chat posts could be quickly edited to make them dynamic. Maybe other chat-bots do that too. Its definitely a cool add-on.


Yeah, I've been using it for a while, but with the barrage of memes and politics on the internet nobody finds out about the good stuff until years later.


tqdm is indeed 8 years old, but it's been popping up everywhere for only a couple of years now. Hence the "gaining traction".


I used an early version of this in 2009.


Ive used tqdm 20 years ago


I've used tqdm 30 years ago!

Although the first release on pypi was in 2013: https://pypi.org/project/tqdm/#history


Way before @noamraph put it up on in pypi it was internally available in our company. To my knowledge he didn't yet make it 30 years ago, but if he did then probably at least not for Python!


Wise of you...


OP didn't take issue with "gaining traction" and clearly was responding to "new tools". Tqdm isn't a new tool.


It’s been making some tqdm lately


Despite of all the hate Python gets (pkg system), it’s still my go to language. Most fun. Most rewarding. Getting things done fast.

I can go home with Python at 5pm. And have a good time with my family.


I hate python, I just hate everything else more.

Jokes aside it's a great language. I would love to see a better package management ecosystem for it, as that is also my biggest issue. Python also does something no other mainstream scripted language does- it allows you to install extensions to the language right in the same package manager, as it can compile libraries from source when wheels are unavailable- this makes it a much harder challenge. At the same time I'm really happy that PyPI is a non-profit organization and won't have to go through the issues that something like NPM did.


I love Python (flexibility, ecosystem, datamodel). I love Java (verbosity, explicitness, robustness). Now, kill me. I don't let others define what I should and shouldn't think about a tool, in this case a programming language. I make up my own mind based on my own experience with the tools. Remember, they're just tools. Not the end game.


For me at least, Poetry [1] automates the process almost on par with npm, cargo, etc.

[1]: https://python-poetry.org/


I really like Poetry for my own uses but as a semi-infrequent Python user my struggle is dealing with other people's Python repositories that aren't using it.

I can never remember all the differences and subtleties between virtualenv, pipenv, venv, pyenv-virtualenv, workon, conda, and so on when I encounter them in a random git repo.


Right?

Doing advent of code in Python is almost cheating. It feels like playing a video game.


I did AoC 2021 through Day 7 in Python, before switching to Go (for personal learning, can't remember if times listed below were with "go run" or from running after "go build"). D7 actually in both, to try and solve a problem I was having with my Python performance. But, it was actually a big learning moment for me when it came to structuring my logic.

My Python code in Part 2 (some minor adjustments from Part 1) took about 40 seconds to run. Terrible, but usable to get a proper answer. I was able to bring it down to ~25 seconds with some optimization by adding a calculated lookup dictionary per loop. Now, the same exact logic in Go ran in about 0.8 seconds.

However, I wasn't satisfied with this and realized that if I moved the dictionary to be global rather than per-loop, I would be able to realize significant gains in performance by completing eliminating redundant calculations. This change dropped the runtime from 25 seconds to 0.35 seconds (of course, applying the same logic in Go brought it down from 0.8s to 0.05s).

Due to the nature of performance you can get out of the Python interpreter, it can actually lead you down paths of learning better optimization strategies that you may initially write off in other languages (depending on the use case) because they perform inherently better. It made me think a bit more about what I was doing and how I could improve it since (in this particular case), the impact of not doing so was pretty drastic.


Day 6 and 7 are fantastic for that. It's a learning moment, where you can get the benefit of thinking about the problem for a few minutes instead of bruteforcing gives you a dramatic speed up.

When I read the Day 7, I saw bruteforcing would lead to bad perfs. Then I remembered that in high school, I learned a formula to calculate the nth term of a sequence without having to process the entire sequence.

I couldn't remember the formula, nor the name of the concept, so I google around until I found some tutorials, and relearned what I was taught as a child: arithmetic sums.

The consumption for a crab can then be calculated in constant time:

    def crab_consumption(crab, target):
        n = abs(target - crab) - 1 
        return (n**2 + 3*n + 2) / 2
And the Python solution finishes instantly.

Bottom line, I could keep using Python for all problems and benefit from the amazing productivity of it.

I've been using python since 2.4 now, and it's not always fast enough. But it very, very often, is.


Interesting, I'll have to look at that. Actual algorithms are a big weak point for me, I'm not a developer by day, so I don't spend a lot of time learning code practices or computer science/math topics. This was my solution to Day 7 Part 2 (positions = sorted int list of input data):

    def calculate_fuel(positions):
        fuel = None
        low_fuel_value = None

        calculated = dict()
        for value in range(positions[0], positions[-1]+1):
            consumed = 0
            for position in positions:
                diff = abs(value - position)
                try:
                    consumed += calculated[diff]
                except KeyError:
                    if position != value:
                        consumption = sum([x for x in range(1,diff+1)])
                        calculated[diff] = consumption
                        consumed += consumption
            if fuel:
                if consumed < fuel:
                    fuel = consumed
                    low_fuel_value = value
            else:
                fuel = consumed
                low_fuel_value = value

        print(f"Aligning to: {low_fuel_value}")
        return fuel
And Day 6 I fell for the bruteforce bait and had the thought "It can't be as easy as changing 80 to 256, right?". Then I realized the pain I had created for myself. BUT! My 6p2 code ran faster than my 6p1 by a good margin, which I was happy about.


Can even calculate the target without bruteforcing. . n^2+n is approximated by n^2 when n is large. Can take the mean of all the distances and use that (or perhaps +/- 1).

    val crabs = lines.first().split(",").map { it.toInt() }
    val avg = crabs.sum() / crabs.size
    return crabs.sumOf { abs(it - avg).let {dst -> (dst * (dst + 1)) / 2} } 
And similarly for part1 take the median. Why it kinda works:

Part1: The median I felt made sense intuitively, as in my head I thought about an example ala 1,1,3,100. Never makes sense to use x>3, because even though the crab at x=100 then can walk shorter, there are 3 others then having to walk longer. And x=1,2or3 doesn't matter, just symmetrically changes which side has to walk one step less or one step more.

And for part2 I thought similar, except the cost is exponential and therefore I want to minimize the avg move and not the total moves, thus taking the average.


The better optimization with Python is to not use python. Half joking. If you want awesome performances, transform your problem into a numerical one, and use Numpy. Numpy is awesome. I always miss it when using other languages than Python.


I don't understand your solution to Day7. What kind of dictionary, and how come even a naive solution would be so slow?

My Kotlin solution runs in about a second. And it was even so stupid that I didn't calculate the sum of the arithmetic series directly, but through a loop. Can't fathom something being slower.

    line.split(",").map { it.toInt() }.let { crabs ->
        (0..crabs.maxOf { it }).minOf { pos ->
            crabs.sumOf {
                (0..abs(it - pos)).sum() // slower than calculating arithmetic sum, but quicker to write 
            }
        }
    }
My proper Kotlin solution runs in less than a ms, though.

I do think that "it's good that python is slow because it forces you to optimize" is a weird take, though.


> I do think that "it's good that python is slow because it forces you to optimize" is a weird take, though.

My take wasn't that it forces you to, but that non-optimal code paths can be greatly exaggerated in comparison to other languages, particularly compiled ones. You can still ignore it (I mean, within reason), but it can give you that extra push to really look a bit deeper to understand what's going on. And of course, there's optimized libraries written in C/C++ that you can take advantage of for even better number crunching than standard CPython.

> What kind of dictionary, and how come even a naive solution would be so slow?

My naive solution was literally going through every single element for every loop and not storing any data besides the fuel buildup and the alignment number that generated it. The dictionary was added to act as a cache to store already computed fuel consumption values, initially per-loop then moved one level up to be global (because the summations wouldn't be different).

I'm not saying my method (posted in a sibling comment) is the best solution, but it's the way my brain walked through the problem.


Posted my optimized Kotlin solution in that sibling thread :)

Cool of you to participate without being a developer! Lots of computer science topics makes it easier, so hard without knowing of them. For instance graph searching / Dijkstra has beem relevant this week.


Yeah, I was doing a CS minor in college but had to drop as it was consuming too much of my time from my other discipline in the non-intro courses. Big(O)/time complexity were my usual failings in the intro algorithms course I took.

I'm not unfamiliar with programming, but I come from the sysadmin side of things. "Glue" work is usually where things are focused and the 'fun' nitty-gritty of algorithms can be a bit out-of-scope, though I'm not a sysadmin in my current role anymore so any dev-related work I do is purely personal now.

I've had to take a break from AoC, only got up through Day 10, but didn't get P2 for 8 and 9. It's a fun way to keep the mind going and to slip back into the coding space to at least not lose skills, even if the solutions are simple/non-optimal.


Yes! Tasks like AoC (relatively small, without stringent performance requirements but still requiring the correct algorithm) are where Python is not only a reasonable choice, it's unreasonably effective.

Doubly so this year, with the theme being linear algebra.

  import numpy as cheat
:)


Your positivity and enthusiasm is infectious. Thanks for being an optimist.


doit [0] is a superb toolkit for building task-oriented tools with dependencies. It isn't too complex to get started and gives you a lot to work with. I've used it for an internal tool used by everyone in the company for 5+ years and it has never given me a headache.

[0]: https://pydoit.org


And surprisingly underrated.

I mean, it's declarative, works on Windows, easy things are (very) easy, and because you can mix and match bash and python actions, hard things are suspiciously easy too.

Given how complicated the alternatives are (maeven, ninja, make, gulp...), you'd think it would have taken the world for years.

Yet I've only started to see people in the Python core dev team use it this year. It's only getting traction now.


"hard things are suspiciously easy too."

Care to share an example?


Here is a task that groups all static files from a web project into a directory.

It has to make sure a bunch of directories exist, run a node js command to build some files from the proper dir, then run a python command to regroup them + all static files from all django apps into one dir. Simple.

But then I had a problem I had to hack around. This required me to change an entry to a generated TOML file on the fly at every build.

doit just lets me add a 5 lines python function that does whatever I want, and insert it between my bash tasks, and I'm done.

    def task_bundle_static_files():

        def update_manifest():
            conf = Path("var/static/manifest.toml")
            data = toml.loads(conf.read_text())
            data["./src/main.js"] = data["index.html"]
            conf.write_text(toml.dumps(data))

        return {
            "actions": [
                "mkdir -p ./var/static/",
                "rm -fr ./var/static/* ",
                "cd frontend/; npm run build",
                "python manage.py collectstatic --noinput",
                update_manifest,
                "cp -r ./var/static/* ",
            ]
        }


or if you prefer rust, there's just. https://github.com/casey/just/

better yet, use both and just doit


For simple tasks — e.g. a list of commands — that are fine staying in sh, https://taskfile.dev is excellent


How does this compare to pyinvoke or they are completely different ?


The pythontic replacement for makefiles?


Yes. Like make, it lets you define tasks with dependencies and targets, and rebuild only if one of them have changed.

But I prefer it because:

- it runs anywhere you have python.

- it uses a clean syntax, and the parser is great at telling you about errors since it's python.

- you get access to python's stdlib: string formatting, maths, etc.

- you get access to python's ecosystem. Want to deal with timezone, hashing, crypto ? Sure you can.

- you get access to python's tooling (debugger, formatter, linter).

- you can still just use bash if you want. Easy things stay easy.


That would be invoke tasks. https://docs.pyinvoke.org/en/stable/getting-started.html, which I first encountered in fabric: fabfile.org, which has the fab utility and fabfiles (analogous to Makefiles) but is so much more.


It is a pain to work with invoke now. It is all find and dandy for the basic features but you going to hit the seams soon you start trying advanced stuff. Looks like the project is going to be abandoned.


What is advanced?

btw, the project is old and it is useful with the current feature set. There is an issue with the bus factor but is common for many tools.


How does this compare to snakemake?


https://github.com/keleshev/schema a library for validating python data structures by schema definitions, gave me a wow moment. (i have a slightly less original one here: https://github.com/MoserMichael/kwchecker )


Love the idea of Schema, but not a fan of that syntax, doesn't seem Pythonic to me, seems more like something you'd see out of Javascript word.

Like looking at that very first example, I have no clue what "len" means in that context. Is it implicitly checking that it's not an empty string? Then on the next line, how come `int` has `Use()` around it, but on the previous line `str` didn't? I guess that int is being used as a converter, line on the next line with str.lower, but the str was being used as a type check?

Not a fan of that API.


I'll add BeeWare (https://beeware.org/) as a pretty nice nice to deploy Python applications cross-platform easily. It's more like a suite of tools, though.


I love Python for many things: scripts, data science, prototypes, etc. But I would never use it to build a large backend system. I just can't handle all the warts. Yes it has been used by large companies, but not without their problems.


You use Python to rapidly build a small backend system and then, if any warts appear that need to be smoothed over, you carve that function off to a more robust solution.

Python is great for programming at the speed of inspiration.


To me Python is fast just like not writing tests is fast.


for prototypes and MVPs time-to-learning and time-to-market are king, and programmer time is the most expensive thing. in that niche Python is helpful and tests just slow you down

tests are super helpful and wise in any sort of long term or safety-critical software, obviously

so, tests (and Python) are not inherently a win or a loss. they just give you different trade-offs

times to write testless Python and times to write test-heavy Go, Rust etc.


Generally I believe in engineering tradeoffs but I think some tests are always important. Even with MVPs. Writing test might double your time to market, but they will allow you to move faster and make less regressions once in production. The early days are some of the least stable features wise and having tests in place to verify things when massively changing a codebase is nice. Also, it can greatly help add confidence to newcomers who don't know the codebase.


understood. theres def an art to judging when its too early to write tests vs the perfect time. its easy for anyone to recognize once its become "too late" and therefore more painful and costly to add it than otherwise would have been

I therefore try to put each situation quickly into 1 of 3 buckets then move forward on that basis:

1. heck no

2. heck yes

3. either way. a gray area

I generally see a case 1 and 2 with confidence. therefore by a process of elimination, that also lets me deduce when its case 3. and in those cases you cant go wrong. :)

"Impossible to predict, the future is." - Yoda


It's interesting because even FANG companies can't agree on testing. I've heard Facebook and Google are very different in this regard.


What do you think about using Python for prototyping of microservices in large backend systems?


Sounds reasonable. Especially for a ML group. I just know that many times the prototype turns into the production product.


I think that is also reasonable, if the production system does not have to service a heavy load, and does not need to be scalable. Scalability is often assumed to be a requirement, however it is not always required in practice.


Good point about scalability. The first company I worked for was tiny, and this really hits home :)


tqdm has been around for ages now, it's not exactly new.


tqdm is indeed 8 years old, but it's been popping up everywhere for only a couple of years now. Hence the "gaining traction".


You said "wave of new tools that are gaining traction" maybe you meant to say "wave of tools newly gaining traction".


A new wave "of tools gaining traction"


How would you separate this new wave from any old waves? I've never been aware of "waves of traction".

Please just admit you made a mistake instead of responding to everyone trying to defend your use of the word "new" on an old tool. :D


I though I wrote it correctly, but I'm French, so I'm going to assume I haven't.


I'd chip in dramatiq as a nice python tasks/message passing library


rich is great - exactly this library i used to solve same problem as tqdm does and it includes estimation (ETA) too!

Rich is just amazing library


too bad python is the least energy efficient programming language, by a lot. It's like rolling coal of programming.


It's energy inefficient like a school bus, not inefficient for the sake of it, but because it's a decent way to shuttle passengers of all experience levels through all weather.


Do you seriously think that 20 cars are more economic than a single bus?

Python performance problems are exaggerated for many use-cases (hot paths are not written in Python e.g., matching regexes happens in C code(re,regex), parsing xml too (elementtree, lxml), sqlite, numpy,scipy (C, Fortran), etc. Cython makes it trivial to drop to C level where necessary)


Python might not be energy efficient in the hardware it is definitely efficient in the wetware.


fire is also really nice for easily building cli


tqdm is like around for 5 years or something now


They remember they still made banks after that and their accountant laughed it out.


It's removed from marketing material, but is it removed from the code?

Since the OS is proprietary, how do we know they didn't go for it anyway?


> Since the OS is proprietary, how do we know they didn't go for it anyway?

Reverse engineering is a thing.


Good luck on not being more than half year behind the latest release, with decent accuracy. That really takes some effort.


An expensive, hard, long and unreliable thing.


Have you reverse engineered iOS?



I haven't reverse engineered iOS itself because I've never had any reasons to, but I have reverse engineered third-party iOS apps (dumped from a jailbroken device) and some parts of macOS.


How do you know it’s not on android?


Who cares? Weren't talking about android right now. No need for "what about" deflections of valid criticisms


That may have been simple ignorance instead of whataboutism. The person asking it may genuinely not know how much easier it is to inspect Android (both the device and the open source). They may not know you can build custom images of Android either.


Android is open source? At least you have the chance to use it like that, some tinkering required.


The only difference between Android and iOS in this regard is that Android's frameworks are open source. The rest is exactly the same.


The AOSP code is open source. The Android and related apps running on your latest Pixel 6 is not.


Well you installed an always on microphone in your house, attached to a processing unit connected to internet all the time.

People said again and again it's going to be abused, and you had the technical knowledge to evaluate the risk.

Yet you went with it.

If it was not your scenario, it would have been another one. There will be other ones. Hell, with things like PRISM, that's inviting 3 letters agencies in your bedrooms.

Since the pandora box is opened and people are going to do it anyway, we should at least militate for having hardware switches on any sensors for any device.


The Alexas were for my elderly mother in law. If she fell or was having some sort of problem, she could call us with just her voice.

Also she and my partner both like the convenience, so who am I to say that they shouldn’t have such a device? The device does have hardware switches for the camera (it was off) and the microphone but you can’t switch off the microphone without effectively disabling the device.

When I she bought these devices they didn’t have this feature. None of us knew that the feature was deployed and enabled by default. To your point, it is a huge issue that we have no control over these devices anymore since the software can be changed at any time and can lie to you (lies of omission usually).

The Alexa goes above and beyond imo because when this person gained access to my mother in law’s other accounts, it took about 30 minutes to permanently lock him out, despite him bypassing text based tfa by having compromised her phone. Alexa wouldn’t even tell me this problem existed, and I can’t document what happened unlike with literally every other service.


>Well you installed an always on microphone in your house, attached to a processing unit connected to internet all the time.

How is it different from a smartphone or notebook?


Intent.

I don't have my phone expecting it to listen to all the room, all the time.

It could, but if it is, it's not a deliberate choice.

The microphone is not made of this, I regularly put it in plane mode, I don't have an account linked to the phone nor smart assistant actives.

Listening to my phone all the time would require targetting, since it's not, unlike alexa, doing so by design: https://eu.usatoday.com/story/tech/conferences/2020/02/25/go...


You can put them in the freezer like Edward Snowden.


It would be funny if you could only smell it if it was your biological child.

Although getting serious statistics on the matter is not easy, the estimated numbers can be surprisingly high (e.g: "One in 25 fathers is not biological parent": https://www.theguardian.com/society/2005/aug/11/childrensser...)

If suddenly we discovered an easy way to give a hint you should do a DNA test, it could do some serious noise.


Technically 23 and Me monetized this as the fun holiday gift for everyone + the reddit thread you post in the aftermath.


My wife is on a number of genetic genealogy Facebook groups, and this time of year is peak season for confused new posters who are desperately trying to get some rationalization as to why their father (or mother!) didn't match with them on 23andMe. Many just cannot accept reality and continue posting convoluted possible reasons ("23andMe messed up both me and my fathers tests, but we both still matched with lots of other people?"). It's quite sad at times


I did hear a story about one of the genetic testing places accidentally rotating one of their sample trays 90 degrees.


Why do you think the 23andme results can't be wrong?

Many years ago my father was once given hospital test results stating he was terminally ill with a heart condition. He knew he was somehow given a different patient's test result under his name when when his family doctor asked him if he exercises (he does) and the doctor said "That can't be your patient record. You wouldn't be able to exercise if your heart was as sick as the test result states." My father is still alive and exercising regularly today.


In a world which contains huge, systematic lab screw-ups (such as the FBI Crime Lab scandals), is there good reason to believe that 23andMe is particularly reliable and competent? Vs...one of our clients at $DayJob is a home mold inspection lab. Keeping their modest mold lab Officially Certified requires daily duplication, replication, etc. of dozens of individual test results, plus statistical analysis of those, plus...


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: