My goal with this article is to share my perspectives on the web, as well as introduce many aspects of modern HTML/CSS you may not be familiar with. I’m not trying to make you give up JavaScript, I’m just trying to show you everything that’s possible, leaving it up to you to pick what works best for whatever you’re working on.
I think there’s a lot most web developers don’t know about CSS.
And I think JS is often used where better alternatives exist.
So, let me show you what’s out there.
↫ Lyra Rebane
As someone who famously can’t program, the one thing I like about CSS is that I find it quite readable and generally easy to figure out how I can change things like colours, fonts, and so on. Of course, anything more complex will still break my brain, but even the more complex elements are still at least nominally readable, and it’s often quite easy to determine what a piece of CSS does, even if I don’t know how to manipulate it or how to get even close to any desired result. It’s like how the fact I learned Latin and French in high school makes it possible for me to nominally understand a text in Spanish, even if I have never spent a single second studying it.
JavaScript, on the other hand, is just a black box, incomprehensible gibberish I can’t make heads or tails of, which in my mind goes against what the web is supposed to be about. The web is supposed to be an open platform in more ways than one, and the ability to make a website should not be hidden behind complex programming languages or website builder gatekeepers. The fact JavaScript is a resource hog and misused all over the place sure doesn’t help, either.
If you want to know more about the current state of CSS, the linked article by Lyra Rebane is a great place to start. I wish I had the skills to finally give OSNews a full makeover, but alas, I don’t.
CSS are definitions. JS is code gone wild running on clients.
Everyone should run something like NoScript to prevent Javascript from running by default. But yes, almost all websites have gone “lazy” and use a myriad of dependent Javascript, often times from several completely unvetted sources. And there’s zero reason for it.
A long long long time ago, it was “the way” to handle idiots like MSIE that decided to “go their own way”. And while I don’t like the “whole world has to run on Chrome” current mentality, the vast majority for gunk like Javascript has gone away. With that said, websockets everywhere and webassembly is just a “pile push” and will likely lead to a whole slew of bad things moving forward. But doing all that mess, plus Javascript??
Moving the “web server” to a custom foreign downloaded code base executing on your computer (via browser)…. wise?
chriscox,
You are close, but everything has a place in the “stack”
I would even argue JavaScript moving to the backend (Node.JS) has been a greater issue than polluting the client.
Yes, it helped novice “developers” to write backend code. However at best it is only 2x slow of native C++ (or Java) and has wasted billions of compute power in aggregate.
Anyway… The article should probably be titled:
“You no longer need JavaScript for Most Basic Animations and Transitions”
And that would be more agreeable. Back in the day we used to animate everything frame by frame using heavy frameworks like jQuery. Did it work? Yes. Did it require a decent machine for basic things? Also yes.
(I’m also guilty of this. But the alternatives were: Flash, JWS, or Silverlight)
Now CSS has progressed enough to build nice UIs without needing additional code. But that does not mean it covers everything. We still have HTML for page structure, Canvas for native rendering, SVG for scalable objects, WebGL for gaming or other complex graphical needs and of course CSS to style them. But that does not mean we no longer need JavaScript in general.
Model, View, Controller
or
Model View VIewModel
Are the modern UI paradigms, and here HTML/SVG/WebGL would be the “Model”, CSS would be the “View” and JavaScript would be the “Controller” (or the logic in ViewModel.
Yes, you can probably do much more in CSS. I would not be surprised if it had reached “Turing Complete” status. But doing control logic in CSS is akin to writing backend code in Node.JS (wrong tool for the wrong job).
sukru,
I had a node.js project that I would end up regretting for scalability reasons. It turns out node.js is a poor choice for things like multithreading and async for network daemons, even though it can technically do them. But we didn’t get a feeling for these problems until we already had a working prototype that we could benchmark. By that point the company was more interested in using the code already written than rewriting the daemon in a higher performing static language.
I’d say node.js does have some advantages though because you can write business rules in javascript that can be evaluated both client and server side without rewriting them and risking things being out of sync. I like to give users real time feedback, running business rules on the client provides a much better user experience than server side forms. But the caveat is when server and client side code are in separate languages, it limits code reuse between both. For some projects I’ll write a database driven rules engine that can be executed both client and server side. This makes it easier to do things like adding fields, but sometimes business requirements end up necessitating custom code anyway on both the server and client, which highlights the benefit of using one language.
Javascript is a natural choice for obvious reasons, but I suppose you could cobble up something in LUA or similar and link in an interpreter on both the server and client so you can reuse the same code that way. In the 2000’s I was thinking about making a new language that blurred the distinction between client and server. The full application would be written in this language and the “compiler” would emit the code needed by both the client and server. The IPC and security enforcement between these domains would be handled transparently for the developer. I still think it’s a neat idea.
I wonder if WebAssembly has become a mature alternative to JS, where you don’t need JS anymore. Or at the very least significantly reduce it’s usage. A nice write up on this would be great.