Friday, March 1, 2013

repl.it, online REPL for many languages, and empythoned

By Vasudev Ram

repl.it is an online REPL (Read-Eval-Print-Loop) for multiple programming languages, including for Python. Some of the other supported languages are QBASIC, FORTH, Lua and Scheme and Ruby (it says "beta" for Ruby, but the other languages also may not have full support, e.g. see the excerpts below).

Here is a small test run of using repl.it with Python, that I just did:
Python 2.7.2 (default, Jul 20 2011, 02:32:18)
[GCC 4.2.1 (LLVM, Emscripten 1.5, Empythoned)] on linux2
   def foo(bar): 
..   print "in foo, bar =", bar 
..   
   foo(1)
in foo, bar = 1
   foo("ab")
in foo, bar = ab
   
   for i in range(4): 
..   foo(i) 
..   
in foo, bar = 0
in foo, bar = 1
in foo, bar = 2
in foo, bar = 3

   class Foo(): 
..   def bar(self): 
..     print "in Foo.bar()" 
..     
   
   foo = Foo()
   foo.bar()
in Foo.bar()
    

About repl.it.

For running Python, repl.it uses empythoned, which in turn uses emscripten.

Excerpts from the related tools' sites:

[ Empythoned is a build script that uses Emscripten to compile CPython for use in a browser. It attempts to compile the main interpreter as a single small executable and the whole standard library as dynamically loaded libraries.

The project is in its infancy. Right now the core interpreter works very well, but many of the libraries either don't work at all or contain various bugs. ]

[ Emscripten is an LLVM-to-JavaScript compiler. It takes LLVM bitcode - which can be generated from C/C++, using llvm-gcc or clang, or any other language that can be converted into LLVM - and compiles that into JavaScript, which can be run on the web (or anywhere else JavaScript can run).

Links to demos, tutorial, FAQ, etc: https://github.com/kripken/emscripten/wiki

Main project page: http://emscripten.org ]

- Vasudev Ram - Dancing Bison Enterprises



No comments: