
Ask HN: Compiled Web App - alcover
I desperately want to build radically fast and lean web apps.<p>My stack at the moment is nginx &gt; nodejs &gt; sqlite.
To step it up I want to replace nodejs with a compiled app.
What language should I use ?<p>Precision : I&#x27;d prefer a C-like language since I&#x27;m comfortable in JS and C.<p>- C&#x2F;C++ are excluded for obvious reasons.<p>- D looks REALLY nice but lacks momentum at first glance. (few packages - only one for async-http, one for sqlite - and a not-so-busy forum)<p>- Go ? I&#x27;d like to avoid it.<p>- Zig : as alluring as D but not stabilized.<p>- Rust : too unfamiliar.
======
simplecomplex
Haskell!

If you aren't proficient in a functional language like Haskell then you
haven't completed your programming education. Go, Rust, D, etc. are all just C
with fancy features. Change your whole programming paradigm.

Here's a great deep-dive into Haskell web server performance:
[https://www.aosabook.org/en/posa/warp.html](https://www.aosabook.org/en/posa/warp.html)

And if you're building an API you don't need to code! Just throw postgREST in
front of a postgreSQL database and get a haskell-powered API for free. No need
to write a web server.

~~~
alcover
Damn.. that Warp lib looks powerful. Although from 2012, that benchmark
against Nginx is unbelievable.

> Go, Rust, D, etc. are all just C with fancy features

Come on.. Their fanciness is very helpful. Doing web in C is tedious,
insecure.

> Change your whole programming paradigm.

That is no small endeavour but I hear you !

------
explorigin
Need more info. What do you mean by radically fast? Unless you're doing lots
of computation in your web request, then the "steering code" that is currently
nodejs is almost never your bottleneck. 90% of the time your database is your
bottleneck. sqlite can be crazy fast for one request at a time so it just
depends on your app.

~~~
alcover
By 'radically' I mean the fastest possible - short of writing a single blob in
C integrating an http server.

Since I want to keep it modular, the db part with sqlite is already optimal.
Now I need the app on par : statically typed, compiled.

------
therockhead
I know you said Rust was too unfamiliar but if you want the efficiency of C++
but in a safe language this is where I would start (and what I’m currently
learning). For what it’s worth, the Rust web framework Actix has some of the
best performance numbers on techempower.

~~~
alcover
Thank you. Indeed it ranks top. Followed by.. a Java framework (es4x) ?

The D one (vibed) doesn't shine much. Alas.

Maybe you're right and I should take the dive with Rust.

------
fouric
If you're willing to exclude D because it "lacks momentum", Go because you'd
"like to avoid it", and Rust because it's "too unfamiliar", then you're really
out of options. I don't think there exist any other performant, popular,
compiled languages that are similar to Javascript; all of them fail one of
your criteria or another:

\- Haskell: very fast but probably more "unfamiliar" to you than Rust

\- Common Lisp: fast, very stable, easier than Haskell (semantics similar to
Python/Javascript) but definitely not mainstream

\- FORTH: very fast but memory-unsafe and semantically+syntactically almost
polar opposite of most popular languages

~~~
alcover
Thank you,

\- I don't exclude D but it means some untrivial learning in spite of its
semblance to C. I don't have infinite time to learn all promising C++
replacements.

\- Haskell.. really ? Plus it's not fast at all it seems.

\- Lisp : interesting idea. I'd prefer a C-like language but learning it
expands your mind they say.

------
jimnotgym
C# and .net core sounds like a good solution to your rather vague problem.
What are you trying to do?

~~~
alcover
It's more of an inclination for speed than a problem. I have no problem with
my current stack.

C# and .NET are VM/bytecode I think and like 1/4th the speed of C.

~~~
jimnotgym
Perhaps they are faster than well written C, which you say you have
discounted, do doesn't bear comparison.

There have been several articles on HN stating that .NET core is considerable
less resource intensive than Node in real world use cases.

I'm not clear you have a real world use case though.

------
_448
Have a look are Wt ([https://webtoolkit.eu](https://webtoolkit.eu)) and Kore
([https://kore.io](https://kore.io))

------
giaour
Why would you like to avoid Go? It's pretty ergonomic for programmers with C
experience and can compile a web app plus its dependencies into a standalone
binary.

~~~
alcover
Honestly I may have no good reason except maybe speed.

I just read that Go is not best for low-level optimizations, and memory size.

------
billconan
I'm using c++/mongodb for my backend.

I'm gonna rewrite my backend using epoll and coroutine.

~~~
alcover
Exactly what I want to achieve. Compiled and evented.

D permits that. I guess you are comfortable with C++ but I would not even
try..

~~~
billconan
my code is open sourced, [https://github.com/shi-
yan/Swiftly](https://github.com/shi-yan/Swiftly)

it's based on Qt, but my rewrite will be pure c++.

~~~
alcover
Nice if you can get rid of dependencies and threads.

