11 ms·
JavaScript Is the CO2 of the Web [audio]
- deleted 7y ago[deleted]
- pohl 7y agoIf anybody catches the titular moment, drop the time index here, please.
- donio 7y agoaround 20:45
- jefflombardjr 7y agoDoes 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 7y ago> 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 7y agoUse your own experiences and your common sense to make good decisions yourself.
- pier25 7y agoOf course I do, I was just wondering what you used.
- deleted 7y ago[deleted]
- pier25 7y agoHe 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.
- nop3 7y agoJavaScript should be used like a condiment instead of a whole meal. It's led to the bastardization of the web in my opinion.
- pan69 7y agoLike, all we have for dinner is tomato ketchup.
- steve_adams_86 7y agoI'm with you. It occurred to me that what I love about things like react or vue has nothing to do with SPA capabilities. It's just developer ease in building reusable, composable, testable components. I've had similar experiences with scaling too early into microservices for example. I need a seriously compelling reason to consider building around these paradigms now. The overhead is unreal. Both great ways to solve a problem, but not really a problem I've yet encountered - ever. I'm still glad I've had great opportunities to learn this, at least.
- pjmlp 7y agoThing is, building reusable components was always a feature of SSR Web frameworks since early 2000's, so there is no need for react or vue for bundle the HTML/CSS/JS that makes a fancy calendar widget. And with WebComponents being supported across the board, even less so.
- TomMarius 7y agoWeb components are useless, you can't pass values around without converting them to string or employing a non-native mechanism, and of course you need to do all DOM updating by hand - which is both way worse than just using React from various perspectives.
- jaehong 7y agoso, http is the methane(ch4) gas on the internet?
- austincheney 7y agoThen 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
- TeMPOraL 7y agoArguably, JS should be methane, and HTML should be CO₂ - the gas that's an important building block of life, and to which methane eventually breaks down (after doing its thermal damage to the planet, of course). (Then, web developers would be cows, and web fashion/standards would be food for said cows; unlike in real life, here we transitioned from algae-based food to whatever farmers shove into livestock today, making the cows start burping large amounts of methane in the process. NPM would be an open-air landfill.)
- threatofrain 7y agoRelevant 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
- brylie 7y agoI'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?
- brylie 7y agoCorrection, Vue minified and gzipped seems to be around 20k, so might still be my best bet for sprinkling declarative DOM manipulation into the static HTML. Is there perhaps a library in the 2k-5k range, or somehow a way to use only specific parts of Vue (like a custom build)?
- goatslacker 7y agoI’ve been enjoying the simplicity of keeping it plain using lit-html. It lets you write declarative markup and they’re template literals.
- brylie 7y agoThanks for the suggestion :-)
- scarface74 7y agoI’ve used HandlebarsJS for the same thing. I can’t imagine you can get much simpler.
- uxcolumbo 7y agoSo 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.
- finchisko 7y agoI 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.
- goatlover 7y agoOne complaint is developers defaulting to using SPAs for building traditional websites which aren't apps, recreating the functionality that modern browsers are already good at, and there's plenty of good backend frameworks that have been around for while, where content can be loaded quickly, so a full page load isn't a big deal as long as it doesn't have a bunch of JS it has to wait on.
- altfredd 7y agoWhat 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...
- Khanhanhan 7y agoShouldn't you just write that "browsers suck as a platform for running JavaScript"?
- marcus_holmes 7y agotake literally any language, and there's a laundry-list of complaints about it. there was a whole thread here a few weeks ago hating on SQL (a battle-tested veteran of ~50 years) and giving a laundry-list of "things that are broken in SQL" there are routine threads discussing the manifest flaws of Go, and why everyone should switch to Rust/Elixir/Nim/whatever the newest flavour is. no language is perfect (not even LISP), every language is a bit broken in some ways. JS is a great language for its role. It allows newbie coders to write some godawful web code that works!!!1!1!! while they're learning (without having to understand a lot of CS), and veteran coders to write some really elegant code if they want. Learning to use JS powerfully has been a great education in coding for me. I'm still not using it as well as I could be using it, and I like that it has depths still to discover.
- tjpnz 7y agoI'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 7y agoOut 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 7y agoBetter 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.
- TeMPOraL 7y agoGood to know. For small personal things that need JS, I too tend to just go for jQuery, or increasingly stick to vanilla JS. React is ridiculously overcomplicated for small projects[0] IMO. I always thought that Vue is just a React competitor/copycat, so never bothered to investigate it. Since you say it offers more lightweight vDOM with no JS NPM tooling bullcrap, I'll look into it, so thanks! -- [0] - I used React a bit, and I can only stomach it when working with ClojureScript, which gives some sanity to the syntax and language - but that's another pretty large and very complex dependency to be included in the pipeline!
- pier25 7y ago
- tannhaeuser 7y agoI 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 7y agoExperienced 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.
- zaro 7y agoSo 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.
- boomlinde 7y agoSo the rats and lice are the problem? Not the plague?
- 0xDEEPFAC 7y agoJavascript 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 7y agoThe 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 7y agoFair 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.
- cryptica 7y agoI 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.
- neya 7y agoI 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 7y agoLanguages 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 7y agoIt's really not genuine to label a language "useful" if it's the only option you've got.
- krapp 7y agoYes 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.
- deleted 7y ago[deleted]
- marcus_holmes 7y agoI'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 7y agoIt’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 7y agoThat 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.
- pier25 7y agoVue is not an SPA framework. Vue only makes components with data binding and reactivity. Vue Router, a plugin, adds the SPA functionality.
- marcus_holmes 7y agogood point. I haven't quite gone that far, but it's on the trello board for consideration ;)
- mmcnl 7y agoI'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.
- tjoff 7y agoI'm all for dynamic content, as soon as anyone can find a decent use-case for it.
- indalo 7y agoYeah, 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.