
JavaScript Is the CO2 of the Web [audio] - feross
https://changelog.com/jsparty/80
======
pier25
He has some great points.

For 5 or so years I've been the guy who immediately started a SPA and I've
turned 180 degrees. I now think SPAs are basically a cancer, with some
exceptions where an app-like website is justified (Gmail, etc) or a hybrid
app. SPAs introduce unnecessary complexity and bloat for the vast majority of
use cases.

~~~
quickthrower2
There is so much entertainment in SPA vs HTML and similarly Vim vs Visual
Studio, static vs. dynamic types etc. debates. But to be boring (sorry!) it
all comes down to the most approriate tool for the job. At work it's a SPA
because it's an application delivered via the web. Delivering via not the web
wouldn't work as well, and delivering it as not an application is a non
starter.

My current side project is a HTML sprinkled with JS, turn off JS and you can
use most of the site kind of thing. Why? Because ... well mainly SEO to be
honest. But there you go ... reasons!

~~~
TeMPOraL
> _But to be boring (sorry!) it all comes down to the most approriate tool for
> the job._

It does. But, depending on how you look at it, either most web companies
absolutely suck at picking right tool for the job, or the job isn't really
what you'd think it is.

Taking your typical plain webpage done as an SPA, you could either say (as I
would) that the authors picked wrong tool for the job, introducing completely
unnecessary complexity both on their end and customer end - or, you could tell
that the job of that website isn't to be useful to and considerate of the
visitor, but to be e.g. CV-fodder for web developers, a way for the team to
show off their sophisticated infrastructure, or for the marketing to play
their A/B testing shenanigans, or for the company to show off to the
investors, etc.

Once you account for all the "parts of the job" that are orthogonal or even
opposite to delivering value to users, suddenly a proliferation of frontend
complexity makes perfect sense.

------
tjpnz
I'm working on a dashboard for a personal project. It involves a few
dynamically populated dropdowns and a map with custom markers. In the past I
might've used jQuery and maybe Backbone in more extreme cases. After looking
into the "modern" options available I ended up writing the damn thing in
jQuery. I did it in a few hours without having to involve Node, npm (or yarn),
hundreds of dependencies (and associated security concerns) or
"(com|trans)pilation)" of anything. The whole process reminded me again of why
I went from fullstack to working exclusively on backends years ago.

~~~
artiscode
Out of curiosity - did you chose jQuery because it's so ubiquitous or was it
the better choice? There are frameworks like vue.js where you don't have to
deal with node, yarn, explicit dependencies and transpilation, that offer
virtual DOM and have very little overhead.

~~~
tjpnz
Better choice ultimately but I suspect the hype around "modern" everything
these days would still lead a lot of people in that direction, even for
simpler things like this. I did briefly look into Vue and didn't completely
hate it. Although the docs (at least from my cursory glance) were suggesting
you would need Node to get up and running with it. Good to know it doesn't
need to be that complicated.

------
tannhaeuser
I don't know, on the one hand, JavaScript is without doubt neccessary for a
lot of useful things on the web. OTOH, I always thought of JavaScript as a way
to get a better declarative web long term, by experimenting with UI paradigms
and trying things that eventually can become part of new declarative HTML UIs.
But that feedback into HTML never happened, and it seems we're stuck with an
incredibly poor language we're enslaving the next generation of both users and
developers in. The worst part is IMHO where we attempt to shoehorn JavaScript
into a "serious" language with ES6+ classes, modules, new syntaxes, type
decorators and what not; all we've achieved with these inessential extensions
is to make future browser implementer's life difficult.

I haven't listened to the audio, but all it takes to get rid of JavaScript-
heavy pages (that only exist because young webdevs are being taught and drool
about mostly JavaScript, React, and other overkill rather than web basics), we
just need to step up the game and demand power-efficient webapps, or no
webapps at all.

~~~
davidjnelson
Experienced engineers use react when it is needed for the enhanced ux.
JavaScript is actually a decent programming language if you use the functional
paradigm and read enough books and ship enough products to understand its
strengths and weaknesses. It’s even better with typescript.

------
marcus_holmes
I'm building a web product.

The static pages are in static HTML, because of course they are.

But the product pages need to be interactive. To do that, I need to use JS,
and an SPA framework (I use Vue) makes that easier and way less effort than
(e.g.) JQuery.

I have one problem, though... the marketing folks want to be able to change
the copy on the static pages, but they don't want to learn HTML. They're
pushing for me to implement the static pages as a Wordpress site, with a list
of pluging that they want, because that's what they're used to.

I don't think JS is the problem here...

~~~
xwdv
It’s fairly trivial to setup a simple text file with all the websites copy so
that when the file is updated a script can automatically fire to rebuild the
static pages and deploy it.

~~~
zbentley
That doesn't answer the marketing folks' concerns in GP. They don't hate HTML
because they prefer markdown or whatever; they want a WYSIWYG/drag-and-drop
site builder because it's what they're used to.

