from Hacker News

Ask HN: Good Stack for a Single File, Compiled to Binary, Web App?

by x0054 on 4/10/21, 3:51 PM with 2 comments

I am looking for a good stack for a simple web app that I am planning to build as a side project. I would like to find an option that would allow me to build the app as a single binary that can run as a server, serve my app, and also run the API for it.

Basically think Transmission or Resilio Sync, both of which are written in C. I am pretty good with C, but would rather try something new while working on this side project.

My priorities are:

1. Small Compiled binary size. 5-20mb is reasonable, larger is NOT.

2. Dependency free binary, statically linked and self contained.

3. Low memory footprint.

4. Scalable to large number of clients.

I would love to work either in Swift or TypeScript, but those don't appear to be viable options. Please correct me if I am wrong, especially when it comes to Swift.

Go and Rust are my top contenders at the moment. Any other languages I should consider? Any specific stacks that you liked in the past?

PS: I am well aware of many ways to package JS code, Python code, etc, but those options are neither dependency free in practice or particularly size and memory efficient.

  • by aszen on 4/10/21, 4:57 PM

    Ocaml and Haskell are two other contenders if you are looking to learn functional programming. Both compile to native code and quite effecient.

    Haskell has few web frameworks which are worth taking a look.

    Needless to say C++ may also be an option given your familiarity with C.

    Other newer contenders are Crystal and Nim. Both look promising but are still young languages.

    DLang and Zig are more known for systems programming but like rust can also be used for web programming.

    For a go like language also take a look Vlang (which has a lot of stuff built-in, web framework, orm, testing, ...)

    I think all of these languages fit your requirements, as you can see there's quite a lot of choice these days. As usual there is no right or wrong way to go. (:

  • by sylvain_kerkour on 4/10/21, 7:40 PM

    Even if I'm a big Rust fan and user, what you are describing is exactly the use case that Go is designed for, especially since 1.16 with embed[0].

    The big plus is that you can even configure Go to automate TLS certs[1].

    [0] https://blog.golang.org/go1.16

    [1] https://github.com/skerkour/bloom-legacy/blob/27908e44dd45b3...