Thursday, December 22

Geek

Emerald Anaconda

This is real code:
# Python
def readfile():
  for line in open("/some/file"):
    yield line

# Ruby
readfile.to_enum.each do |line|
  puts line
end

# Python
def iterate_list():
  for item in [ 1, 2, 3 ]:
    yield item

# Ruby
items = []
iterate_list.to_enum.each { |item| items << item }
puts items == [ 1, 2, 3 ] # => true
At least, it's real code if you are running RubyPython.

You can embed JavaScript in Ruby, and Lua in Python, so that gives you four languages in a single environment.  Five if you count CoffeeScript, which is a CoffeeScript to JavaScript compiler written in CoffeeScript.*

And you can of course chain things so that Lua can call back to Python which calls back to Ruby which calls a CoffeeScript function which you precompiled to JavaScript.**

* They used magic.
** Because it was there.

Posted by: Pixy Misa at 01:26 PM | No Comments | Add Comment | Trackbacks (Suck)
Post contains 133 words, total size 1 kb.

Comments are disabled. Post is locked.
40kb generated in CPU 0.04, elapsed 0.2201 seconds.
50 queries taking 0.1965 seconds, 280 records returned.
Powered by Minx 1.1.6c-pink.