------
mmcnl
I'm tired of discussions concerning "Javascript" and "the web" where
absolutely conclusions appear to be drawn. JS is a language, the web is a
platform. Ofcourse overusage of JS results in annoying bloated websites, but
when you want to build interactive applications that can easily be distributed
to the entire world, the combination of JS + web is a virtue. The web isn't
only for displaying static content, it's time to accept that.

~~~
indalo
Yeah, I've never understood the yearning for effectively plain text html. I
remember recently a submission that had a "brutalist" styleguide.

I wonder how much of this is a reaction to the complex and volatile nature of
frontend patterns, in a psychological sense.

------
pohl
If anybody catches the titular moment, drop the time index here, please.

~~~
donio
around 20:45

~~~
jefflombardjr
Does this mean Svelte 3 is the Tesla of the web? No virtual DOM it's like it
doesn't even use gas. XD

tl;dl around 20:45: They're comparing javascript and the tools you use for it
to transportation modes. Saying things like Angular was the H2, React is the
H3, vanilla javascript is riding a bike. They really are just saying don't
over engineer things and use the right tools for the job.

Douglas Crockford's Javascript the Good Parts, is imo the best when it comes
to getting a feel for what the right/wrong tools are. That book was a
perspective changer for me. People like to get very passionate about
frameworks and how Javascript _should_ be done. JS The Good Parts made me
realize it's better to play the strengths of what's available to you here and
now. To accept the tooling as it is with its pros and cons - exploit the
strengths and minimize the impact of the cons.

~~~
pier25
> _JS The Good Parts made me realize it 's better to play the strengths of
> what's available to you here and now._

So... use what?

~~~
Lowkeyloki
Use your own experiences and your common sense to make good decisions
yourself.

~~~
pier25
Of course I do, I was just wondering what you used.

------
brylie
I'm wanting to enhance a server-rendered template with a bit of JavaScript to
fetch data from the server and update the DOM.

I like that Vue can be "dropped in" to any HTML page, like jQuery, without
completely taking over the frontend development process, but it still weighs
in at 30k. Also, the Vue docs are primarily oriented towards a pre-processing
SPA workflow.

Are there any light-weight libraries like Vue, around 2k-5k, that enhance
static HTML with declarative DOM manipulation reactive data binding?

Is there a "plain JS" approach to declarative DOM manipulation?

~~~
spankalee
lit-html lets you write declarative, reactive templates in plain JS, and is
~3.3k. Check it out here: [https://lit-html.polymer-project.org](https://lit-
html.polymer-project.org)

~~~
rbanffy
That sayHello function declaration burns my eyes.

Why?

~~~
TeMPOraL
Because it's the first time you've seen JS lambdas, the "html`foo`" syntax,
and/or JS string interpolation?

This function looks perfectly 100% normal to me, but that's probably I spent a
whole workweek once almost entirely in ObservableHQ documents, where you'd use
md`...`, html`...`, etc. all the time.

~~~
rbanffy
It's not the first time I see JS lambdas, or lambdas. I'm just not sure why

    
    
        let f = (a, b) => a + b
    

can be considered prettier (or clearer) than

    
    
        let f = function (a, b) { return a + b }
    

or (given the differences in runtime behavior)

    
    
        function f (a, b) { return a + b }
    

It saves typing for trivial functions, sure, but it's yet another syntax for
the same thing.

~~~
thrower123
I've come to like the arrow-function lambda syntax, but that's mostly because
it is exactly what C# uses, and I write vastly more lambdas for LINQ and
higher-order functions on the back-end than I do in JS.

The only downside is you've got to involve babel to transpile it down to the
shitty old browser versions that we need to support, so you go from a simple
reload to a webpack or grunt invocation that takes 30 seconds to a couple
minutes, depending on how invasive the corporate anti-virus is feeling today.

~~~
spankalee
Just don't compile during development. Only compile for testing on and
differential serving to legacy browsers.

------
cryptica
I think that VueJS is a great framework because it's very flexible. I love
being able to build entire apps without a bundler and no build step. I hate
bundling during development. It's so slow.

------
zaro
So Javascript is the problem? Not the trackers, and ads but Javascript which
is simply a programming language. May not be the best, but its not the worst
either.

~~~
0xDEEPFAC
Javascript was a poorly thought out language designed in two weeks. It is a
problem... so much so that features keep getting stacked on it because by now
we are stuck with it.

It is such a mess that it is now mainstream to compile some metajs langauge to
js.

Is it the worst language every created? Certainly not, but is it the worst
language being actively developed and used? Yes. Is it poisoning the minds of
young programmers with bad practices and a fear of concurrency? yes.

~~~
starbugs
The first prototype was designed in 10 days. The language itself underwent
several iterations and I think it's not fair to say that it was "designed in
two weeks".

Other languages (and newer versions of JS) compile to ES5 so they can be run
in JS engines supported by commonly used browsers. Not because JS itself "is
such a mess". This allows one to roll out new language features to developers
without having to wait for browsers to pick up a new standard (or language).
Pretty much every language I am aware of adds new features and changes over
time. Do you call them a mess also, because they make changes?

I think your comment is highly opinionated, not well supported by facts and
sources, and IMO on the edge of being insulting to a lot of people.

