21 ms·
It is hard to avoid JavaScript
- deleted 3y ago[deleted]
- robin_reala 3y agoI take issue with “CSS is tricky”. We’ve never had it easier with CSS in terms of browser compatibility, documentation and functionality.
- solardev 3y agoIMO CSS is fundamentally tricky because HTML isn't WYSIWYG by default. In similar document styling systems like in Word or Illustrator, you can graphically alter your parameters and get immediate feedback. In CSS it's often tweaking ambiguous parameters (align vs justify) across several layers (self, items) just to try to position something in a way that would take half a second if it were a good GUI. I've been working with CSS since its invention, I get by OK, I can use it a hundred different ways, but I would never consider it straightforward. It's powerful, it's evolving, it's useful, but simple it is not.
- moritzwarhier 3y agoThis is mandated by responsive design. WYSIWYG is terrible for the web not because of the languages used. It just does not make sense. And responsive design not only means mobile, it means all screen sizes and includes other factors. Flexbox is a good example for this.
- tracerbulletx 3y agoForget responsive design and WYSIWYG... VSCode, Figma, Discord, Slack.. etc.. etc.. can be implemented with html and css and it's a better experience than any other GUI framework for any other platform.
- solardev 3y agoWhy do you believe that (it's a better experience)? Are you talking about for the developer or the user?
- wiseowise 3y agoBoth. As a developer you can tap into endless pit of resources for web development. As a user, you can access same program on all platforms without any changes and continue where you left off, what’s not to like?
- bee_rider 3y agoI would rather know straight-out that a company doesn’t have real native support.
- moritzwarhier 3y agoI have used many native GUIs on Windows that looked blurry because they din't get font rendering right and that only work at a fixed window size. Both in enterprise and consumer software. Yes, they probably weren't holding it right, were written in Java and/or sth else. But I don't understand where the sentiment that native=better comes from. I like native applications too, when done well. For example, I still like IntelliJ IIRC, this does use Java for GUI? Also it doesn't use native controls.
- wiseowise 3y ago> But I don't understand where the sentiment that native=better comes from. OCD.
- bee_rider 3y ago> But I don't understand where the sentiment that native=better comes from. Some of it is integration, the UI just looks nicer for native apps and the graphical language is the same as the rest of the system. Some of it is performance, these non-native toolkits always seem to bring along too much junk. Some of it is vibes, if an organization is willing to invest in a native app, it seems like they are probably more interested in sticking around.
- xandrius 3y agoThis is because of what we have today, it's not how it needs to be. I wouldn't mind a GUI where I put constraints to the elements visually and then check the different ratios/sizes I want to support and bam, done. As a field we're under a general assumption that it makes sense to do visual work textually. Just because WYSIWYG tended to be overly verbose and used by "noobs" that it's not how it should be. Imagine most people making music by just writing notes and then only playing it back afterwards.
- dexwiz 3y agoDesign tools often have controls on how you can scale a box by locking expansion in different directions and anchoring elements to specific side. Its results in the same thing as flexbox and alignment but is was more intuitive. The real issue with CSS is the eternal question of, do I fill my parent or expand to fit children? You have to trace multiple levels and rules, and even then it might be a guessing game. This is because the rules that govern this can change at each level, and that changes how you answer the question. I have been using CSS for 20 years. It’s too difficult for what it primarily does.
- emllnd 3y ago> The real issue with CSS is the eternal question of, do I fill my parent or expand to fit children? This is one of the real issues of GUI tools in general, not just CSS. You run into the same complexity on e.g. UIKit/SwiftUI (Apple) or any other toolkit that tackles the full complexity of defining UI layouts for any screen simultaneously. Agree that CSS has a bit of extra cruft due to it’s evolution which makes it more difficult to learn and slower to work in than it perhaps could be if the web standards process allowed pruning features more easily
- leptons 3y ago>I have been using CSS for 20 years. It’s too difficult for what it primarily does. I've been using CSS since the day it first appeared in IE3 in 1996. "Too difficult" is not at all how I would describe it. Considering how many kinds of layouts need to be created, CSS has performed really well for the task it was designed to do. New features are added every year. It keeps getting easier. The difficulty is in trying to support every kind of device layout, which wouldn't really be any easier in any other layout language.
- solardev 3y agoI think it's easier for us because we've kept up with small incremental changes over 20 years. To someone just jumping in fresh from school or boot camp or whatever, it's quite overwhelming. We've had the benefit of having mastered the simple basics back when they still were simple, and then gradually increasing complexity on an as-needed basis, every few years at a time. It's different when you're just thrust into it new, with decades of built-up cruft. There is nothing magical about CSS that makes it uniquely suited for responsive layouts, especially compared to print layout software (Illustrator or Word or InDesign have had to deal with many container and page sizes and be able to reflow text between and around them for decades) or other GUIs (like Winforms or the ill-fated WPF, or today's mobile platforms, all of which have responsive layouts) or bespoke UIs like game UIs that have had to support different monitor and window sizes since the Everquest and WoW days and before. Hacking together a bunch of pixel measurements and percentage calculations and virtual pixels to do responsive layout is just so... unnecessary. Even with Bootstrap or Tailwind, when a lot of it is abstracted away with helper classes, it's still often much slower than defining the same layout in GUI tools with a few simple clicks and drags. Having to try to guesstimate a resulting layout from code is a poor way to lay out visual designs, which is why full-time designers usually use Figma or a similar tool, not just tinker with CSS until it looks almost right. I don't hate (or even dislike) CSS; it's a powerful tool uniquely suited for the job it was intended for (wrangling HTML "documents" into complex app UIs), but I do wish we had an entirely different workflow that was custom-built to be UI-first and not a paint layer over a hacky XML document... CSS itself has to compete with HTML layout rules, different levels of specificity and overrides, etc. It's a lot of unnecessary complexity that only exists because of history and backward compatibility, not because it was the best design choice overall.
- solardev 3y agoThe two aren't mutually exclusive (responsive design and GUIs). Winforms was responsive long before HTML. Dreamweaver was OK at responsive layout shifts in real time. Figma handles it OK too. Even the browser inspector with hot module reload can do the job. But not having easy drag and drop at the component level, and having instead to cut and paste chunks of code, makes it slower and more error prone in my experience.
- moritzwarhier 3y agoFair point. There surely is a space for new tools of this kind. All that is needed to build such a tool is available. I think you are talking about a developer-focused tool you mentioned WinForms. The largest issue building something like this is probably what the input (widgets/components) and output formats (a layout description to be consumed by some framework like react? or pure HTML/CSS?) should be. It needs to be integrated with the code, and we're leaving pure HTML/CSS territory here for purely technical reasons. The web still has no proper native component abstraction. Outputting pure HTML/CSS wouldn't be very useful to me, but might still be cool to visually design layouts, and be useful in some cases.
- mewpmewp2 3y agoIt has got a lot better now with flex and other new functionality, but before it was definitely very tricky.
- richrichie 3y agoIt is actually amazing how much can be done with vanilla JS without fancy frameworks.
- dylan604 3y agoWhy is that amazing to you? Frameworks are just vanilla JS wrapped up in specific functions to that framework that do a lot of abstraction level work for you.
- mp05 3y agoPerhaps it's strange to the uninitiated that so many seemingly useless/redundant abstractions exist around something that seems pretty capable of doing the job without a bunch of handwaving. If you never worked with the DOM in 2012 and had a need to support every browser out there, you'd not understand the pain that was involved.
- dylan604 3y agoThe one thing that I thought was a pro for frameworks were all of the compatibility tricks they abstracted away. It allows for your code to be cleaner by not having to constantly use if branches testing the user's browser. It meant that the frameworks update kept up with any new quirks freeing me from constantly researching them and updating my code. My code can stay the same, and my project stays up to date with those quirks by updating the framework.
- reactordev 3y agoIt only seems capable due to those frameworks and abstractions. At the end of the day, there are only so many builtin types and functions on the core runtime. Everything else is up to the ecosystem to provide. Just like C or C++, at it's core, it's just a basic language for things. It's the libraries of code from others that give it [more] powers.
- mp05 3y ago> It only seems capable due to those frameworks and abstractions. Are talking about Javascript or the DOM? I write a lot of NodeJS and since somewhere around v8 or 9 it became pretty nice to use.
- benstigsen 3y agoIt definitely depends on the technology, but for a lot of sites JavaScript simply isn't necessary. A lot of what could be static sites use JavaScript. CSS may be tricky to some (I'm still lost with flexbox), but what I've found particularly helpful is using some already finished CSS stylesheets, then just modify them to my needs. Like PicoCSS, MVP.css and more. Like the post says: Sometimes, people get angry at React or other FrontEnd frameworks just because they look scary or too complex. But the reality is, FrontEnd is complex. I have been avoiding React and similar frameworks with a belief that they introduce complexity, but also that they make the site perform slower, produces less traffic either due to hardware restrictions or download speeds. These are valid concerns to consider. Vanilla JavaScript and so on is already pretty simple, I wouldn't be too opposed to the use of jQuery as it can make some things simpler. But in the same way a few of us avoid front-end frameworks like the plague, a lot of front-end developers choose frameworks due to a lack of familiarity with standard / vanilla technologies. I think what's even more interesting to note is the support for modals with regular HTML and other such features, so that one can depend less and less on JavaScript. (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog https://developer.mozilla.org/en-US/docs/Web/HTML/Element/di...) Did like the write-up on HTMJS though.
- kid64 3y ago> I think what's even more interesting to note is the support for modals with regular HTML and other such features, so that one can depend less and less on JavaScript. (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog https://developer.mozilla.org/en-US/docs/Web/HTML/Element/di...) From that link: "JavaScript should be used to display the <dialog> element."
- benstigsen 3y agoAh that is true. It does make us depend less on JavaScript, although not to the degree I thought when linking to it. Thank you for correcting me.
- pton_xd 3y agoFor all its quirks, JavaScript is an incredibly concise and easy-to-write multi-paradigm language. For banging out prototype code, it's my favorite tool no matter the domain.
- dan-robertson 3y agoHmm, I think the real advantage is more that you get an advanced cross-platform environment to run it in “for free” – excellent debugger, various ways to do UI, graphics, getting input from the user, etc. For lots of recommended ‘beginner’ languages, this isn’t the case.
- egnehots 3y agofor devops, datascience and ml stuff Python is a good contender
- wiseowise 3y agoPython + JS is a killer combo for exploratory work.
- jauntywundrkind 3y agoLong time huge fan of JS. I appreciate your calling out the multi-paradigm aspect; having these first class functions & prototype based inheritance has been so flexible. TC39 has done a great job shaping the language over the years. New capabilities are usually well thought out & integrate well. Async await has been amazing. The one major miss that makes me so sad and frustrated is modules; js has gotten better everywhere except it's near requirement for build tooling. Being able to throw some scripts on a page and go is still an unparalleled experience in the world, is so direct & tactile an experience. EcmaScript Modules was supposed to improve things, help get us back, but imports using url specifiers made the whole thing non-modular, was a miss. We're still tangled & torn. Import-maps has finally fixed but it's no where near as straightforward, and it still doesn't work in workers, which leaves us infuriatingly shirt of where the past was. https://github.com/WICG/import-maps/issues/2 https://github.com/WICG/import-maps/issues/2
- gjsman-1000 3y agoI don’t know - the author seems fairly aggressive in his belief that one shouldn’t question JavaScript. Seems hypocritical.
- jokethrowaway 3y agoElm is the closest we got to usable no-js in my opinion, too bad the excessive centralisation by the benevolent dictator wrecked it I'm betting on a Rust framework (leptos is pretty nice!) being the next shot at the problem, but nothing with wasm as bundle size actually matters.
- gjsman-1000 3y agoAs much as we all use HTML, CSS, and JavaScript; it isn’t 2003 anymore. Most web browsers people use are relatively up to date and automatically updating. This also means… we aren’t necessarily stuck forever with HTML, CSS, and JavaScript. We could make a new scripting language. We could make a new markup language - or, better, explore different paradigms that might be more suitable. Maybe there’s a better way than having a DOM in the first place. We’ll never have that discussion though if people are forever convinced of JavaScript being the pinnacle. I say this as a person who is more willing to question whether ridiculous levels of abstractions means the underlying technology perhaps needs changes.
- wiseowise 3y agoAfter working with new age frameworks (SwiftUI, Compose, Flutter), I’m rediscovering web development (last time I’ve touched it was more than 10 years ago). I can’t believe how far modern web jumped. Development process, modern ES features, reliable CSS, amount of learning resources. I will never understand why would you sacrifice all of this for something like Compose/Flutter, with their janky web performance, clunky, baroque toolchains and nonexistent (compared to pool of JS developers) mindshare. To start with Compose you need to: Install Java Install Intellij Somehow generate working project Wrestle for half a day with Gradle Search for ever changing APIs or updates Find a way to reference html and CSS Somehow connect all of this together and finally launch in the browser After that - good luck debugging black box generated by Kotlin compiler And now compare this to JS/CSS/HTML: Most likely you already have modern enough browser Create file wherever python3 -m http.server Done.
- leptons 3y agoNobody said "Javascript is the pinacle". But it is extremely difficult to create standards that multiple companies can agree on and want to spend huge efforts to implement and continue to refine for 30+ years. Microsoft tried to make VBScript happen, but nobody else making browsers would ever support it, so it died. And I'm glad it did, because it let everyone focus on Javascript and improving it, hardening it as an attack vector, and creating a huge variety of tooling for every kind of project. Web browsers that don't use HTML, JS, and CSS simply wouldn't be web browsers, that would be something else entirely. And anyone is free to try to make that application using any tech they want, but it won't be widely adopted or supported the way HTML, JS and CSS are.
- leptons 3y agoI love JavaScript, but that HTMJS page has to be a joke. Putting that much JavaScript inside an inline onclick event attribute is pretty ridiculous. It's like a blog for how not to use JavaScript.
- simonklitj 3y agoIt seems you are right. The blog post reads “I've created HTMJS as a *sarcastic* way to express my thoughts.”
- simonw 3y agoSerious question: why is inline JavaScript like that a bad idea? It's easy to find the code that does something, easy to understand what it does and easy to modify it to do something else. Sure, I wouldn't want to maintain an app with thousands of lines of HTML and JavaScript that works like that, but for a single simple feature on a page that isn't doing anything else I don't see the problem.
- leptons 3y agoIf it is actually a simple bit of inline code, then sure. I mean not more than 2 commands maximum. Any more than that should be inside a <script> tag where it's far easier to write and format the code, debug, abstract, and reason about. The huge amount of code in the example on the HTMJS "blog" is just the worst way to write js code into a webpage because it is not a simple function, it's difficult to read, it won't have syntax highlighting because it's treated as a string.
- alexkutas 3y agoIt's properly highlighted in my IDE, which was actually a surprise.
- bee_rider 3y ago> You can have JS in the way you want, just don't be too aggressive towards other people's choices. I think there is never really an excuse to be “too aggressive,” the most strenuous opinions can be expressed without threats of violence or slurs for example. However, people who develop websites that require JavaScript are contributing to this absolutely terrible ecosystem where people just download programs from the internet as a side effect of browsing and run them without even knowing it. That’s wildly insecure as a ground state. To try to push things out of that wildly insecure ground state, the convention has been to create these very advanced sandboxes. Putting aside the fact that they fail fairly somewhat regularly, only three companies have had success in this endless battle. Apple and Google, by dint of having infinite money to throw at it, and somehow Mozilla using magic. As a result of the fact that making a web browser now requires constant security fixes, no small organic community projects can create a web browser. We’re living in the failure-state of the idea that the web should be this open standards-based platform. So, yes. I get that people have to write JavaScript to put food on the table. But it is a choice that has been made at the expense of the rest of us.
- gjsman-1000 3y agoWelcome to Hacker News. Where merely questioning the modern state of JavaScript is a heresy.
- noahtallen 3y agoThe comment is questioning whether the interactive internet, where webpages can be computer programs instead of just documents, is a good idea. That’s a pretty broad claim! Complaining about modern JS is a different story, and it’s a pretty popular discussion point on HN :)
- leptons 3y ago>"download programs from the internet as a side effect of browsing and run them without even knowing it. That’s wildly insecure as a ground state." This is why that comment is getting downvotes. Javascript running in a web browser is probably one of the least insecure ways to run code that exists. It's been developed for almost 30 years to be secure, an attacker can't just do whatever they want on a system, there are many safeguards, and many smart people concerned with keeping JavaScript safe to run in a web browser. It isn't the same Javascript that it was 20 years ago so the "insecure" argument sounds like you really haven't kept up with the evolution of JS and web browsers.
- simonw 3y ago> I see a lot of folks trying to avoid that simply because it's not considered a proper language. If you still think JavaScript is not "a proper language" today in 2024 you're giving off serious junior engineer energy.
- gjsman-1000 3y agoOr maybe the junior engineers grew up with JavaScript, loved it, and have been driving the actual seniors who grew up with strict typing and predictable behavior insane. I would not be surprised if JavaScript gets the reputation of 2012 PHP in a decade.
- simonw 3y agoPeople were refusing to take JavaScript seriously twenty years ago! Here's something I wrote about that back in 2005: https://www.sitepoint.com/2005-the-year-of-the-dom/ https://www.sitepoint.com/2005-the-year-of-the-dom/
- wiseowise 3y ago> Or maybe the junior engineers grew up with JavaScript, loved it, and have been driving the actual seniors who grew up with strict typing and predictable behavior insane. What the hell are you even talking about? > I would not be surprised if JavaScript gets the reputation of 2012 PHP in a decade. What year are you from? JavaScript already passed that stage with ES6.
- jokethrowaway 3y agoI feel 2012 PHP is the perfect description for JS reputation today and I've been working in companies where they do node.js as main backend tech since 2011 and react since 2015. I think it's the result of a mix of clunky tooling (started with transpiling), OSS maintainers who stopped caring and left a broken mess everywhere and lack of static typing (+ dissatisfaction with TS, despite it being the only sensible option for types), the diffusion of JS in uncool corporate workplaces. I still think both PHP (which I've used extensively between 2006-2011) and JS are fine languages with a few defects.
- jokoon 3y agoI made some picture/text/video gallery explorer application with python/flask/js all the HTML is generated with python and transferred with ajax calls. it's inefficient, but it works well and it's easy to maintain. there is as little js as possible I pulled my hair figuring out those pesky async js things, but I'm happy, it works well. I would gladly use Typescript if I could use it without nodejs, I guess there might be a typescript compiler for python? Anyways I am glad I was able to take advantage of js while writing as little of it as possible, it feels like a big achievement.
- johnisgood 3y agoI look at all those Tor-compatible websites that have achieved so much without JavaScript, including CAPTCHAs, etc.
- reactordev 3y ago`parseInt(c.innerHTML)` and we're hacked... :D seriously though, I know HTMJS is tongue in cheek but don't ever do this if you are a JS dev. innerHTML isn't safe, sanitized, or what you expect it to contain. To the author, thanks for the laugh.
- giancarlostoro 3y agoI have had a love hate like most. I have come to peace with it mostly because I know its quirky, and I think once you reach this point you can really do a lot. Reading Mozillas documentation is a huge help though.
- ralmidani 3y agoI’ve settled on htmx not because I’m anti-JS, but to avoid Node/NPM, build steps, duplication of logic, etc. For me, it’s the ecosystem that’s problematic, not the language itself. Also, “just learn JS” is a lazy and off-the-mark response to complaints about having to use JS. Do I prefer Python? Yes. However, I’ve pretty extensively learned and used JS, and I teach a full-stack JS bootcamp. I still think insisting that everyone has to write lots of JS __just_because__ it’s the language that got integrated into browsers is a bit tyrannical.
- wiseowise 3y agoYou can use JS to write application that can be used across all major platforms without any changes. On top of that, a lot of modern languages can compile to JS or WASM. You call that tyrannical?
- leptons 3y agoDo you remember when the most widely used web browser supported 2 programming languages? Javascript and VBScript. It didn't work out so well, and everyone making browsers agreed it was better to focus on one language so the browser didn't become an even larger attack surface. Javascript has become highly optimized and very hardened against attacks, and has improved significantly over the years, and if you __must__ use another language, then WASM is there for your needs.
- bilalq 3y agoJS is the only language that has really fulfilled the dream of being able to run anywhere. Web, desktop, servers, CLI tools, mobile, microcontrollers, you name it. I've written JS/TS that has run across so many different runtimes over the years, and it has endured. Dozens of browsers, NodeJS, iojs, Deno, Johnny Five, Rhino, Nashorn, LLRT, React Native (JS Core & Hermes), Electron, and more.