blueslurpee
Like you I've been on a basically identical search, but instead of coming up from Rust I've come down from dynamically typed languages on the backend. I just couldn't bear another run-time error that would have been easily prevented with Typescript.
I've come to the conclusion that the palette of ergonomic and statically typed languages for the backend is surprisingly quite sparse (when one includes the requirement of a relatively sizable community) if you don't include Java/Go.
Languages I personally crossed off:
* Java - Just much too verbose for my taste, too mutable, too nullable, and I don't find "Kingdom of Nouns" elegant to program in. (The JVM is quite magnificent though..)
* Golang - I get why people like it, and I have absolutely nothing against it. For me it's not expressive enough.
* Typescript - Pretty much 100% what you said. The language itself is wonderful, but it really shines when confined to the browser. The runtime differences between the Browser/Node cause all sorts of problems. Also compiled binaries are nice, which are out here.
I see why somebody might choose each of those languages, and be highly justified in doing so, but for me they didn't fit the bill.
That leaves:
* Scala - Only have very light experience. Really strong support for functional/immutable style programming, and checks all the boxes as another commenter pointed out. Community seems a bit complex at times. I haven't had time to really dive into it, but it's been on my mind.
* Rust - Seems like it nails a lot of things really well. Haven't ever touched it, so I can't give an educated appraisal of its merits. The only real obvious con is that it's "overkill" for systems dealing primarily with business logic, i.e. where GC isn't a big issue.
* Swift - Seems quite excellent, but I had written it off as unsuitable for general purpose stuff. Perhaps a premature take?
* Nim - The one on the list I have played around with the most. Seems to have a very powerful macro system which I have yet to take full advantage of. Feels like a statically-typed python, with a bent towards an imperative style over a more functional one. I am personally thrilled they went with the decision to make "func" a fist-class keyword, with special compiler significance. Still a bit niche however.
I’ve been looking at Nim or Scala for the backend. It’s either that, or just dive into Rust.
It really seems if you don’t want to use Node, Java, or Go the available choices for a statically typed backend get quite slim.
It actually all starts to feel like.... SQL! State is stored globally in a defined schema and queried as needed by the system.
But you can't do this if your compositions are preordained from on high by a rigid class hierarchy, the data is crystallized into the "blessed" projection and that's that. It's analogous to your SQL queries being constrained to solely static views. No JOIN. No GROUP BY. No WHERE.
It's not quite a backend and it's not quite a frontend, but it sort of sits in the middle and (hopefully) helps you achieve lower latency. I haven't used it myself but I think it's a promising idea and based on your post I gather a similar concept worked very well for you.
Assuming a real-time interactive application, the major components would look something like this:
- Backend service distributed geographically to facilitate low latency to clients, with a single writer node and many read replicas
- Backend data store is SQLite, and importantly runs as a process on the same VM as each of the service nodes, so that there is no need for any network roundtrip to query the database on a read operation
- Clients subscribe to the service and receive a single JSON object representing the UI state
- Database modifications trigger a websocket notification to all subscribed clients with the respective diffs to the state object
- On the client side, a library like React (my choice, but of course there are others) watches the state object and renders the UI accordingly. Client writes are routed to the writer node (Traditional caveats about RYOW apply), UI updates are optimistically applied
- Pure client side state (modals, etc.) is handled solely via the frontend
It's tangential to the architecture, but this obviously would be well suited for something like fly.io. I'm sure many of the Phoenix people are nodding their heads as this architecture bears a lot of resemblance to LiveView, which I am also interested in for its own merits.
I see this as essentially a marriage between React/Redux and LiveView; it essentially comes down to having a globally replicated SQLite DB serve as your Redux store, but "over the wire" and it's colocated with your API layer.
What's the motivation? For me, React/Redux with Redux Toolkit is pure bliss for any sort of UI development. Throw in Tailwindcss and you're really rockin'. The problems arise from the impedance mismatch between maintaining application state locally in a Redux store when the true source of truth is your DB, and all the network traffic/caching considerations/api logic that needs to come with that. (You've actually got a distributed system on your hands)
If you can keep the client focused on the UI, then the complexity mostly lives in the API service layer where writes are replicated to all the VMs. It wouldn't work for every style of app, but with a service like fly.io behind you this tradeoff starts to look very attractive.
(Aside: I think this is why a lot of HN'ers are so excited about fly.io. If I can distribute my application and achieve super low latency relatively simply that is a step-change and opens up so many avenues of experimentation for development)
If the application were a more traditional read-heavy website and didn't need real-time updates, I might rip out the websocket layer and replace it with something like Remix, which I see as sort of a "rendering layer" that sits between the client and the backend for React apps.
Anyway, it's an exciting time to be a web dev. I would be curious to hear if anyone else has pondered a setup like this.
EDIT: Formatting
So at the moment I really think I’m stuck between Scala, Haskell, or Elixir.
It’s tempting for people to simply say, “Learn all of them” but for practical reasons that’s not possible at the moment. So thanks a lot for your comment.
In general, it's a low-risk decision, because it's only for personal enrichment. But time is precious at the moment and it would be quite a good bit of fun to hear from some people that simply ~love~ their language.
I know, I know.. questions like this can sometimes lack rigour and lead to a simple cheerleading fest, but I was hoping for a relatively lighthearted thread.
I am also convinced this is not an isolated feeling on my part, what I mean by that is, I'm sure this is a relatively common phenomenon among younger engineers who enjoy CS in and of itself, and I would be very interested in hearing what they have to say.
Thanks for the Zig recommendation!
And fair enough point. To use your analogy, this question is more of the "linguist" side.
If I were solely interesting in the "writer" side, I would be building distributed systems in Go.
Ask HN: Which programming language should a journeyman programmer learn?
Hello HN,I'm looking for some advice and/or enthusiasm on which programming language you might recommend to a young journeyman programmer looking to broaden their horizons beyond the mainstream imperative stock.As some background: Like many from the past decade, I was introduced to programming and cut my teeth via Python, and while it holds a soft spot in my heart for its lovely syntax and...
3factor App Architecture
For instance, assume the future of IT looks like it does today, only ramped up x10. Imagine the majority of business value is driven disparate API's/Services managed by companies or organisations, with numerous and diverse clients that can "plug in" for their respective needs.
GraphQL essentially allows you to simplify the work that any client (internal or external) needs to do to tap into your interface, provided that you invest the appropriate resources on the backend. (which you would, if that were your core business proposition and a piece of your competetive advantage)
If companies continue to digitalize (is there any doubt) then a company's value will be encompassed and driven by the quality of its API, and importantly, it's relative use of connecting with many diverse clients. Therefore backend API's that support and interface to digital products the best will win.
I see GraphQL supporting this in that it trades simplicity and a uniform mono-interface on the front-end for complexity on the backend. I think a lot of firms will look at that trade and call it a great deal.
However the premise of their statement is that it used to be more feasible for one person to "do it all", whereas now things have transitioned towards a more team-oriented environment.
I observe this trend patently in reverse.
I find actually the opposite to be true. The leverage of individual engineers is only growing with the advent of SaaS and the proliferation of API's. Then of course there are the stories of small engineering teams with Unicorn exits, e.g. Instagram, WhatsApp, etc.
Do you have any thoughts on the “native vs. React native” question?
Ask HN: How is Swift UI performing for you in late 2021?
My team and I need to build a mobile application which will involve complex views and animations, and long term down the road access to important hardware on the phone. (Think new LiDaR scanner on iPhone 12).Many on my team push for React Native but I believe native code is the smarter choice.People using SwiftUI what has your experience been like? Threads from late 2020 and early 2021 mention...
Ask HN: Small shops, how do you do CD?
Hi, I'm looking if any of the solopreneurs or small shops (5-10 people) could give some insight into their CD.Do you practice CD, and if so how?I run two unrelated Django monolith applications, which serve me very well. I use CircleCI for Continous Integration, and it works well enough. The benefits of CI are of course muted if one is rolling completely solo, however I'm bringing on another dev...
Ask HN: Simple Deploys Scaled to Large Businesses?
Hello -I am looking for war stories from simple deployments that scaled to large businesses. Does anyone on HN have any stories of running a large business solo, or with just a few engineers?I just love those stories of "We scaled to $500k+ in Revenue all running on one phsyical linux box with mySQL and Apache."Perhaps the 2020 version would read something like: "We scaled to massive amounts of...