~~~
0xDEEPFAC
Fair points, but the fact it has to be compiled negates almost all the
benefits of a scripting language. Not to mention that using these tools is
error prone (see leftpad).

TL;DR JS has become more of a target over time than a source which might be a
hint that there is something deeply wrong with it. People wouldn't reinvent
the wheel if it was round to begin with.

~~~
starbugs
Yeah, it's so much of a problem and so badly designed that the whole web runs
on it every day, enriching the lives of billions of people and providing them
with access to valuable software.

You know, I guess that's why I come to think more and more that I have a real
issue with the attitude of some of the more deeply technical folks: You
completely neglect the success of this ecosystem and what it does for all of
us, because of technical details that apparently do not matter a lot to end
users.

Yes, for technical people having to deal with that ecosystem, it can introduce
new quirks and issues. It's your job to deal with that and create value for
customers.

Do something about it instead of ranting and whining.

~~~
0xDEEPFAC
Being forced to use electron-based apps hardly feels like an enriching
experience (Microsoft removing the legacy QT based app for one without push-
to-talk, Discord, Slack etc.)...

My final comment would be success of proliferation isn't always a result of
quality. I am not saying it doesn't provide value - it is just a very poor
programming language which, being popular, means people who learn
professionally my get stuck in a minefield of dogma instead of focusing on
sound principals.

[https://hackernoon.com/how-it-feels-to-learn-javascript-
in-2...](https://hackernoon.com/how-it-feels-to-learn-javascript-
in-2016-d3a717dd577f)

------
finchisko
I don't get the sentiment about JS. Where all the hate is coming from? Maybe
it's just confusion. People hate SPAs, but talking about web. IMO web and SPA
are two different things. Maybe overuse of JS on web sites is problem, but A
in SPA stands for "application". And applications written in JS are perfectly
legit to me.

~~~
altfredd
What is there not to get? Javascript in browser simply sucks as platform.

1) No memory limits (technically, there is a limit, but it is much bigger
than, say, app heap limit on Android)

2) Background tabs can use setTimeout() to indefinitely run code long after
user left them

3) Websites can start background processes (Service Workers) without user
oversight. Users can't prohibit that or kill them via easily available means.

4) Applications are non-optimized by default, need massive CPU resources for
JIT-compilation

5) Rendering a page with five sentences requires executing tons of said
unoptimized code.

6) No permission system for majority of things. All important user controls
have to come with browser add-ons.

7) Applications can update themselves anytime without user consent

8) Most web apps do not work offline

9) Everything is tied to proprietary web services with overarching
surveillance and dodgy EULAs...

~~~
krapp
Every item in your list describes a problem with the way browsers are
designed, with the way the web works, or with the standard practices and
incentives of web development culture, and all of them would likely still
exist were javascript replaced with any other language.

It's ironic that JS as a language is hated to the point of near derangement on
HN while being the least relevant component of the problems people here have
with the modern web.

------
threatofrain
Relevant discussion titled "Why I'm still using jQuery" (27 May 2019, 237
comments):

[https://news.ycombinator.com/item?id=20021289](https://news.ycombinator.com/item?id=20021289)

------
uxcolumbo
So what's the view on using Gatsby for building content or ecommerce sites?

Better than using other static site generators sprinkled with JS?

I've not done any research yet, so curious to know what the HN community
thinks.

------
neya
I urge you to use a well designed language like Elixir. And work with a well
designed Framework like Phoenix. And then try to use Javascript for once.
You'll see how fragile the language itself is, let alone its eco-system.

No, I'm not a JS hater, In fact I LOVE VueJS and I think you can do a lot of
great things with it. For example, I built a completely offline cart system
without any server backend using just VueJS. But then, between VueJS and
something like LiveView, I find its infinitely easier and faster to develop on
vanilla server-powered CRUD applications than SPA/JS only frontends with
"serverless" backends.

With each year in web development, the complexity only seems to keep
increasing to get something as simple as loading a web page fast or without
refresh.

These days, I've started using LiveView and Turbolinks which basically means I
have absolutely no necessity to touch Javascript at all and I can get
everything done with the same language I write for my backend - Elixir. It's
pretty amazing.

Much love to José and Chris.

~~~
amelius
Languages do not have to be "amazing" to be useful.

Also, being able to use the language directly in the browser is a pretty
useful property.

~~~
neya
It's really not genuine to label a language "useful" if it's the only option
you've got.

~~~
krapp
Yes it is. Utility in a language doesn't only exist relative to other
languages that target the same platform, a language can be useful on its own
merits.

In the case of the web, the utility of javascript comes from being able to
script the DOM and execute code in a browser. If there were other languages
which could also do so (as was the original intent implied by the <script>
tag,) those languages would also be at least as useful as javascript.

------
jaehong
so, http is the methane(ch4) gas on the internet?

~~~
austincheney
Then I guess the DOM is the radon of the internet, because most JS developers
have no idea what it is or what its for and are scared to death to approach it
without 3 layers of abstractions plus safety scissors.

dom - [https://dom.spec.whatwg.org/](https://dom.spec.whatwg.org/)

radon -
[https://en.wikipedia.org/wiki/Radon](https://en.wikipedia.org/wiki/Radon)

