Serious Programmers Should be Serious about Ditching JavaScript. Here’s how to do it right now.

Want to abandon Javascript from your web pages for all eternity, right now, using today’s technology, without any special support from the web browser? JavaScript is and always has been one of the worst aspects of writing code in a browser.   It has no real type system, no objects, no inheritance, no interfaces.  To make things worse it is run-time evaluated, meaning that syntax errors in your code as simple as a typo in capitalization will go unnoticed until a particular branch of code is executed. Typescript to the rescue!

Typescript works in any JavaScript enabled browser because Javascript is typescript and Typescript compiles itself down to Javascript.  Therefore you can simply embed the typescript compiler into a script in your web page and it will conveniently and seamlessly handle the translation from Typescript to Javascript.

Anders Heijlsberg, over at Microsoft, has an excellent presentation that will quickly sell you on the idea of why you absolutely need Typescript to replace Javascript with some awesome code samples.

In his presentation he mentions that it can be compiled inside the web browser, however, Microsoft did not supply the necessary tools/examples showing you how to embed the compiler inside your web page (as opposed to having it compiled on the back-end). Fortunately, github has a nice example, proving that it can be done. I installed the sample on my server so you can simply test it live if you want.  For some reason the demo only works on my phone if I “request a desktop site”.   But requesting a desktop site proves that the demo can compile just fine from the phone.

I may put it through the paces and change it a bit as I am rather curious about this new language myself. Compiling TypeScript on the client, means that the server does not need any special support or plug-ins or compilers installed.  It will just work.   However, you might want to consider compiling it on the back-end to protect your valuable code.

-jn

One Reply to “Serious Programmers Should be Serious about Ditching JavaScript. Here’s how to do it right now.”

  1. Why not use our Smart Mobile Studio compiler? Then you can write object pascal and compile to JS. Much easier and very fun to work with. Instead of spending 3 weeks writing in native JS, you can do the same work in SMS in 3 days using object pascal.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.