jueves, 11 de junio de 2015

LED is my new Hello World - Pony Time

As you know...I'm always in a constant search for new, weird and cool programming languages...well...this time...the language came to me -;)

I was contacted by @scblessing letting me know about a programming language his company is working on...Pony.

So...what's exactly is Pony? Pony is an object-oriented, actor-model, capabilities-secure, high performance programming language.

Think about it as a nice mix of C++ and Erlang -;)

The documentation is not yet complete...but it's a good starting point...and also...it provides a Sandbox where you can read the source of Pony libraries and execute some fine examples...

So of course...I couldn't be happy with reading and playing around with it...I needed to code my LED as I do with all other programming languages...so here it is -;)

main.pony
actor Main
 var _env: Env
 
 new create(env: Env) =>
  _env = env
  let leds: Array[Array[String]] = [[" _  ","| | ","|_| "],
                                    ["  ","| ","| "],
                                    [" _  "," _| ","|_  "],
                                    ["_  ","_| ","_| "],
                                    ["    ","|_| ","  | "],
                                    [" _  ","|_  "," _| "],
                                    [" _  ","|_  ","|_| "],
                                    ["_   "," |  "," |  "],
                                    [" _  ","|_| ","|_| "],
                                    [" _  ","|_| "," _| "]]

  var num: String = try env.args(1) else "" end
  var i: I64 = 0
  var j: I64 = 0
  var line: String = ""
  while i < 3 do
   while j < num.size().string().i64() do
    try line = line.insert(line.size().string().i64(),
             leds(num.substring(j,j).u64())(i.string().u64())) else "" end
    j = j + 1
   end
   i = i + 1
   j = 0
   _env.out.print(line)
   line = ""
  end
  _env.out.print("")

And here...you can see it in action -:D



My thoughts are that Pony while still a young language, has a lot of potential and my quick experience with it was nothing but fun and exciting...I will keep a close look at it -;)

Greetings,

Blag.
Development Culture.