Could you please discuss your favorite web frameworks and the features they provide?
If you don't have a particular favorite, could you share the features that you'd like to see in web frameworks? ๐
I agree almost 100% with what @Isofruit brought up. I would like to be specific and say that I'd like .NET-style validation, with controller methods mapping to routes, their arguments being used to generate JSON validators automatically, and the ability to use annotations to customize it further.
Since that is a limitation of the HTTP server prologue uses: I'd love a framework that has the ability to deal with large file uploads and downloads. Namely, if I wanted to upload a file that is 350 MB large, the server should be capable of handling that.
You should check out @pwernersbach's excellent MicroAsyncHttpServer library. It's slightly faster than httpx when multithreading, and it's nearly 100% API-compatible with stdlib's AsyncHttpServer. The difference is that it doesn't load bodies entirely into memory, and instead lets you stream them. I worked with @pwernersbach a month or two ago to clean up the library a bit and make it more usable so I could use it in a web framework I was writing.
Unfortunately, I ended up hitting many hurdles in that search, but TL;DR if you want to do multithreading with asyncnet, stay away from ORC for now. I did a deep dive into all the HTTP servers I knew a few months ago in this thread if you're interested in reading about my thoughts on the general state of HTTP servers in Nim.
@jasonfi
I'd say Next.js, mainly because of React being reactive and having excellent tooling.
I think fullstack web frameworks are good in theory, but tying your backend teck to your frontend tech is a bad longterm decision, because it makes migration very difficult. They also usually don't have very good performance, but unlike a backend where the only shared things are data type definitions (generated with OpenAPI/Swagger or similar), with a fullstack framework, your library is inextricably linked to your entire project, not just frontend.
When it comes to a fullstack framework in Nim, I simply am not comfortable shipping the massive bundle sizes that Nim JS produces. It sounds fine until you realize that, as of the time of posting, forum.js is 793.69KiB uncompressed, and 114.94KiB gzipped, partially due to bizarre codegen like this:
// ...continued...
case 97:
case 98:
case 99:
case 100:
case 101:
case 102:
case 103:
case 104:
case 105:
case 106:
case 107:
case 108:
case 109:
case 110:
case 111:
case 112:
case 113:
case 114:
case 115:
case 116:
case 117:
case 118:
case 119:
case 120:
case 121:
case 122:
case 65:
case 66:
case 67:
case 68:
case 69:
// ...continued...
For size reasons alone, I don't think Nim JS is suitable for most websites, and even many web applications.
You should check out @pwernersbach's excellent MicroAsyncHttpServer library. It's slightly faster than httpx when multithreading, and it's nearly 100% API-compatible with stdlib's AsyncHttpServer. The difference is that it doesn't load bodies entirely into memory, and instead lets you stream them. I worked with @pwernersbach a month or two ago to clean up the library a bit and make it more usable so I could use it in a web framework I was writing.
@termer, HappyX uses asynchttpserver, httpx and microasynchttpserver ๐
When it comes to a fullstack framework in Nim, I simply am not comfortable shipping the massive bundle sizes that Nim JS produces. It sounds fine until you realize that, as of the time of posting, forum.js is 793.69KiB uncompressed, and 114.94KiB gzipped, partially due to bizarre codegen like this:
HappyX have CLI that can build your JS file from 600+ Kb to 50-60 Kb โ
I agree almost 100% with what @Isofruit brought up. I would like to be specific and say that I'd like .NET-style validation, with controller methods mapping to routes, their arguments being used to generate JSON validators automatically, and the ability to use annotations to customize it further.
HappyX have powerful routing/mounting system and it support request models (at moment only JSON body)
You build skyscraper or private village house differently. If you bring 100t Liebherr crane to village, neighbours would ask you stupid or what.
But in programming, there are unquestioned "best practices". And peple blindly applying Facebook-scale practices to small and mid dev shops.
All this performance, zero-overhead, micro-service archtecture, contenerisation, graph-ql, and so on and on. Those are good things, if you build skyscraper.
But for small and mid level companies best feature is - one man army. The developer time is the most scarce resource, and you trade other features (like all those listed above) to save it.
Somebody called it "Resume Driven Development".
As a side note, the "hyperscale" companies are not using most of the new fancy tools of the month internally, especially around critical infrastructure.
I can't say about ORC, but libraries httpx and microasynchttpserver support multithreading
btw in HappyX you can use it via -d:httpx and -d:micro ๐
Personally, I only want a fast webserver. case statement on the path and method are good enough for me.
I don't use an ORM- I either use raw typed SQL with tiny_sqlite, or limdb if I don't need SQL querying. I spent too much time trying to get the ORM to spit out the query I want. I do like some kind of serialization that the frontend likes.
I do like easy websockets and I really dig writing the frontend in Nim.
So I would say my web framework is asynchttpserver, ws, jsony, tiny_sqlite, limdb, and karax- for small projects a few lines of javascript.
Note send HTML (without attributes) over websockets sometimes for โdisplayable data serialization". You can both parse it to get the values, or dump it into an innerHTML and style it.
I don't use an ORM- I either use raw typed SQL with tiny_sqlite, or limdb if I don't need SQL querying. I spent too much time trying to get the ORM to spit out the query I want.
Just replying here to make sure you are aware of my Ormin project. You might like it.