Typescript missed a trick

IntelliJ IDE with typical tools already available!

Looking into Typescript as part of a drive to upskill for web development, I can’t help sensing a missed opportunity. I won’t quibble with the need for a strongly-typed alternative to Javascript that can be translated into a browser-readable format. That was certainly long overdue.

Maybe it’s the evil smell emanating from the keyword “let”. This is the disgusting spoor of the organisation that gave us Visual Basic, keeping alive for decades after its natural life one of the worst “educational” languages. Its presence doesn’t fill me with enthusiasm about the new language.

The thing is, though, there are already a plethora of frameworks for web development. There are Spring, Django, Node.js, several front-end frameworks including Angular, React, Vue and probably one more for each web developer on Earth at this rate. And they all do variations on the same things — rendering the front-end and mapping HTTP calls to functions at the back end. YAML stands for “yet another markup language”, in a fitting piece of self-knowledge. It can only be a matter of time before Yet Another Web Framework acquires a catchy acronym.

Having been in the software game since the mid-80s, I’ve seen a lot of languages come and go, and a few persist and grow. By-and-large, successful languages have been based on C syntax, with Python as a salient exception. The best tools out there are language-agnostic, by which I mean that you can connect the IDE and other GUI tools to compilers and debuggers of your choice. Eclipse and IntelliJ are good examples of these, as they let you build and debug in many languages using the same IDE. Maven, Jenkins and so on cover different parts of the software experience in a similarly flexible way.

Where I think Typescript missed a trick is that it’s Yet Another Web Framework. It’s added yet another, rather clunky, syntax to the world and made developers slightly more tribal in the process. For me personally, there’s yet another slightly different language that employers think I need years of experience to migrate to, when in fact it’s just another slight variation on C , Javascript and Java.

What needs to be done — and I’m talking to YOU, fellow developer with time on your hands — is to adapt an existing language to do what Typescript does. Think about it in terms of Java. Java runs on a virtual machine. It’s not the only virtual machine. There’s Rails, on which Ruby can run, and .NET, on which unspeakable things run. Nor is it the only language which runs on the Java JRE; there are Kotlin, Scala and even a Python port. The image which should be forming is that of more than one language which can already be compiled into bytecode running on more than one virtual machine.

Compiling to bytecode is a more complex exercise than translating to Javascript! The C++ precompiler has more to do than a translator. So why not take C++, Python or Java code and translate it to Javascript, rather than starting with a new language?

This is not just irritation on my part, although it is partly irritation. A translator could strip code of anything not permissible to a Javascript module, like API access or file operations. It could use existing code and libraries — the STL and Java Generics spring to mind. You could run it, debug it and test the logic in existing IDE tools. It would bring already-powerful strong typing and syntactical constructs for free. You could compile the same code fully for use in native applications. The possibilities and advantages are endless, and much of the work has already been done for the popular languages.

So why are we lumbered with yet another new language? Can someone hurry up and write me a Java to Javascript translator, please?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store