3 ms·
Ask HN: Smallest cross-platform language runtime?
For mostly command line tools, but ideally with some GUI support, what’s the smallest (and easiest to deploy) language runtime?
Rationale: I often write little tools, and often I need to run them in the future (frequently on different computers). I’d like to use C#, but getting a tool chain and development environment is a painful multi-gigabyte commitment. Today, I like Deno for its trivial deployment and smallish (80 MB) footprint (and VS Code+TypeScript is a great development environment, although not very small), but I’m not sure it will be around for the long term. Node is similar, but much more painful to setup.
Zig’s compiler (another smallish download) is intriguing, but it’s probably too low level when I only run the programs a few times a year (meaning I don’t want to write low level, fast code—-I’ll trade speed for ease of writing code or small footprint).
Tcl/Tk seems promising (I’ve heard it can be as small as a few megabytes). Any reason I shouldn’t use Tcl?
I’m sure there’s a Lisp option, but I haven’t found one with as small of a footprint as I thought should exist.
- verdverm 4y agoGo can easily cross compile and has lots of OS level abstractions. I would use web tech for any frontend, run a server and embed the necessary files in that binary. Go can be just a few MB onto the low 10s
- schemescape 4y agoI have very little experience with Go, but I recall setting it up was trivial and it compiled very quickly. My only concern is that I’ve heard the language is simple to the point that it requires writing a lot of code that wouldn’t be necessary with something higher level (similar to Zig, but at least no manual memory management and Go’s channels sound great). Good suggestion! Edit: I also just remembered that my other experience with Go was the template library used in Hugo. I recall that being a negative experience, but hopefully something I’ll mostly be able to avoid.
- verdverm 4y agoI would say Go has minimal syntax, so yes there is a lack of syntactic sugar, but it also has a great stdlib. What is there is really well done and the tooling is fantastic
- schemescape 4y agoI didn’t mention a standard lib being important, but it most definitely is, and that’s a big plus for Go. The lack of a standard lib is certainly JavaScript’s biggest weakness. Deno provides one, but I’m not certain it will stand the test of time.
- verdverm 4y agoI'm building a tool on top of CUE and Go's text/template library. My opinion is that the problem is more how Hugo organizes and combines files, lots of magic if you don't know how it makes decisions, kinda like CSS rules being opaque. https://github.com/hofstadter-io/hof https://github.com/hofstadter-io/hof
- Tozen 4y agoAgree that Go, among some others (Vlang, Dlang, Nim), that are both compiled and use a GC (the GC of some languages are optional and can be turned off) could be on the list of what's looked at.
- ahazred8ta 4y agoIs the 100KB TCC an option? posix+windows https://en.wikipedia.org/wiki/Tiny_C_Compiler https://en.wikipedia.org/wiki/Tiny_C_Compiler https://www.lua.org/download.html https://www.lua.org/download.html is only a few hundred KB
- schemescape 4y agoTCC is great, but the C “standard” library is a mess (and huge, and inconsistent across Windows and Linux). Zig includes a C compiler and C library in a convenient package. But my main issue with C is that it’s just not productive. Dealing with strings in C is a chore. I also like Lua, but the last time I used it (admittedly 10 years ago), the closest thing to a standard library was minimal. Maybe worth another look, thanks!
- schwartzworld 4y agoHow about Forth?
- schemescape 4y agoJust for the record (and since it might not be clear from the title, due to the character limit), I'm not just looking for the smallest footprint--more like "best bang for the buck". I'll give Forth another look, but in the past I found the language to be difficult to read and modify.
- planetis 4y agoI think the smallest binaries you're going to vet with nim. 73kB according to [1]. [2] also mentions that "This implementation was designed for embedded, hard real-time systems.". [1]: https://nim-lang.org/blog/2022/12/21/version-20-rc.html https://nim-lang.org/blog/2022/12/21/version-20-rc.html [2]: https://nim-lang.org/blog/2022/11/11/a-cost-model-for-nim.html https://nim-lang.org/blog/2022/11/11/a-cost-model-for-nim.ht...