Are we assembler programmers?
Development | Vlatko Drempetic

Are we assembler programmers?

Monday, Oct 29, 2018 • 3 min read
A personal opinion on the current and future state of JavaScript and its use.

Assemblers are traditionally considered difficult as well as the ultimate geek toys, but the rapid development of JavaScript engines and popularity of the web just might give us a chance to experience one.

When I was a kid, I started gaining my first programming skills on mighty C64. All the cool games and stuff back then were done in assembler, and it was kind of a programming language for superheroes. I always wanted to get a grasp of that superhero power and learn it, but I was still very young and it was hard to find tutorials (remember pre-internet era? Yes, I am not young anymore).

Soon after, the PC became popular and I was finally able to reveal the secrets of magic x86 instruction set, or in simple words, PC assembler. I had to learn memory segmentation, how to effectively use stack, CPU architecture details (pipeline, cache, FPU), and a lot of low-level technical details in order to write efficient assembler code. It was cool and fun, but I realized writing and maintaining assembler code was hard and time-consuming, not to mention its extremely low portability.

Despite the fun, I leveled up to more productive languages like C, Java, and C#.

Who wants to write in JavaScript?

As I became a full-time developer I mostly worked on web applications, so it was inevitable to get in touch with JavaScript - and I hated its guts. I couldn’t stand writing anything in it, and it was a pain just to think about it. I thought this language was someone’s idea of a joke. By the way, did I mention how I love and absolutely adore JavaScript? Well, not really what JavaScript is today, but its core ideas. Once you get to know it, you’ll fall in love with it, too. I love its lack of ceremony and the ease of writing and running the code. It’s just fun to use.

By now you’re probably wondering what does JavaScript, a high-level dynamic language, and assemblers, low-level, close-to-metal languages, have in common (except I obviously love them both). Well, a few years ago they had absolutely nothing in common, and today, almost all other languages can be compiled into one of them.

In case you’re a C# master, you have Script#; if you’re Java kind of guy, try jsweet. Need something for Python? Check out Transcript.

If you prefer more modern languages like Go, F#, or Haskell - you’re covered. You can even do it in C++ using jspp, not to mention languages whose primary target is JavaScript, like CoffeeScript and TypeScript. You can also try Dart, a language Google hopes will succeed JavaScript, but at the moment you’ll compile it to JavaScript most of the time.

I probably missed a bunch of them, and many of the languages mentioned above have more than one compiler. Even trying to write JavaScript can be awkward nowadays - check out this great rant.

Seems like all the world is trying to write JavaScript, just not in JavaScript. It’s like bytecode for the web - whenever you’re doing something in vanilla JavaScript, you’re doing assembly. Today JS is everywhere, and it’s funny to see a language originally designed as a simple script language for writing small and simple code to become major development tool and base for running almost anything on the web. It’s even taking a foothold in areas dominated by more “serious” languages like desktop and server-side applications.

What’s next, JavaScript on hardware?

Today, JavaScript is quite different from its humble beginnings. Toolings and editors are more sophisticated and proven in practice (at first you didn’t even have a debugger), language has improved a lot, as well as vital parts like module system (whether it’s good or not), arrow functions, async/await, etc., and it will continue to improve on a yearly base. JavaScript virtual machines are catching up with the latest standards, and all the big players are working together to bring unified API and experience on all platforms. It’s much more mature and it’s shifting from being a simple script language used to write a small patch of code to a full-fledged programming platform. JavaScript today is much more serious, but still with all the good parts inherited from its beginnings. For that reason today it’s less fun to write JavaScript (Javascript fatigue fatigue).

Many people see WebAssembly as the savior, something that will free us from the evil JavaScript so we can finally write apps in proper languages. I personally don’t see it like that, they both have very different missions; one is designed for ahead-of-time compiling and performance, while other for productivity and code simplicity. I hope WebAssembly will replace JavaScript as web bytecode. It’s silly to write JavaScript code in C#, and it would be nice if you could write C# (or any other similar language) code that runs in the browser. WebAssembly is still in its beginnings and is lacking some key features (source mapping being the most important one) to take the web assembly throne. It will most likely stay this way over the next few years, so we’ll be stuck with JavaScript as bytecode for some time - and enjoy writing assembly. :)