4 ms·
Ask HN: Why are all of the best back end web frameworks dynamically typed?
Ruby on Rails, Django, Node JS all have great developer experience, are highly configurable but easy to use and hit the ground running.
Spring, Gin, anything Rust, .Net, etc all are very difficult to configure properly for even the most simple SaaS products.
Why is that? Are there any good statically typed web frameworks?
- hitpointdrew 3y agoI would argue Gin/Go isn't really statically typed. I mean sure you can specify that this var is a int32, but pretty much every tutorial, every code snippet out there, will do. myvar := 10 And just let Go guess what the type should be. So yeah, Go CAN be statically typed, but in practice it rarely is.
- calderwoodra 3y agoAren't go types determined at compile time? That would make it static in my book. But regardless of that, are you also implying that Gin is as good as nodejs/Django/ror? There are lots of bad dynamically typed web frameworks, but I'm looking for a good one that's statically typed.
- htljwfasdf 3y agoWhat you are observing here is actually called "Type Inference".
- tom_ 3y agoBut the point is, the name is that type, a property enforced at compile time. If you do ``myvar:=10'', you can't then do ``myvar="fred"'', because the value of myvar must be an integer.
- Jtsummers 3y agoThat's type inference, not dynamic typing. The two are distinct language features. Many statically typed languages offer type inference: Haskell, C++, Rust, Java, D, SML, OCaml, C#, F#. Good luck convincing people that those are dynamically typed languages just because they have type inference.
- ActorNightly 3y agoBecause development speed and flexibility matter way more than "correctness". Engineer salary is expensive, and there is software to manage running processes that makes errors in software in niche cases not a big deal because it can just restart the failed container or the failed process, publish logs, and then an engineer can implement a patch.
- calderwoodra 3y agoIIUC, you're saying that failures are low stakes, so even if a good framework existed, the idea of using static types is flawed since is only slows you down compared to dynamic types. I disagree but my position is purely preference/subjective. The main point for me is that static types make reading other teammates code much easier. If I could use statically typed python/Django, that would be amazing.
- kingkongjaffa 3y agoYou probably already know but you can add type hints and then check for consistency with https://github.com/python/mypy https://github.com/python/mypy in python. Modern Python with things like https://learnpython.com/blog/python-match-case-statement/ https://learnpython.com/blog/python-match-case-statement/ + mypy + Ruff for linting https://github.com/astral-sh/ruff https://github.com/astral-sh/ruff can get pretty good results. I found typed dataclasses (https://docs.python.org/3/library/dataclasses.html https://docs.python.org/3/library/dataclasses.html) in python using mypy to give me really high confidence when building data representations. And there's https://pypi.org/project/django-stubs/ https://pypi.org/project/django-stubs/ for working with Django.
- catlover76 3y agoThings like MyPy and Pyre end up being a pain to setup, in part because of an annoying and unautomated "stub" ecosystem (it was like back in the day when you had to manually install or declare types for every JS package used in a TypeScript project). It really just doesn't feel as good or useful as using a statically typed language.
- satvikpendem 3y agoWhat do you mean hard to configure? I use Axum with Rust just fine.
- gavmor 3y agoBecause junior developers don't know how to do Type-Driven Development.
- calderwoodra 3y agoSadly, I think there's some truth here which is unfortunate because it would do them a world of good to learn!
- gardenhedge 3y agoSpring is pretty simple, it works out of the box (spring boot) and the docs are good.
- holoduke 3y agoBut soon you will run into performance issues because not a single developer in your team ever wrote a plain sql query and simple actions resulting into 1000 queries.
- gardenhedge 3y agoThat's not spring though, that's poor developers
- calderwoodra 3y agoI like to think of myself as a pretty good engineer, but I spent countless hours trying to get authentication of any kind working in spring and it was very painful. It's been a few years (2020) since I tried but that was just one of many roadblocks I hit trying to get spring boot to work.
- Bridged7756 3y agoThis is just preposterous. Out of all programming languages I've used, never have I seen the bloat of Spring. Innumerable interfaces, abstraction behind layers and more layers to do the most basic of changes, not to mention the bizarre fetish of Java developers to NOT write code and instead relying on "hacks" (Annotations). Spring boot sure, Spring boot works out of the box by slashing all of the configuration from spring, "convention over configuration" they say, which does not help understanding the underlying magic that Spring does, it just adds more magic upon it, so it's just yet another layer of abstraction to learn. Is that all? No! We need more annotations, so add Lombok on top of the existing @ hell.
- smrtinsert 3y agoClearly a question rooted in grounded science (not).
- catlover76 3y agoI don't think Django or most NodeJS frameworks are all that pleasant to use (I especially dislike the monstrocity that is NextJS). .NET MVC is a very good framework, but I know the devops can be weird and a pain. Overall, most frameworks get in the way anyways, IMO. I prefer to cobble together several modules that each do one thing well. E.g. use FastAPI for the endpoints, and any unrelated ORM you like for DB stuff, etc.
- syndicatedjelly 3y agoWhat are some things you don’t like about Django?
- catlover76 3y agoOff the top of my head and non-exhaustive? Not a fan of the lack of real controllers and the way the endpoints are defined, especially when it comes to class based views, mixins, etc; and, while, the ORM is mostly good and useful, I think it has a couple features (like through fields) that obscure too much what is actually happening at the DB level. I suspect that if I really sat down and tried to more thoroughly write my thoughts on the subject, a lot the things that annoy me with it may just apply to dynamically typed languages in general (and sometimes just Python in general).
- pharmakom 3y agoSuave is the best web framework I have ever used, and it’s on the extreme end of the strong-static typed spectrum. I don’t think the dynamically typed ones are better, just better known.
- throwaway858 3y agoIHP is a batteries-included web framework similar to "ruby on rails" for Haskell, with strong static typing. The website has lots of information and videos and beginner tutorials. https://ihp.digitallyinduced.com/ https://ihp.digitallyinduced.com/
- mixmastamyk 3y ago"Move fast and break things" doesn't lend itself to the drudgery and cementing/ossifying nature of the statically-typed languages of 15+ years ago. They've both improved and the industry has matured.
- davidthewatson 3y agoI found IHP straightforward: https://ihp.digitallyinduced.com/ https://ihp.digitallyinduced.com/ despite not remembering much haskell! This assumes you can get past nix for the install. I find IHP well-designed. I just wish the licensing scheme were more transparent.
- nathants 3y agothese days the best web framework is net/http.