I'm curious how Nim fares for DS/ML.
I'm curious how Nim fares for DS/ML.
One of the advantages of the language for DS/ML is the native "C like" performance with very low developer friction.
Another advantage from a library perspective is being able to automate fast, low level boiler plate code from easy to use DSLs using AST macros. For example a DSL could generate bespoke code for different data layouts and pipelines etc., giving you the best possible performance without the user worrying about it.
The latest incarnation of JS tools seem to be written in Go and Rust (esbuild and another one), not JS.
GC is an issue for compilers, or even just front ends, which create huge, fine-grained, linked data structures
You wouldn't be crazy for choosing JS for a new compiler project, even for work that had nothing to do with JavaScript.
(You would be pretty crazy to choose js to build a rich data science backend, in comparison).
I do agree the GC rules out some use-cases like many gaming applications.
You can, but that's a prerogative of all Turing-complete languages.
There are much better languages fit for the purpose, which is the point of this comment thread.
Keep in mind "a compiler" may not be for "a widely used general purpose programming language" but something smaller with a specific use, especially in the context of a company.
JS has many quality libraries for parsing grammars etc, and is Fast Enough for the purpose unless you need incredible perf - Python or Ruby, for example, might be much worse choices.
Even C++ might be a worse choice depending on your project's objectives (sure it might be faster but it might be a lot less maintainable, especially compared to TS). I also don't buy the argument that TS would make it harder to write a correct/safe compiler than C++.
Rust and Haskell may be sexy for the purpose but would be much slower to get started with, especially if your team isn't already staffed with experts. The Sorbet team at Stripe chose C++ over Rust because they felt developing with the latter would be too slow.
Keep in mind that most people are sticking with pure-JS build stacks even as esbuild et al are coming on to the scene. And the TS team has stuck with a Node compiler despite having the resources and know-how to use something totally different.
Please don't tell people to avoid writing a compiler in JS/TS unless you really know the specifics. :)
Of course, all of this does make me curious how Nim is for compilers (I imagine it'd be very, very nice).