It's time to stop

A Better Javascript

Filed under:

This article is one of Metal Toad's Top 10 React JS Tips. Enjoy!


I've been thinking a lot about Javascript over the last few months. And not the "How can we architect a better system" type of thinking, but the "Why do people still write this?" type thinking. I guess it only recently occurred to me, it seems crazy that people still think it's a good idea. Javascript is the car you bought in 1992 that you drove until 2015, each week a new part breaking, each week a new "solution" to that broken part being glued on.  It's 2016, I think I've finally come to terms with the idea that it's time to upgrade.

But Browsers!

Yes. Browsers still use Javascript for tons of fun stuff. Yes, tons of programmers all over the world also are employed to write code specifically for the browser. Thing is, it's not 1992 anymore, there is a wide array of compile-to-js languages that allow you to both A.) Write better, more stable code, and B.) Work in the browser. The cool part is that many of them even out perform Javascript/JS libraries when compiled down. So again, why are we still writing this?


Elm is my personal favorite JS alternative, as it is a statically typed, functional compile-to-js language that is Blazing Fast. The compiler is written in Haskell, the language itself is very similar to Haskell, and the rendering implementation is similar to that of React/Angular2. Elm has a pretty decent following, and is often praised for its robust troubleshoot-ability. An example here.

Elm is great. I think Elm will be the tool I use to build my next personal application.

A quick code snippet to better understand what we're dealing with:

import Html exposing (Html, button, div, text)
import Html.App as App
import Html.Events exposing (onClick)
main =
  App.beginnerProgram { model = 0, view = view, update = update }
type Msg = Increment | Decrement
update msg model =
  case msg of
    Increment ->
      model + 1
    Decrement ->
      model - 1
view model =
  div []
    [ button [ onClick Decrement ] [ text "-" ]
    , div [] [ text (toString model) ]
    , button [ onClick Increment ] [ text "+" ]


Do you love Clojure? Well why not write Clojure in the browser! Clojurescript is yet another compile-to-js language that enables a user to write non-js for the browser. For those that don't know, Clojure is a Lisp-like language that runs on he JVM. Clojurescript is meant to be a direct port of Clojure for the browser, so most of the Clojure features loved by Clojure developers are available. A Clojure example:

(defn say-hello
         (println (str "Hello, " name)))
(say-hello "kim")

In Clojurescript there is a need for UI-Rendering libraries (as unlike Elm, Clojurescript does not ship with a concept of browser DOM), but a couple really smart people built a couple really smart libraries to solve those problems. David Nolen (now working at Cognitect, the developers and maintainers of Clojure) developed a library called Om, which is "a Clojurescript interface for Facebook's React." It can be found here.

Lastly, we have


Scala.js is yet another compile-to-js tool that compiles Scala code down to Javascript. Scala, like Clojure, runs of the JVM and, like Elm, is a statically typed, compiled, functional language. Scala.js offers type-safety and better-than-js compile-time error checking. Scala.js also has a React-to-Scala port in the works, which can be found here.

Your code sample:

package tutorial.webapp
import scala.scalajs.js.JSApp
object TutorialApp extends JSApp {
  def main(): Unit = {
    println("Hello world!")

So please, consider alternatives

Javascript isn't the best. Even ES6 has its problems. In 2016 we do not have to be tied to a language as finicky and error-prone as Javascript. The conversation seems to have moved away from "what language will allow us to deliver the safest, most efficient, easiest to write software," and into "But I like javascript! I don't like other languages because they're not javascript." I think that this thought process is losing the forest through the trees. Elm, Clojurescript and Scala all provide better alternatives that solve the same problem as javascript (browser stuff), but with safer, more efficient development means.

Learn more about JavaScript in our JavaScript Blog Archive.

Date posted: October 3, 2016


The world of programming has many flavors. No technology has been created to-date that makes programming a business application easy. All these technologies are complex and once you get beneath the surface, you discover that they are all complex and have horrible shortcomings. OO, Functional, ... you name it. God bless COBOL. It has not changed over the last 25 years or so. You can be an expert in 2 years and live your professional life at ease. No programmer should abandon JS if they know how to use it. I see it as a horror story. However, you better have it on your resume if you want to find a job in web development.

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <cpp>, <java>, <php>. The supported tag styles are: <foo>, [foo].
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Metal Toad is an Advanced AWS Consulting Partner. Learn more about our AWS Managed Services

Schedule a Free Consultation

Speak with our team to understand how Metal Toad can help you drive innovation, growth, and success.