I had taken a look at Pony Lang a few years back, and I had found that it had a lot of very interesting ideas about it that warranted a closer and deeper look.
Unfortunately, the documentation was quite subpar in those days, and I quickly lost interest in the project. A while back, I heard new that Sylvan Clebsch (the author of the Pony language) had moved on to Microsoft, and that led me to wondering about the state of the project.
Surprisingly, I found that the language had managed to garner itself quite a community of enthusiasts and even some industry support (thanks in a very large part to Sean T. Allen and co.). This rekindled my interest in Pony, and I have decided to seriously pursue the language this time around.
In that spirit, I present my first attempt at a relatively interesting program in Pony (I am still an abject beginner in Pony!), much as I have done with other languages that piqued my interest:
class LineNumGenerator var _env: Env new create(env: Env) => _env = env fun new_line_num_closure(): {ref()} => var linum = USize(0) {ref()(env = _env) => linum = linum + 1 env.out.print("Line number = " + linum.string()) } actor Main new create(env: Env) => let a_linum_func = LineNumGenerator(env).new_line_num_closure() var ctr = U32(0) while ctr < 10 do a_linum_func() ctr = ctr + 1 end env.out.print("") let another_linum_func = LineNumGenerator(env).new_line_num_closure() ctr = U32(0) while ctr < 5 do another_linum_func() ctr = ctr + 1 end
And running it, we get the expected output:
Line number = 1 Line number = 2 Line number = 3 Line number = 4 Line number = 5 Line number = 6 Line number = 7 Line number = 8 Line number = 9 Line number = 10 Line number = 1 Line number = 2 Line number = 3 Line number = 4 Line number = 5
Very satisfying, especially the blazingly fast compilation speeds of Pony (thus far – I hope to see similar performance when I get around to some actual projects in it).
The bulk of the core language still lies ahead of me – Reference & Object Capabilities, Generics, Pattern Matching, and C-FFI in particular. This should be an interesting journey!