CSS and Markup in Javascript is an Evolutionary Dead End

There is a popular trend among some Javascript developers to argue that humans should stop writing CSS and HTML (and HTML-based templates). They argue everything should instead be written as Javascript, to reduce complexity and present a more unified developer experience.

And certainly many people who try this approach like it. It works well for a certain kind of team. But this approach over-optimizes for the present, and discounts the future. It's going to get leapfrogged by technologies that are already starting to land.

As the web platform matures as an application runtime, it's starting to become a true compilation target.

Q: Sure, almost everybody transpiles something these days, how is this news?

A: There is a critical tipping point that we haven't hit quite yet. A true compilation target is one that you don't need to understand to use.

Today, everyone doing practical work in compile-to-Javscript languages needs to know Javascript too. The tooling simply isn't mature enough and the abstractions leak too much. Even if you write in some other language, you need to think in Javascript to debug anything.

We have seen this all before. There was a time when you couldn't be a professional programmer without knowing C. Your higher-level language was implemented in C, and it would break a lot, and you would need to debug the C layer. Further back, you couldn't be a programmer if you didn't know assembly, because C compilers were too leaky an abstraction, and debuggers were not good enough to debug-while-thinking-in-C, so you had to debug-while-thinking-in-assembly.

But eventually, layers mature and become mostly ignorable. You don't need to know assembly today to be productive in most parts of programming. You don't need to know C. And we are on the cusp of the day when many web programmers won't need to know Javascript.

The reason for this is that both the runtime capabilities (in the form of WebAssembly and ASM.js) and the develop & debug facilities are advancing quickly.

Every time this process has repeated in the past, the old guard who were already experts resisted the change, and denigrated the newcomers who had the gall to call themselves programmers even though they didn't know assembly! But the newcomers win in the end, because there are so many more of them, and the nexus of activity moves up the stack.

It's the nature of software to make last year's cutting-edge problem into next year's moderately-hard problem into something a precocious child can do a few years after that. Realize there are many of us out there working toward the point where a kid in a weekend can reproduce your $X million app by plugging together reusable components. It's not a question of if, but when.

And we're going to succeed because we control all the language semantics and choose how they map into underlying Javscript (or webassembly) semantics. That ability to choose gives us immense leverage over the future.

How does this relate back to whether HTML and CSS belong in Javascript? The bet to make is that we're going to see more use of specialized languages. And HTML and CSS are the grandaddy specialized languages that have enough social consensus and capital investment to be the seeds of the next generation. A project like the Glimmer Virtual Machine is really a new programming language being born, one that has standards-based HTML baked into its DNA.

When we succeed, it will not be because we turned everyone into Javascript ninjas. It will be because we made it radically easier to compose applications. Fully-general programming languages are irreducibly complex. You can only go so far in automatically helping people with them before you summon demons like the halting problem. Specialized languages can put a velvet rope between most users and the deep abyss of computational complexity, and present gradual onramps for users who have the need and desire to begin exploring those nether regions.

If you plant your flag on "it's just Javascript semantics", you don't have that flexibility. You cannot evolve as far or as fast.

The asteroid is coming.

Photo credit: Daniel Mennerich via Visualhunt / CC BY-NC-SA