Monday, March 3, 2008

Notes from the SoCal Piggies meeting on Feb. 28th

The SoCal Piggies meeting last week was graciously hosted by Gorilla Nation at their offices in Culver City. There were a lot of new people in attendance -- in fact, when I got there, I only knew 1 out of the approximately 10 people in attendance. More familiar faces trickled in slowly, and we ended up with around 20 people, which was good to see.

The first presentation of the evening was "Django reports with JQuery -- how to build a report system in 60 minutes" by Gorilla Nation's own Steven Wagner and Saravana Reddy. Steven had spent less than 60 minutes the night before coming up with a Django application that shows how easy it is to run reports by navigating data relationships and displaying summary information in Django. I liked the fact that the app was self-contained and easy to grasp. It made indeed for a very good introduction to the reporting capabilities of Django.

Saravana showed us a quick demo of DOM manipulation, event binding and animation using the JQuery Javascript library. It looked fairly easy to use. The code for the Django and JQuery demos is available on code.google.com here.

The next presenter was Chuck Esterbrook, who talked about his new programming language, Cobra. You don't get to see language creators talk about their babies every day, so it was an interesting experience. Cobra is inspired by the other slithering language, but adds features such as (optional) static typing, design by contract (inspired by Eiffel) and language-level support for unit tests. Of course, this last feature made me perk my ears. Here's how unit tests look in Cobra:

def capped(s as String) as String is shared
test
assert Utils.capped(‘aoeu’) == ‘Aoeu’
assert Utils.capped(‘’) == ‘’
expect NullArgumentException
Utils.capped(nil) # ahem
body
...

The tests get auto-discovered when you run the Cobra interpreter with the -test switch. Which is really cool.

I encourage you to check out Chuck's slides, and the various comparisons with other languages available in the Documentation area of the Cobra Web site. One thing that's not exactly clear from the overview of the language on the Web site is that Cobra is really tied to the C# compiler and the .NET CLR. In fact, if you don't have the .NET CLR and the C# compiler available, then you can't run Cobra. Chuck is developing under Mono on OSX, and of course Mono is available for Linux, so it turns out the .NET thing is not as restrictive as it seems. And there are plans for other back-ends, such as the JVM, LLVM, Parrot, etc.

The fact that Cobra is compiled to .NET CLR bytecode gives it an advantage when it comes to using available .NET libraries and frameworks. I asked Chuck when will we see the first Web framework written in Cobra (that of course being the sign that a language has arrived) and he replied that there already are many open-source Web frameworks available for .NET, so Cobra can just use those.

If you're asking yourself why you need Cobra when you already have IronPython, Chuck provides an explanation on the 'Comparison to Python' page:

"Cobra creates the same kinds of classes, interfaces, method signatures, etc. that are found in C# and Visual Basic. Consequently, you can create a class library in Cobra and comfortably vend it out to C# and Visual Basic programmers on the .NET/Mono platform. In fact, it's an explicit goal of Cobra to play nice with .NET's flagship languages so that introducing Cobra to work environments is both technically and politically feasible.

This is different than IronPython whose class libraries are not going to "feel right" or even be readily accessible to other .NET programmers.

Like IronPython, Cobra can use any .NET libraries, whether home grown, open source, commercial, etc. It can also benefit from .NET tools like profilers and ORMs.

(By the way, IronPython is certainly the best choice if you have lots of existing Python code you wish to run on .NET, or you simply wish to stick with Python while using .NET.)"

Personally, I can't say I'm sold on starting to use Cobra -- the fact that's it's currently married to .NET/C# is a fairly big turn-off for me. But that's just me. If you're developing under .NET and are looking for a modern language with a lot of good features, then give Cobra a try and also check out the Cobra forums.

I'd like to thank Steven Wagner and Gorilla Nation for hosting the meeting. The food was really good too :-) Thanks to Steven, Saravana and Chuck for presenting.

The next SoCal Piggies meeting will be at the end of March, after PyCon08. Paul Hildebrandt offered to host the meeting at Disney in Burbank. If you're interested in attending, sign up on our mailing list so you can get all the details.

No comments: