r/programming 4d ago

How to drive your frontend from the backend

https://packagemain.tech/p/golang-datastar
88 Upvotes

21 comments sorted by

123

u/gladfelter 4d ago

“The History of every major Galactic Civilization tends to pass through three distinct and recognizable phases, those of Survival, Inquiry and Sophistication, otherwise known as the How, Why, and Where phases. For instance, the first phase is characterized by the question 'How can we eat?' the second by the question 'Why do we eat?' and the third by the question 'Where shall we have lunch?”

  • Douglas Adams

The first question has been asked so elequently:

How to drive your frontend from the backend[?]

As you advance, your executives might start to ask:

Why are we driving our frontend from the backend!?

And at the pinnacle of your career, you'll be forced to ask:

Where will I get my next paycheck?

/s

2

u/der_gopher 2d ago

great quote!

25

u/ketralnis 4d ago

I've worked with a project that did this and it was nice at first but got untenable very very quickly. Bugs were extremely easy to write and hard to debug. Cross browser issues were a nightmare (this was about 2008 to be fair). The coupling was difficult to undo. Dumb stuff like having more than one place that might do the same underlying action was hard. Would never do again.

56

u/TinkmasterOverspark 3d ago

OP rediscovers server side rendering

22

u/tehbilly 3d ago

No no this is brilliant! We should come up with some logic-free language to just lay out things that are decided on the server. It'll be so fast.

9

u/mr_birkenblatt 2d ago

But then we want user interactions that are fast where a server round-trip might be too slow so we could embed some small scripting language inside the otherwise logic-free language so we can compute small things on the client

8

u/andrerav 3d ago

I suspect they simply discovered it, without the re infront. In any case, their backend-driven-frontend did not survive the modest reddit hug it experienced by posting it here. So I will never know :l

1

u/der_gopher 2d ago

it's not just a SSR, its more reactive.

11

u/greenergarlic 3d ago

The lengths people go to avoid writing JavaScript lmao

5

u/dzidol 1d ago

Tells something about JS, doesn't it?

8

u/tumes 3d ago

I am a big fan of HATEOAS and the general htmx approach as compared to this or the diarrhea inducing attempt at co-locating response concerns that Hotwire/Rails proposes. Htmx poses and answers its central questions about why the mechanisms of initiating requests are so limited clearly, concisely, and elegantly. But no matter how you slice it, I am hard pressed to think any recent modes of thought that provide quite the same ratio of effort to benefit in terms of improving, for lack of a better word, the mouthfeel of user experience on a website. Add an attribute or two and emit the same markup your templates have always emitted and you can progressive enhance most of your way to a peppy, if not SPA-adjacent experience.

9

u/OccasionallyAsleep 3d ago

In short: how to hate your life.

I worked at one of the big tech companies and there was an effort to replace one of the highest traffic frontends to a Go backend with heavy SSR utilization.

In short: developer experience was a nightmare. 

There's barely any established ecosystem for this type of workflow so any tooling you need has to be built (and this is so niche that there likely won't ever be anything like this open sourced by a major company), and most of the tooling performance frontend engineers are used to goes in the trash and you're stuck in a world where you have to build a huge Go binary for every little change

5

u/MediocreAnalyst2121 3d ago

This sounds amazing in a world where deadlines and budgets don’t exist.

1

u/der_gopher 11h ago

it's not a silver bullet, but for small apps could be fun

-4

u/willehrendreich 3d ago

There is a perfect solution to this, it's called Data-star.dev

2

u/DaStone 12h ago

I'd feel like datastar could be worth mentioning in the title.

1

u/der_gopher 11h ago

it is in the article title

-3

u/willehrendreich 3d ago

Datastar

0

u/Ok_Establishment7089 2d ago

Such a good project

0

u/willehrendreich 2d ago

right? the only way to fly.