• 2 Posts
  • 705 Comments
Joined 2 years ago
cake
Cake day: September 24th, 2023

help-circle






  • it has modules for everything

    Not everything. PyYAML, Pydantic and Typer are things I commonly want in scripts that aren’t in the standard library.

    Simply do pip install anything. But best practice is to use a python virtual environment and install packages into that one.

    It’s more than “best practice”. It’s mandatory on many recent Linux distros. And yeah setting up a venv and installing dependencies is not something you want to have to do for each script you run.

    Its one of the slowest to write code in.

    It depends what your goal is. If you want robust code that works reliably then I would say Rust has the edge still. Yes it will take longer to write but you’ll spend way less time debugging it and writing tests.


  • That’s kind of the point. You can do it in most languages, so why use a shitty one like Bash? Use a good language like Rust!

    Also there are aspects of languages that make many languages less suitable for this application though. For example Python, because you can’t use third party dependencies (or at least you couldn’t; I think uv has an equivalent of cargo script now). Java would be a pretty awful choice for example.



  • Right, I’m not saying it isn’t simpler in terms of syntax. The point I was making is that the syntax is simpler but in a way that makes it worse because while it’s easier for computers to read, it’s harder for humans.

    it was only later discovered that they can be compiled down to native code.

    That sounds extremely unlikely. I think you’re misinterpreting this quote (which is fair enough; it’s not very clear):

    Steve Russell said, look, why don’t I program this eval … and I said to him, ho, ho, you’re confusing theory with practice, this eval is intended for reading, not for computing. But he went ahead and did it. That is, he compiled the eval in my paper into IBM 704 machine code, fixing bugs, and then advertised this as a Lisp interpreter, which it certainly was. So at that point Lisp had essentially the form that it has today …

    As far as I can tell Lisp was always intended to be compiled and executed. That quote is about compiling the eval() function (which was just meant to explain how Lisp is executed) into a binary and using that as an interpreter.

    Also I skimmed the paper that is from, and in fact Lisp was intended to be targeted by AI (in the same way that we get AI to write and execute Python to solve problems), which explains a lot. It wasn’t designed for humans to write, so why bother with nice syntax; just have the machine write the AST directly!

    (I expect that was only part of the motivation tbf, but still!)


  • This comment perfect captures why I don’t like Lisp. Essentially “it’s simple, this easy to read code transforms to this AST”. Lisp basically says “we can make parsing way easier if we force programmers to write the AST directly!” which is really stupid because computers can perfectly well parse syntax that is easy for humans to read and turn it into ASTs automatically.

    It makes it easier to parse for computers at the cost of being much harder to parse for humans, which is really the wrong choice in most cases. (The exception is if you’re DIYing your compiler, e.g. if you’re teaching how to write a compiler then Lisp is a good target.)



  • Yeah it’s great for little scripts. There’s even a cargo script feature that’s being worked on so you can compile & run them using a shebang.

    I’d use a shell script if it is literally just a list of commands with no control logic or piping. Anything more than that and you’re pointing a loaded gun at your face, and should switch to a proper language, of which Rust is a great choice.


  • It’s definitely a growing problem with Rust. I have noticed my dependency trees growing from 20-50 a few years ago to usually 200-500 now.

    It’s not quite as bad as NPM yet, where it can easily get into the low thousands. Also the Rust projects I have tend to have justifiably large dependencies, e.g. wasmtime or Slint. I don’t think it’s unreasonable to expect a whole GUI toolkit to have quite a few dependencies. I have yet to find any dependencies that I thought were ridiculous like leftpad.

    We could definitely do with better tooling to handle supply chain attacks. Maybe even a way of (voluntarily) tying crate authors to verified real identities.

    But I also wouldn’t worry about it too much. If you a really worried, develop in a docker container, use a dependency cooldown, and whatever you do don’t use cryptocurrencies on your dev machine.


  • The real costs are the ~$100m they spend a year on developing GitHub and providing it for free to most people - including free CI.

    They charge 3x the cost price for runners so that they can actually make money. This change is so that they can’t get undercut by alternative hosted runner providers.

    I do think they could have just explained that and it probably would have been more palettable than their “we’re making it cheaper!” lie, but I guess there are also a lot of people that still think the only moral pricing is cost plus.





  • This is the first time I’ve heard of Deno, but I’m not sure that having to install a 110Mb JS VM + runtime is more convenient in my context than simply using Python which is already guaranteed to available on any system I use and does all I need.

    I can assure you it is 100x more convenient. One command to install it that has worked every single time I’ve done it, vs the hell that is Python installation. It’s meme-level bad..

    Granted that was written before uv existed, and UV makes things a lot better in general. One thing it still isn’t great at though is installing Python. E.g. the binary Python distributions it can install never look for SSL certificates in the right (read: different on every Linux distro) places, so HTTPS doesn’t work.

    If you actually want to install the latest version of Python on Linux (so you can’t use distro packages), the official solution is to build it from source. Which mercifully is easy (very surprising given the rest of Python), but still!

    Is Typescript a better language than Python?

    Not uniformly (e.g. arbitrary precision integers are the right choice for ad-hoc scripting, and Python’s support for lists, dictionaries, and filter/map is arguably nicer). Overall though, absolutely.

    I definitely wouldn’t use Rust - or any other compiled language - for scripting.

    Why not? It’s really good for shell scripting type stuff (executing commands, manipulating files, etc.).


  • Surely you wouldn’t argue that Rust or C++ would be a more appropriate alternative in that kind of role because they’re statically typed.

    Not C++. Rust hopefully, when cargo script is stabilised!

    Until then I strongly prefer Deno (which is also statically typed) for ad-hoc scripting. Python is surprisingly bad for that use case despite it being super popular for it because:

    1. There’s no way to use third party dependencies reliably from a single-file scripts. You’re limited to the standard library, or setting up a whole pyproject.toml, venv and so on.
    2. You can’t import files by relative file path like you can in Deno, Zig, and Rust (sort of; it’s slightly hacky). That leads to people doing hacks to PYTHONPATH or importlib which completely breaks all tooling.