Jakub Beránek (Kobzol), a Rust compiler contributor, writes about Rust performance, compile times, binary size, and async Rust.
Commenters recommend his posts as interesting and detailed, and cite them on what makes rustc slow, the benchmark suite, and building for older glibc.
My experience has been different: last year I started writing Python again after a long break, and I am yet to regret using types pervasively. If some library has no type definitions, I prefer to have my typed code interact with its untyped code. It is still better than having no types at all. You can sometimes get some useful type safety by annotating your functions with the untyped library's classes.
Since then, I have used established libraries like Beautiful Soup, Jinja, Pillow, platformdirs, psutil, python-dateutil, redis-py, and xmltodict with either official or third-party types. I remember their types being useful to varying degrees and not a problem. I have replaced Requests with the very similar but typed and optionally async HTTPX. My most objectionable experience with types in Python so far has been having to write
root = cast( lxml.etree._Element, # noqa: SLF001 html5.parse(html, return_root=True), ) when I used types-lxml with https://github.com/kovidgoyal/html5-parser. In return I have been able to catch some bugs early and to "fearlessly"refactor code with few or no unit tests, only integration tests. The style I have arrived at is close to https://kobzol.github.io/rust/python/2023/05/20/writing-python-like-its-rust.html.
Admittedly, I don't use Django. Maybe I won't like typed Django if I do. My choice of type checker is Pyright in non-strict mode. It seems to usually, though not always, catch more and more subtle type errors…
I appreciate this detailed explanation! To preface, I took on macro expansion caching because it was a clear solution for the slow builds I saw in some projects (taking the "project-specific" approach I mentioned in the blog). That said, my medium-term vision for CodeRemote isn't to develop a superior closed-source Rust compiler fork; instead, it is to provide remote tooling for faster development (i.e. bring small dev teams' tooling up closer to Google's level):
(a) pre-configured build servers, so a developer doesn't need to be equipped with the latest Mac to be functional
(b) shared cache within a developer team
(c) potential avenues in CI/CD, testing, etc.
I'd love to hear your thoughts on this goal! Does some aspect address a development pain point of yours? I also want to address your points above, and I agree with lots of them:
1. I agree that especially in the wider Rust community, closed source is not a long-term solution. For what it's worth, I have been considering making the source available -- though likely not with a super copyleft license, at least initially. Do you think making the source available would alleviate people's safety concerns?
2. I have thought about the mold/sold linker quite a bit, especially because the author changed his license on sold from a commercial license to MIT. And defaults are indeed very powerful (this is discussed in a recent change to strip debug info by default,…
> but I had heard that the compiler is slow (because it's doing so much thinking and checking in advance).
The compiler is indeed not particularly speedy, but the reason you were given is not entirely accurate. As measured in this blog post [0] different parts of the compilation pipeline will take different amounts of time depending on what you're doing (cargo check vs. incremental build vs. full build, building a library vs. binary, etc.), but generally speaking type/borrow checking take up relatively small portions of compilation time (~15% or less, based on eyeballing the charts [1, 2]) compared to everything else.
> one that's optimized for such tight loops, and another that does thorough checking
I think that would risk producing diverging language subsets, especially if the checks are essential for language semantics. For example, what exactly does it mean if a program passes the "relaxed" compiler but fails the "thorough" one? How close does that actually get you to a "real" working program?
[0]: https://kobzol.github.io/rust/rustc/2024/03/15/rustc-what-takes-so-long.html
[1]: https://kobzol.github.io/assets/posts/compile-sections/binaries.png
[2]: https://kobzol.github.io/assets/posts/compile-sections/libraries.png
I actually upgraded my team's Jest config to use https://github.com/Brooooooklyn/swc-node a few weeks ago. However, our Jenkins CI agents run RHEL7, and neither of the Linux binary targets would run. The `x64-gnu` binary needed a `GLIBC_2_23` symbol when only 2.18 was available, and the `x64-musl` binary had no `musl-libc` on the machine. I don't own the Jenkins agents, so I couldn't install other deps myself.
I ended up building `musl-libc` from source on another RHEL7 agent, committed the `.so` to our repo, and added that to the `LD_LIBRARY_PATH` in our Jenkinsfile, and actually got that working.
I did see some mentions that Rust could build to target an older GLibc ( https://kobzol.github.io/rust/ci/2021/05/07/building-rust-binaries-in-ci-that-work-with-older-glibc.html ), so I'm curious if Next is going to use copies of SWC built that way for better compat or if it will require more workarounds on my part.
I can definitely see shipping a WASM version as a great workaround to those sorts of compat issues.
I personally doubt you'll get anything out of this route, but maybe I'm not seeing a line of reasoning that led to this.
On a more helpful note, I'd check out a few books (try https://hackernewsbooks.com) and then pick a subject/domain you find interesting and create a small project to use as a learning medium.
Also, to tinker with assembly you could start with simple but interactive processor and assembly simulators/emulators; there are a few web ones floating around like https://schweigi.github.io/assembler-simulator/ or https://kobzol.github.io/davis/ but there are also more graphical ones too. Later you can maybe move to more serious virtualization software like qemu
There was another one of these posts floating around recently https://kobzol.github.io/rust/python/2023/05/20/writing-python-like-its-rust.html
My personal experience is that while this would be a really good way of getting people to write quality Python code, a lot of python users (data scientists) are not software engineers and don't have the discipline to do this without very strict PRs