Tag Archive for webdev

How I Missed Web Assembly

As pointed out by an intrepid Coder Radio listener, I totally missed the importance of Web Assembly when it was in its initial nascent phases a year or so go. Now that Web Assembly is going to become a standard endorsed by the W3C and has backing from at least two major browser vendors to date (Google and Mozilla), I’ve done a full 180 and am convinced it is the future of not only web development but probably a good deal of mobile and desktop development as well; my assumption is that tools like Ionic and Electron will be able to leverage the performance gains brought by web assembly as well.

Looking back my mistake was that I failed to parse out the signal from the noise in the wider JavaScript conversation circa 2014 and on. There was (and in many communities still is) a lot of angst about the short-comings in the JavaScript language and a lot of people making noise about using alternatives to it that would simply compile to it –  CoffeeScript and TypeScript for example. There was of course a thread in the background about Web Assembly becoming potentially a language agnostic solution to this problem, but because I was looking at it through the lens of alternative languages to JavaScript and at the time didn’t think and I still don’t think  that changing from JavaScript just because you want a different language but then compiling into JavaScript makes any sense at all. In other words, I took a breathe and shouted a hearty “get off my lawn!”

My curmudgeon-like tendencies aside, I still firmly standby the idea that just writing in something like CoffeeScript to compile into JavaScript just because you don’t some features or shortcomings of JavaScript is silly. What I missed was that this whole language brouhaha was just a minor prologue to the real story — Web Assembly. Moving to Web Assembly not only increases web application performance significantly but also (as more languages create compilers for it) gives those developers who prefer some language over JavaScript a much more reasonable choice; they can simply use the language of their choice and compile it directly to Web Assembly! I’m totally on-board with that. In fact, I’ve been working in Microsoft’s TypeScript and find it great, so if we actually make it (we probably will) to this Web Assembly world, then I’ll probably go Typ eScript for most greenfield projects going forward.

As in Eden, there’s a potential snake in our garden — Apple. Web Assembly being fully supported on mobile Safari for iOS is absolutely necessary to unleash the full potential and development efficiencies that I believe Web Assembly can over the next five year period bring.

Questions? Comments? Blood curdling nerd rage? Tweet me! Also, take advantage of my free strategy session for your next project!

JavaScript is Not Assembly!

There is a growing idea on the web that JavaScript is somehow the assembly language of web. This is a horrible analogy for a number of reasons: it shows a misunderstanding of what assembly language is, implies that JavaScript is not a human readable language, and it  suggests that JavaScript is a far lower level language than it is.

According to Wikipedia, “An assembly language is a low-level programming language for computers, microprocessors,microcontrollers, and other programmable devices in which each statement corresponds to a single machine language instruction.” That doesn’t sound like JavaScript to me. Let’s keep reading and see what else Wikipedia has to say about assembly: “ An assembly language is specific to a certain computer architecture, in contrast to most high-level programming languages, which may be more portable.” Therefore for JavaScript to be considered an assembly language wouldn’t it have to target a specific computer architecture (such as i386 or ARM). Taking this to its logical conclusion, that would mean that for the JS == assembly relationship to work, you would also have to think of different browsers and JavaScript runtimes as different architectures. If that sounds crazy to you, that’s because it is. The analogy is broken just based on the definitions and essence of what assembly and JavaScript are respectively.

JavaScript gets messy. There is no doubt about it. Due to years of abuse by sloppy “devs” (who probably were more closely related to what today would be called an “Interactive Designer”) who didn’t treat it as a proper programming language but rather a little hack to get some fancy animation on a web-page. What does that have to do with assembly? Well, assembly is known to be very hard for humans to read; yes, I am fully aware that there are a number of hardcore individuals who can read and write assembly, but on the whole they are the exception not the rule. Guess what! JavaScript isn’t inherently hard to read. All this complaining about it being a tangled mess of crap is not the fault of the language but the fault of the dev and trying to force some analogous relationship with assembly onto it does not give you some sort of excuse for writing unmaintainable and hacky code.

Did I mention that assembly is low level  “down to the metal” sort of language? Guess what JavaScript isn’t? Ding ding! Well, done! JavaScript is not low level. While your C++ code is compiled to assembly and ran on your iPhone’s lovely ARM processor, your JavaScript is run in a JavaScript engine such as V8 in your web browser. Looks like JavaScript is running at something of a higher level.

My purpose here is not to beat up on the JavaScript detractors. The language (like all languages) could use some work, but adding an unneeded layer of abstraction over it is not going to bring the change the language needs. Standards bodies are slow, but you can “be the change you want to see” (Gandhi). Instead of abandoning it for some questionable layer of abstraction, use the great features in JavaScript, ignore the bad, and write maintainable code. If we all did this we’d find that over time the web would be a better place to work and JavaScript would be a better language to work in.  Not sure what the good parts are? Check out JavaScript the Good Parts. Got some feedback for me? Find me on Twitter or Google+. Also, check out my show Coder Radio on Jupiter Broadcasting. It is a weekly show on the art and business of software development.