Forums

Cobra vs Boo

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Cobra vs Boo

Postby peterb » Fri Nov 21, 2008 8:19 am

Hi,

I have just discovered Cobra and have noticed how similar it is to Boo.
Both are OO Python inspired languages targeting .NET.
Both support static type inference as well as dynamic types.
Both support generators and yield statements.
Boo seems to be more advanced though in it that it already
supports full closures and syntactic macros.
Cobra does seem to have better support for contracts,
although I believe these can be supported in Boo via
macros.
Looking through the 'Why Cobra?' section, I agree completely
with all the comments, but I'm just curious to know what niche
Cobra addresses that Boo doesn't.

In short, why would I want to use Cobra rather than Boo?
peterb
 
Posts: 1

Re: Cobra vs Boo

Postby Charles » Fri Nov 21, 2008 9:00 am

Hi Peter,

I've seen a few attempts to implement contracts in Boo using macros and they have always fallen short of the full contract semantics as found in other languages such as Eiffel. Contracts may be one of those features that needs to be baked into the language, like generics or infix expressions.

Cobra favors the platform collections. For example, [1, 2, 3] is a .NET List<int> in Cobra, but a BooList in Boo. I think it's easier to vend Cobra class libraries back out to C# and VB developers because the DLLs will "feel normal" to them.

Cobra has compile-time nil tracking, meaning that "String" is always a String, and "String?" is String or null/nil. The compiler tracks these types carefully and can detect multiple errors at compile-time--e.g., passing something nullable to an argument that will never accept null. Furthermore, it can report multiple errors at a time. In Boo, Python, C#, etc. these problems are experienced one at a time as exceptions at run-time, which is far less productive. I have far fewer NullReferenceExceptions in Cobra than I do in other languages.

Boo places great emphasis on macros while Cobra places great emphasis on "coding for quality". This includes first class support for unit tests that can be specified with a lightweight syntax.

I suppose this represents a difference in opinion as to what developers need more of. Do they need more macros and DSLs? Or do they need more quality control to prevent bugs and detect them early?

Cobra is implemented in Cobra which yields these benefits:
-- It helps us test the language. (Is it stable?)
-- It helps us gain more experience using the language which then informs its further development. (Is it convenient and expressive?)
-- Cobra users are more likely to be able to contribute to the compiler because it's written in the language they know.
-- Tt's a demonstration that Cobra is very capable--it can implement a compiler.

I'm not sure which project is more stable. Here's a bug report on their mailing list from October: http://www.nabble.com/bug-or-not--td20198906.html for which no one has responded. I tried out the code in Cobra and it works fine. But Cobra is not bug free either, although we're headed in that direction.

I try to give really good support for Cobra with thorough, timely answers. You should be able to confirm that by browsing through the forums. If you have a question, I'm available.

Closures are coming soon.

Will Cobra ever have macros? Possibly, but if so, it will be much later. I think macros are a tricky topic and I'm well aware that's lots of Python and C# projects are doing fine without them. And I don't mind letting the Boo guys explore this area in public. Even Microsoft could end up exploring this area and it would be interesting to see what they come up with.

If you have further questions, feel free.

HTH,

Chuck
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 120 guests

cron