Live data from Hacker News

Cobra language gets major update

cobra-language.com

11–20 of 24 posts

Re: Cobra language gets major update

#11
Looks a lot like boo[0], which has been around for about a decade and has a Python-like syntax, type inference, static+dynamic typing, REPL loop, and runs on the CLR. Fantastic language, especially when it was new and C# was missing many of the features boo offered.

From what I can tell, Cobra adds compile-time nil tracking (nice!) and contracts. I'd be extremely interested in this if I was still doing anything in .NET.

[0] http://boo.codehaus.org

Re: Cobra language gets major update

#12
post #7

This looks promising. Nothing that has never been done before, but I really like the support for baked in doctests and contracts. This kind of sugar can make a real difference in terms of quality and readability #from the website, because it seems to be down for many right now. class SmallSample var _random = Random() def randomString(length as int, alphabet as String) as String require length > 0 alphabet '' ensure…

I've always wanted to work with a language that supports contracts (originally Eiffel I guess). Would love to see this hacked into Go. Or maybe I shouldn't turn this into a Go thread and start using Cobra.

Re: Cobra language gets major update

#14
post #12
post #7

This looks promising. Nothing that has never been done before, but I really like the support for baked in doctests and contracts. This kind of sugar can make a real difference in terms of quality and readability #from the website, because it seems to be down for many right now. class SmallSample var _random = Random() def randomString(length as int, alphabet as String) as String require length > 0 alphabet '' ensure…

I've always wanted to work with a language that supports contracts (originally Eiffel I guess). Would love to see this hacked into Go. Or maybe I shouldn't turn this into a Go thread and start using Cobra.

> I've always wanted to work with a language that supports contracts (originally Eiffel I guess). Would love to see this hacked into Go.

There have been a few attempts to hack (design by) contracts into Perl. Here are some which can be found on CPAN:

* Class::Agreement - https://metacpan.org/module/Class::Agreement

* Class::Contract - https://metacpan.org/module/Class::Contract

* Sub::Contract - https://metacpan.org/module/Sub::Contract

Sub::Contract is my favourite because it's lightweight, pragmatic & with a more Perlish implementation.

Re: Cobra language gets major update

#15
post #7

This looks promising. Nothing that has never been done before, but I really like the support for baked in doctests and contracts. This kind of sugar can make a real difference in terms of quality and readability #from the website, because it seems to be down for many right now. class SmallSample var _random = Random() def randomString(length as int, alphabet as String) as String require length > 0 alphabet '' ensure…

On that example, the syntax looks like Python with a bit of BASIC (the type declarations). That "StringBuilder" object reminds me of Java, I would prefer a concatenation operator.

Seems that doesn't use explicit variable declaration. Supporting that would be a great improvement over Python.

Re: Cobra language gets major update

#16
post #5

The docs aren't loading for me, but my first question was, why create a language that is almost, but not quite, exactly like Python syntax? Why give up compatibility with that whole community in exchange for minor syntax changes? (I don't mean the language extensions, like contracts, but the random tweaks that would stop you from running Python code directly in Cobra.) Here are some cached answers on that: Why Cobra?…

Cobra is compiled, there is a big speed difference compared to Python. There are a bunch of other features you should check out once the site speeds up.

I did check out the list of features, and it sounds very cool. I like the first-class support for contracts and testing. But it's like, if I have to learn new language quirks and find new libraries to do everything and so on, I could also spend time learning rpython, or go, or any number of other very cool projects with more established ecosystems. Cobra syntax looks so close to Python syntax that it might as well be a superset of Python and be able to run Python programs and take advantage of the Python ecosystem ... except it can't, because there are (what look to be, forgive me if I'm wrong) extremely minor incompatibilities like missing colons or alternate list comprehension syntax. That makes it ten times as annoying to pick up as a new tool, and just strategically, I question whether the gain from the incompatibilities was worth it.

Re: Cobra language gets major update

#17
post #11

Looks a lot like boo[0], which has been around for about a decade and has a Python-like syntax, type inference, static+dynamic typing, REPL loop, and runs on the CLR. Fantastic language, especially when it was new and C# was missing many of the features boo offered. From what I can tell, Cobra adds compile-time nil tracking (nice!) and contracts. I'd be extremely interested in this if I was still doing anything in .N…

Boo is awesome; it's meta-programming/macros look awesome.

Selfishly, I wish the JVM was its primary target and not .NET.

Re: Cobra language gets major update

#18
post #5

The docs aren't loading for me, but my first question was, why create a language that is almost, but not quite, exactly like Python syntax? Why give up compatibility with that whole community in exchange for minor syntax changes? (I don't mean the language extensions, like contracts, but the random tweaks that would stop you from running Python code directly in Cobra.) Here are some cached answers on that: Why Cobra?…

To make matters worse, there are no less than three Python-like options in the .NET world: IronPython, Boo and Cobra. With such fragmentation C# will probably stay the only game in town for a long time.

EDIT: Apparently Boo hasn't been updated for almost a year.. sad. Oh well, that leaves two choices then.

[1] http://dist.codehaus.org/boo/distributions/

Re: Cobra language gets major update

#19
post #16

Earlier quoted context omitted.

Cobra is compiled, there is a big speed difference compared to Python. There are a bunch of other features you should check out once the site speeds up.

I did check out the list of features, and it sounds very cool. I like the first-class support for contracts and testing. But it's like, if I have to learn new language quirks and find new libraries to do everything and so on, I could also spend time learning rpython, or go, or any number of other very cool projects with more established ecosystems. Cobra syntax looks so close to Python syntax that it might as well be…

As I understand it Cobra wants to take advantage of .NET ecosystem, it's libraries and all. If you are not into .NET then I guess you are right, but if you are willing to learn .NET or are already familiar with it, then Cobra may be a nice tool. I recently had to write a small library for .NET and used F# for this (I don't like C# and didn't want to use IronPython), but Cobra could be even better fit for what I needed to do.

If you need Python on .NET there always is IronPython, which is quite well supported. I think Cobra was made incompatible with Python syntax to emphasize that it is not Python, it has different aims and philosophy - but I can be dead wrong on this, maybe it's just because author liked some syntax better...

That being said I really don't think syntax matters that much, even if it's very similar (or very different) to something you know already. I learned and use CoffeeScript with pleasure even though it's syntax is similar - but not compatible - with Python's. Given a good syntax highlighting plugin for Vim, which I use as my editor, I have almost no problem at all with switching from Python to Coffee mode - when I end an if statement with ":" it gets highlighted as an object literal and then I instantly know it's wrong. On the other hand I use OCaml and Racket for some of my side-projects and similarly I don't miss much of Python's constructs. I think it is more important for syntax to be consistent than to be familiar or similar to something. I just don't understand marketing languages as "similar to C" in syntax, who cares?

Re: Cobra language gets major update

#20
post #5

The docs aren't loading for me, but my first question was, why create a language that is almost, but not quite, exactly like Python syntax? Why give up compatibility with that whole community in exchange for minor syntax changes? (I don't mean the language extensions, like contracts, but the random tweaks that would stop you from running Python code directly in Cobra.) Here are some cached answers on that: Why Cobra?…

To make matters worse, there are no less than three Python-like options in the .NET world: IronPython, Boo and Cobra. With such fragmentation C# will probably stay the only game in town for a long time. EDIT: Apparently Boo hasn't been updated for almost a year.. sad. Oh well, that leaves two choices then. [1] http://dist.codehaus.org/boo/distributions/

Python syntax is just one aspect of Cobra. There is also nil-checking, contracts, and easy syntax for testing.
Post reply on HN