Hacker News new | past | comments | ask | show | jobs | submit login

This is such a fantastic benefit of Golang: spin up a VPS, apply some sensible defaults, cross compile then run your binary.

Compare this to deploying python, node or php... Needless complexity.

If only running (and keeping running) a database server could be this straightforward!




Nowadays you can bundle a node app as a single binary file. It’s an underused feature, maybe it will catch on.


Could you share how that can be done? I spent some time this year trying to pack a node tool into a single fat binary for a specific use case where we wanted a history of versioned executables - i.e a build job that needs to run specific versions of the packed tool in a specific order determined by external factors.

I tried Vercel pkg, Vercel ncc, nexe, and a few other tools I can’t remember right now. They all had issues with node v20, some dependencies, or seemed to not be maintained anymore. I ended up relying on esbuild as a compromise to get a fat script containing all sources and dependencies, tarballed with some static files we rely upon we can at least get versioned, reproducible runs (modulo the node env). Still not perfect, a single binary would be preferable


I’ve used pkg with success for some small apps - curious to know why it didn’t work for you.

Now you can use this native feature (not totally stable yet though) which I’ve been meaning to try https://nodejs.org/api/single-executable-applications.html


I don't remember the details, and cannot find my notes on vercel/pkg. But looking at https://github.com/vercel/pkg right now I see the project has been deprecated in favour of single-executable-applications


Bummer that they deprecated/archived it before the native feature was stable.


I saw that deno did this but cool to see node picked it up too. I wish there was an option to run turbofan at build to generate the instructions rather than shipping the entire engine, but i guess that would require static deps and no eval, which can’t really be statically checked with certainty


The engine is actually pretty small. Something like 50-100MB if memory serves (when I was using pkg)


You can build native and self-contained binaries in C# too.


How often the deployment model “copy a single binary to VPS via SSH and run it” is even used nowadays?

And with that still, you’d be much better served by using a more expressive and less painful to use language like C#. Especially if the type of use is personal.


You can do the same with python tho, from nuitka compiler to LinkedIn shiv or twitters pex (that follow pip 441).


Just pack up your whatever-else as an AppImage. Job done.


How does it deal with the undocumented system dependencies Python libraries often have?


For Python, you could make a proper deployment binary using Nuitka (in standalone mode – avoid onefile mode for this). I'm not pretending it's as easy as building a Go executable: you may have to do some manual hacking for more unusual packages, and I don't think you can cross compile. I think a key element you're getting at is that Go executables have very few dependencies on OS packages, but with Python you only need the packages used for manylinux [2], which is not too onerous (although good luck finding that list if someone doesn't link it for you in a HN comment...).

[1] https://nuitka.net/

[2] https://peps.python.org/pep-0599/#the-manylinux2014-policy




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

Search: