Review of Transpilers [Part 2]

IN NOVA FERT ANIMUS MUTATAS DICERE FORMAS
CORPORA; DI, COEPTIS (NAM VOS MUTASTIS ET ILLAS)
ADSPIRATE MEIS PRIMAQUE AB ORIGINE MUNDI
AD MEA PERPETUUM DEDUCITE TEMPORA CARMEN!

I want to speak about bodies changed into new forms.
You, gods, since you are the ones who alter these, and all other things,
inspire my attempt, and spin out a continuous thread of words,
from the world’s first origins to my own time.

Metamorphoses” by Ovid

Transpilation is the process of compiling source code written in one language to generate source code for a desired target language. With the ubiquity of JavaScript used not only in almost all modern web browsers but also in a growing number of server-side applications, a new generation of transpilers that target the generation of ECMA-compliant JavaScript have emerged to provide developers with a robust set of tools to develop efficient and elegant source-to-source solutions.

The motivation behind the transpilation process is that it accelerates the use of next-generation language syntax and language features while helping to ensure that the adoption of the language features results in browser-compatible JavaScript that meets the functional goals of applications.

In Part 1 of this series, two example transpilers were reviewed: TypeScript and Fable. In this second article, Babel and Nim are reviewed.

Babel

Babel allows developers to write code utilizing modern features of JavaScript without worrying about browser compatibility. It does this by transforming code into the older ES5 standard (a since-revised standard on which JavaScript is based). It is updated with yearly modules, collected together in a master preset that contains all changes since ES5. This lets developers use such features as classes, arrow functions, multiline strings, destructuring, and generators/iterators.

The Babel website includes a page of basic examples, linked to a “Try it Out” page that shows how Babel transforms pieces of code.

Nim

Nim is a program language capable of compiling into C-family languages (C, C++, Objective-C) and JavaScript. Note that Javascript compilation is considered an experimental feature and is presented with a list of restrictions in the documentation. Nim allows performance-enhancing optimizations at the compilation level and is extensible through templates, macros, and external libraries. It has also performed relatively well in benchmark testing.

Here are a few links for further exploration of the Nim language:

  • Nim provides specific information and instructions for each of the backends to which it compiles.
  • A third party has developed a self-described “rudimentary” Read Evaluate Print Loop (REPL) for Nim on github to allow previewing post-compilation code in real-time.
  • Nim also includes a since-deprecated built-in REPL called “nim secret”, put out of use due to its inability to incorporate C’s stdlib.

Blogger Dennis Felsing has provided an excellent, feature-by-feature overview of Nim’s capabilities.

Babel vs. Nim: Who Rules the Web? Check out our latest technical blog to find out. Our software developers are totally geeking out rn.

Share this:

Related Topics

Are Waiters Soon to Be Extinct?

Well, maybe not soon, but the concept is definitely a new thought now that a revolutionary restaurant in Singapore is deploying hovering drones to deliver hot food from the kitchen straight to the customer’s tables. Chefs at restaurant Timbre, load up the 5 plated serving tray and send the helicopter­ like device to a particular... Read more »

Read More

Don’t Get Tricked – Treat Yourself to Great Technology!

The great thing about technology is that it’s always working to find innovative new ways to help us run our personal and professional lives faster, better and more easily. Since we have our fingers on the pulse of technology and how it’s being used today to help business owners find more customers, make more sales... Read more »

Read More

Are you in your customers’ Final Four?

As we are enjoying the thrill and heartbreak of the NCAA’s College Basketball tournament, it makes think how similar the competition on the courts are to the intense competition your business faces every day. So we started to ponder the following: Is your company headed for your customers’ final four? Are you top-seeded in appearing... Read more »

Read More