132 points · by bpierre · 4y ago · 43 comments
also was discussed on the latest syntaxfm https://syntax.fm/show/515/wtf-is-enhance-framework
(disclosure, am tiny angel investor in Begin, but Enhance is really kind of a different project)
If all this is is composing plain ol’ HTML, which are just strings, any language will do. We have file based routing in Go in less than 10 lines of code connecting filesystem calls to Go’s template package. We have live reload with Air, too, and the builds times are under a second. Another nice thing with go is Filesystem embedding, so we build the HTML strings straight into the binary and deploy the binary as is.
It’s a framework that lets you write JS functions that are used to render HTML on the server but also run on the client for progressive enhancement which is what your Go pitch does not do.
We have progressive enhancement in our Go app based on HTMX.
Also see Rails/Turbo and Pheonix/Elixir.
Also, before the era of JS devs who only know the hammer of React and React-inspired HTML rendering libraries, there was PJAX to do progressive enhancement. It's not that hard of a problem to motivate reinventing the wheel HTML rendering wheel with yet-another-JavaScript-framework. In that light, it's probably better to just stick to React which provides a superset of functionality and is battle-tested, but I digress. Most of the original complexity of PJAX was smoothing out browser inconsistencies. It's way easier to add progressive enhancement with standardized HTML5 libraries.
Observe how this JS library's source repo doesn't have a package.json and the vendor directory is rather shallow. The first commit was before Node.js even existed.
As for HTMX, it's a JavaScript library. It's 10kB with zero dependencies, and you can just drop-it in with a script tag. I never criticized JS or a particular JS library. My original comment is about the dependency hell (and quality) of Node packages.
> framework that lets you write JS functions
Why is it important to have a framework and to write it is as JS function? That's an incidental detail if the goal is to compose HTML.
> rambling about your favorite language.
No, JavaScript is my favorite language. I just don't like NPM culture. We chose Go because it made sense for our use-case, as opposed to Node.js being an automatic default just because it's a frontend hammer.
That way lies XSS attacks, might be better to have a DOM of some kind in your language.
Being a JavaScript-based doesn't preclude you from XSS, either.
You're better protected using web frameworks than trying to reinvent things by yourself, surely, but also let's not believe in miracles.
Nodejs is a performant runtime and React is not only for creating SPAs.
How do you plan to add JS to your Go web app?
This is what I mean by Node.js being a hammer and everything looks like a nail.
You don’t need Node.js to write JavaScript.
Yes, but you generally do need NodeJS to access NPM packages, which will provide a ton of JavaScript functionality for free.
To the user who posed this question, I'm sure what they meant could be more charitably read as:
"How do you plan to access the thriving JS / NPM web ecosystem from another language ecosystem entirely?"
You've certainly listed some upsides to Go, but then your response to someone requesting a more honest analysis of the downsides is "Node.js devs are idiots". Hm.
You don't need to be building an SPA in order to want to have some client-side javascript. And you may want to use some third-party libraries for your client-side javascript. Npm is a decent distribution channel / dependency manager for that purpose.
Why not have your framework find standard .html files in a well-known location and wrap them in the boilerplate for me?
That way, I don't even need to think of them as something else - they are just HTML - and the magic is happening with me even seeing the wand
I suppose it’s a matter of taste.
You continue not getting it. That's an unnecessary overhead. Strictly speaking, you don't need it. If you can get away with not including it then you absolutely should skip it.
You guys can take some lessons from the so called static site generators. They have the right idea. Also Svelte which kind of does something very similar (although it does compile things to more vanilla JS which I like because less frameworks and inclusions).
I dream of being able to author web content with just a text editor.
Because HTML started life as an SGML application/vocabulary, and with SGML having entities (and link process declarations/stylesheets) for exactly these purposes, there was no need to invent HTML ad-hoc mechanisms. SGML templating based on SGML LINK works in a push (event-driven) style, with fully type-checked and HTML-aware semantics, quite different from your typical pull style embedding of whole programming languages that spit out unescaped strings ([1]).
Of course, browsers never came around to implement even basic SGML features such as entities (except for character entity references), and by 1994 or so, JavaScript was already introduced, making any HTML evolution inessential by introducing a Turing-complete language into the mix.
Using PHP as a template language, it is trivial to generate static HTML content by calling PHP from the command line on your files (this is easily automated to scale for many many pages website) to be able to host the result everywhere even on hostings that do not have PHP :).
Maybe it could be useful for the project to position itself against these other frameworks more directly?
That almost everything on the frontend is over-engineered, I don't think any reasonable programmer would disagree with. It's true.
But since people are stuck with HTML, CSS and JS they try hard to make it more manageable. Pieces of tech like HTMX and Svelte improve the status quo. Not everything is bad in there.
...That still doesn't mean I want to do frontend work though, heh.