this post was submitted on 27 Apr 2024
21 points (100.0% liked)

Programming

423 readers
2 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
 

Let's say we don't care about the backend<>frontend interconnection we see in most JS frameworks. We just want to program the backend. What would be the language of your choice?

top 15 comments
sorted by: hot top controversial new old
[–] Ephera@lemmy.ml 23 points 6 months ago

I feel like you could've asked "what's your favorite language?" and gotten the same responses. Like, it's Rust for me. I could argue that because Lemmy is written in Rust, there's already some mature libraries to work off of, but someone else could argue that for e.g. Ruby, too.

[–] Empathy 8 points 6 months ago* (last edited 6 months ago)

Rust, because I'm lazy and I want a compiler that helps me out. Performance is a pretty neat bonus.

[–] nous@programming.dev 7 points 6 months ago

Whatever language you chose you might want to also look at the htmx JS library. It lets you write in your html snippets better interactivity without actually needing to write JS. It basically lets you do things like when you click on an element, it can make a request to your server and replace some other element with the contents your server responds with - all with attributes on HTML tags instead of writing JS. This lets you keep all the state on the backend and lets you write more backend logic without only relying on full page refreshes to update small sections of the page.

For a backend language I would use rust as that is what I am most familiar with now and enjoy using the most. Most languages are adequate at serving backend code though so it is hard to go wrong with anything that you enjoy using. Though with rust I tend to find I have fewer issues when I deploy something as appose to other languages which can cause all sorts of runtime errors as they let you ignore the error paths by default.

[–] hazelnoot 5 points 6 months ago

The frontend is HTML only? Then I'd go with C# and ASP.NET Razor pages. Modern language with good DX, performant runtime, and server-side rendering.

[–] Paradoxvoid@aussie.zone 5 points 6 months ago

If I really hate front end, but still want a lot of the responsiveness of a SPA, I'd have to give ASP.NET Blazor a serious thought.

It's largely all back end driven, with the dynamic elements driven via webassembly that pretty much works like black magic.

[–] Kissaki@programming.dev 4 points 6 months ago (1 children)

You're asking about the backend only, separated from the fronted? The fronted will be HTML only, but independent of the backend anyway?

Doesn't that mean you're introducing another interface and a need for another backend for the HTML frontend generating?

If it's independent, why does the frontend intention matter?


My first choice/exploration would be C#/.NET.

[–] smileyhead@discuss.tchncs.de 1 points 6 months ago

I just ment that there will be nothing special being done there. Server would just send the result in plan HTML, that would be used and styled as a widget in something else later.

[–] eric@lemmy.ca 4 points 6 months ago

Most of my experience is in .NET at work. My professional recommendation is C#, but my personal recommendation is Go. I find Go to be just nicer to code with.

[–] mr_satan@monyet.cc 4 points 6 months ago

Maybe Go, haven't messed with it at all and it looks interesting enough to try. Other than that I could do C#, since that's where I have most experience. Maybe node.js if I would want to suffer a bit.

[–] RobotToaster@mander.xyz 3 points 6 months ago

I've considered doing something similar myself, honestly it would come down to which one has the best libraries/frameworks for it.

[–] farcaller@fstab.sh 2 points 6 months ago

Any language you’re comfortable with is good for that. Ruby, JS, and Go come to mind the first because they all have solid ActivityPub libraries which are going to save you some time on interconnection. Any programming language can do static html.

[–] MNByChoice@midwest.social 2 points 6 months ago (1 children)

I would want something simple, extensible, and easily readable. I would write in the clearest way possible in Bash with small, single purpose programs handling anything performance critical.

[–] mox@lemmy.sdf.org 5 points 6 months ago* (last edited 6 months ago)

easily readable

Bash

This makes me wonder if you might benefit from exploring more programming languages.

I've never found shell scripts (beyond the most trivial tasks) to be especially readable. Bourne-style shells in particular (e.g. bash) have a lot of easy-to-miss nuances that will lead to bugs if not carefully managed.

Hats off to you if you can do a good job of it, but it sounds to me like a recipe for pain when it comes to long-term maintenance.

[–] stevecrox@kbin.run 1 points 6 months ago* (last edited 6 months ago)

My expectation is whatever the solution it needs to dockerise and be really easy to deploy via docker compose or Kubernetes so people can quickly and easily set up their own.

The front end is effectively static files so I would probably choose Apache or Express (whichever gives me a smaller docker image)..

For the backend I would choose Java for Spring Boot. An Alpine image with OpenJDK and the app is tiny. Spring has a library for every kind of interface making them trivial to implement but the main reason is hibernate.

Hibernate (now Spring Data) was the first library for being able to switch out databases without having to change code (its all config). A lot of mastodon instances struggle with the resource requirements of elastic search so letting small instances use something like postgres would seem ideal.

I have noticed Go/Rust still expect you to write or manage a lot of stuff Spring gives away for free. Python is ok if your backend is really tiny but there is a lot of boilerplate in how Python libraries work so complex projects get hard to manage and I assume interacting with the fediverse will add complexity.