A tour of transpiling and back again with six different web development languages.
Creating modern web applications requires developers that are proficient in an increasing variety of languages. Python, Ruby, and PHP are among the most popular server-side languages while JavaScript monopolizes client-side development. But there's a dream for the future of web development. A future where applications can be written once, in your favorite language, and then run everywhere.
This demo explores the reality and sacrifices of trying to chase this dream through source-to-source compiling for client-side applications.
Prepared for the annual 🐍 Fuzzy.py 🐍 extravaganza at Fuzz Productions.
A small python command-line program is used as the control to be transpiled into a variety of languages.
class Pie:
def __init__(self, filling):
self.fill_with(filling)
self.eaten = False
def eat(self):
self.eaten = True
def fill_with(self, filling):
self.filling = filling
apple_pie = Pie('apple')
apple_pie.eat
frame = ''.join(['*' for s in xrange(28)])
print frame
print "* Who ate the %s pie?!? *" % apple_pie.filling
print frame
Python
(through PythonJS) ➢JS
Ruby
(through Opal) ➢JS
JS
(through js2php) ➢PHP
JS
(through js2py) ➢Python
JS
(through js2hd) ➢Hodor
Dogescript
(through dogescript) ➢JS
Install the dependencies and start the demo by running magic.sh
bash script in the root directory. The script will run through all six conversions and test the resulting code.