Debian Codegraph @

www/src/content/essays/hypermedia-on-whatever-youd-like.mdx

raw
1 ---
2 title: "Hypermedia On Whatever you'd Like"
3 description: "In this essay, Carson Gross explores the concept of 'The HOWL Stack' (Hypermedia On Whatever you'd Like) and argues that using a hypermedia-driven approach for web applications allows developers to choose their preferred server-side technology, freeing them from the pressure to use JavaScript throughout their entire stack while maintaining modern web functionality through HTML and hypermedia enhancements."
4 created: 2023-05-23
5 authors: ["Carson Gross"]
6 tags: ["the-case-for-hypermedia"]
7 ---
8
9 > The one big remaining (advantage of MPAs) is (server side programming) language choice. If you're already part of the
10 > anti-JavaScript resistance, then nothing I say in the rest of this talk is going to matter that much.
11 >
12 > But, I'm going to get into this later: that ship might have sailed...
13 >
14 > Rich Harris - [Have SPA's Ruined The Web?](https://youtubetranscript.com/?v=860d8usGC0o&t=440)
15
16 A concept we like to talk about is "The HOWL Stack". HOWL stands for _Hypermedia On Whatever you'd Like_.
17
18 This is a joke-but-not-really [software stack](https://en.wikipedia.org/wiki/Solution_stack), and a reference to more
19 well known stacks like [The LAMP Stack](https://en.wikipedia.org/wiki/LAMP_%28software_bundle%29)
20 or [The MEAN Stack](https://en.wikipedia.org/wiki/MEAN_(solution_stack)).
21
22 The TLDR of The HOWL Stack is this: when you use a [hypermedia-driven approach](/essays/hypermedia-driven-applications)
23 for your web application, you free yourself up to choose _whatever_ server-side technology best fits your problem and
24 your own technical tastes.
25
26 ## Feeling The JavaScript Pressure
27
28 If you decide to use an SPA framework for your web application you will, naturally, have a large front-end codebase
29 that is written in JavaScript.
30
31 Given that, the following question inevitably will come up:
32
33 > "Well, why aren't we doing the back-end in JavaScript too?"
34
35 This is a reasonable question to ask and there are a lot of advantages to adopting the same programming language on both
36 sides of the wire:
37
38 * You can share application logic between the two code-bases. A good example here is validation logic.
39 * You can share data structures between the two code-bases.
40 * You can build up expertise in a single language, JavaScript, making it easier for developers to work in various parts
41 of your application.
42 * You can reuse the build system & dependency management knowledge you've acquired for the front end
43
44 This _pressure_ to adopt JavaScript will only grow as your investment in the JavaScript front end ecosystem grows.
45
46 Furthermore, JavaScript has improved dramatically in the last five years and there are now multiple excellent
47 server-side runtimes for executing it. Many of the older arguments about the messiness of the language can be
48 waved off as preventable via linting, developer discipline, and so forth.
49
50 JavaScript is the dominant language among the web development thought leaders and there are massive numbers of
51 tutorials,
52 code camps, etc. that strongly emphasize the language. Nothing succeeds like success, and JavaScript (as well as React)
53 have succeeded.
54
55 Let's call the result of this _The JavaScript Pressure_ and acknowledge that nearly every developer working with the
56 web feels it at least to some extent.
57
58 ## Hypermedia: Our Only Hope
59
60 What hope do non-JavaScript developers have in web development?
61
62 Well, there is one older technology sitting there in the browser alongside JavaScript: _hypermedia_.
63
64 Browsers offer excellent HTML support (and the related Document Object Model, or DOM). In fact, even if you are using an
65 SPA framework, you will be working with that hypermedia infrastructure in some form (via JSX templates, for example) if
66 only to create UIs that a browser can understand.
67
68 So you are going to be using HTML or the related DOM APIs in some manner in your web application.
69
70 Well, what if we made HTML a more powerful hypermedia?
71
72 That's the idea of [htmx](/), which makes it possible to implement [common modern web application patterns](/patterns)
73 using the hypermedia approach. This closes the UX gap between traditional MPAs and SPAs, making taking the hypermedia
74 route feasible for a much larger set of web applications.
75
76 Once you adopt this hypermedia approach (and remember, you are going to be using hypermedia infrastructure _anyway_,
77 so why not leverage it as much as possible?) a surprising side effect occurs:
78
79 Suddenly, the advantage of server-side language choice that Harris attributed to MPAs is _back on the table_.
80
81 If your application's front end is mainly written in terms of HTML, maybe with a bit of client-side scripting,
82 and with no large JavaScript code-base, you've suddenly dramatically diminished (or entirely eliminated) The JavaScript
83 Pressure on the back end.
84
85 You can now make your server-side language (and framework) choice based on other considerations: technical, aesthetic or
86 otherwise:
87
88 * Perhaps you are working in AI and want to use a Lisp variant for your project
89 * Perhaps you are working in big data and want to use Python
90 * Perhaps you know Django really well and love the batteries-included approach it takes
91 * Perhaps you prefer Flask and the stripped-down approach it takes
92 * Perhaps you like the raw, close-to-the-HTML feel of PHP
93 * Perhaps you have an existing Java codebase that needs some sprucing up
94 * Perhaps you are learning
95 Cobol, [and want to use htmx to make a nice front end for it](https://twitter.com/htmx_org/status/1656381761188954113).
96 * Perhaps you just really like Rust, Ocaml, Kotlin, Haskell, .NET, Clojure, Ada, ColdFusion, Ruby... whatever!
97
98 These are all perfectly reasonable technical, philosophical and aesthetic perspectives.
99
100 And, by adopting hypermedia as your primary front-end technology, you pursue any of these goals without a bicameral
101 code-base. Hypermedia doesn't care what you use to produce it: you can use hypermedia on whatever you'd like.
102
103 ## An Open Web for Everyone
104
105 And when we say "whatever", we really mean it.
106
107 Here is a screenshot of the [htmx discord](/discord)'s HOWL subsection recently. Note that these are just the channels
108 that happen to have active traffic, there are many more.
109
110 <div style="text-align: center; padding: 16px">
111 <img src="/img/howl-channels.png" alt="Django, alpine, bash, clojure, cobol,
112 deno, dotnet, go, java, node, ocaml, php, ruby, rust -- all active."/>
113 </div>
114
115 You can see we have ongoing conversations in a bunch of different programming languages and frameworks: Java, Go, .NET,
116 Rust, Clojure, PHP, Ruby, Python, Ocaml. We even have some folks talking about using htmx with Bash and Cobol!
117
118 This is exactly the future that we want to see: a rich and vibrant Web in which _every_ back-end language and framework
119 can play as an equal & interesting alternative. Each language and framework has their own unique strengths & cultures
120 and
121 each can contribute to the magical [hypermedia system](https://hypermedia.systems) that is The Web.
122
123 ## But, Is it An *Anti*-JavaScript Resistance?
124
125 Before we finish this essay, we do want to address the idea that the resistance to JavaScript *everywhere* is
126 necessarily
127 *Anti*-JavaScript.
128
129 Now, admittedly, we have laughed at our fair share of [jokes about JavaScript](/img/js-the-good-parts.jpeg), and we have
130 gone so far as to create an alternative scripting language for the web, [hyperscript](https://hyperscript.org).
131
132 So it might seem like we should be card-carrying anti-javascriptites.
133
134 But, to the contrary, we are deeply appreciative of JavaScript.
135
136 After all, both htmx and hyperscript are _built in JavaScript_. We couldn't have created these libraries without
137 JavaScript, which, whatever else one might say, has the great virtue of [_being
138 there_](https://en.wikipedia.org/wiki/Being_There).
139
140 And we even go so far as to _recommend using_ JavaScript for front-end scripting needs in a hypermedia-driven
141 application, so long as you script in a [hypermedia-friendly](/essays/hypermedia-friendly-scripting) way.
142
143 Further, we wouldn't steer someone away from using JavaScript (or TypeScript) on the _server side_ for a
144 hypermedia-driven application, if that language is the best option for your team. As we said earlier, JavaScript now
145 has multiple excellent server-side runtimes and many excellent server-side libraries available.
146
147 It might be the best option for you and your team, and there is no reason not to use it in that case.
148
149 Hypermedia On Whatever you'd Like means just that: whatever you'd like.
150
151 But JavaScript is not, and it should not be, the *only* server-side option for your team.
152
153 ## Turning The Ship Around
154
155 With the resurgence of interest in (and improvements of) hypermedia, an open and diverse future for The Web is now a
156 real possibility, if not an emerging reality.
157
158 The Web was designed to be an open, polyglot & participative hypermedia system.
159
160 And the ship _hasn't sailed_ on that dream, at least not yet!
161
162 We can keep that dream alive by re-learning and re-embracing the foundational technology of the web: hypermedia.
163
164 > I hate that the htmx community has devolved into builders helping each other without regard for likes, engaging
165 > those who don't follow the hype, expanding sound bytes into nuance. It may not score cheap social media points, but
166 > it's healthy. The web used to be worse than this.
167 >
168 > [@teej_dv](https://twitter.com/teej_dv/status/1655668643840098304)