Thursday, February 17


Cobra: Like Python, But With Teef

I've just spent the last hour tinkering with Cobra, a .Net/Mono-based application programming language.

I quite like it.  It's not perfect, but having dabbled in language design myself, I understand that there is no perfect language.  It's not just the limitations of human designers, or bad decisions that you end up stuck with; there are simply trade-offs that have to be made.  Making X elegant makes Y less so.

Occasionally there are clever and robust new ideas that allow us to make both X and Y elegant, but given the progress (hah!) in languge design since Algol 60 which appeared before I was born, I don't hold out a huge amount of hope that things will change significantly before I retire.


It's Python-like, though it's not Python.  (They also have a handy Ruby comparison page.)

It's fast - though Mono has a longer setup time than Python (~100ms vs <20ms, from my cursory testing), once it's up and running it's about as fast as Psyco, the sadly abandoned Python JIT compiler.  Which means, significantly faster than native Python.

And it has real threads.  One of the big problems I have with Python at my day job is that Python doesn't really do threads as a means of increasing performance.  The Global Interpreter Lock (the GIL) ensures that only one thread is executing Python code at any time.  Which means that if you spawn 50 threads, they'll all wait for each other and run little faster than one thread - and possibly quite a lot slower.

The reasons for this are support for non-thread-safe libraries and more efficient single-threaded execution (less locking is required if you're the only thread active at any given time).

The downside is that to get any scaling at all you have to go to multiple processes, and that requires a lot more code refactoring (and potentially a lot more memory) than multiple threads.

Anyway, .Net/Mono is fully multi-threaded; no such limitations apply.

What I don't like about Cobra: 4-space indenting.  I used to use 4 spaces, but lately I've been using 2, and I'd have to change back!!

That, and the Mono thing.  I haven't looked at Mono all that closely; Python has been my main programming language for most the past 4 years (with a brief but horrible excursion into PHP in 2008).  I know Python.  It just works.  Mono I'm not sure about.

Tomorrow, I think I'll venture into Boo-land.

Posted by: Pixy Misa at 04:52 AM | Comments (8) | Add Comment | Trackbacks (Suck)
Post contains 411 words, total size 3 kb.

1 Can Go be far behind? Or how about Erlang?

As I understand, Mono is fine. Its only downside is that if you select it, you select your friends as well. Programming in Mono is a political statement.

Posted by: Pete Zaitcev at Thursday, February 17 2011 06:14 AM (9KseV)

2 Looked at Go.  Don't like it at all.  It's not a good language, and it doesn't have good libraries.  That's why the takeup has been negligible despite the backing of the big G.

Erlang is interesting, but too weird and impractical for general use.  Same goes for the entire functional crowd.

As for the politics of it....  Yeah, it's true.  And the same goes for Java and JVM-based languages.

The problem is that there are no good, independent application languages.  There's plenty of scripting languages - Perl, Python, PHP, Ruby, Lua, Pike.  And as far as system languages go, you've got C or C++.  Objective-C if you're into self-mutilation.

But for application programming, you've got the Java group, the .Net/Mono group, and weird things no-one uses.  Or you go with a system language or a scripting language, and deal with the fact that the language will forever be a bad fit for the task.

Which is a horrible situation, but it's reality.

Posted by: Pixy Misa at Thursday, February 17 2011 07:34 AM (PiXy!)

3 Where was I?


Also, I need to build a desktop client for Minx.  I'm not going to do it in Python, because Python's GUI support is terrible, and I can't ask users to install Python first and then load and run the application from there.  It's possible to bundle it all up into an executable, but it's still nasty.

I hate Java.  Oh, it gets the job done, but it really has become the 21st century of Cobol, with all the bad as well as the good.

Don't like C#; not all that keen on VB.Net.

I could use something like RealBasic, but that means vendor lock-in, so no.  Same goes for either version of Delphi.

It's a mess.  Cobra (and possibly Boo) are the best ways out I've found so far.

Posted by: Pixy Misa at Thursday, February 17 2011 07:44 AM (PiXy!)

4 I don't think it's all that bad. Youtube is all in Python.

Posted by: Pete Zaitcev at Thursday, February 17 2011 08:09 AM (9KseV)

5 I'm pretty happy writing web applications in Python.  It's slower than it could be (Psyco fixes that, but binds me to Python 2.6 and 32 bits), and testing is more involved than it should be, but the language is elegant and expressive and the libraries are excellent.

But for desktop applications it's just terrible.

Posted by: Pixy Misa at Thursday, February 17 2011 08:21 AM (PiXy!)


Youtube is all in Python.

Except for all the parts which are in ActionScript...

Posted by: Steven Den Beste at Thursday, February 17 2011 04:17 PM (+rSRq)

7 I suppose this sort of argument is limited indeed. Mixi hit 5 million on Perl with C libraries, but I think it's being rewritten now.

Posted by: Pete Zaitcev at Thursday, February 17 2011 11:09 PM (9KseV)

8 Adobe Air !!!!!!!!! I better hide.

Posted by: Andrew Fong at Wednesday, February 23 2011 08:49 AM (cB03i)

Hide Comments | Add Comment

Comments are disabled. Post is locked.
46kb generated in CPU 0.04, elapsed 0.1301 seconds.
51 queries taking 0.1118 seconds, 269 records returned.
Powered by Minx 1.1.6c-pink.