It’s time for our 4th and final post on Language Transformations, this time taking a look at transpiling. Transpiling is the process of taking one source language and transforming it into another source language. If it sounds a lot like compiling, that’s because for the most part, it is. The main difference between transpiling and compiling, however, is the output. Compiling generally takes source code and transforms it into a more machine interpretable set of instructions. Transpiling on the other hand, outputs another human readable and usable language.
So why use transpiling?
Getting Awesome New Features
Generally, this is the main reason that transpiling comes about. Someone says “I wish X language did Y,” and then they build a transpiler.
Let’s face it. Most developers have a go-to language that they use for a good share of their projects. Of course, there are generalists, newer and better languages, and some projects that simply don’t allow you to use your favorite language. What transpiling can allow, then, is the use of language features and syntax from your favorite language that is transformed into the language that generalists, early adopters and projects love!
Keeping it DRY
DRY or as we all know it, Don’t Repeat Yourself, is a fundamental paradigm to software engineering. There may be situations where you need to have redundancy and repetition, but in most cases, keeping everything DRY is the best way to increase maintainability by reducing your points of maintenance (and failure). So then, how does DRY apply to transpiling?
Transpiling allows you to build your application in one language, and then port it to many different platforms. You can build websites and mobile apps at the same time with Phone Gap. Or you can build those same apps using C# with Xamarin. When you are done, these services will transpile your source code from one platform into a native language that your mobile devices can understand.
I know, I know, this post was a lot shorter and was not as rife with examples as my other Language Transformation posts. But here’s the best part about transpiling…it’s simple enough that I don’t have to talk on and on about it. If you need more features, familiarity or a single code base, then it is time to look into transpiling.
As for me and my development? I’m sticking with pure JS and macros. Call me a hypocrite, but I just love me some curly braces, polyfills and creating my own domain language. But hey…I’m a bit crazy.