

Cobra language gets major update - whiletrue
http://cobra-language.com/
Currently for .NET, JVM in the pipeline.
======
JackC
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?
[http://webcache.googleusercontent.com/search?q=cache:A7djdaz...](http://webcache.googleusercontent.com/search?q=cache:A7djdazJDbwJ:cobra-
language.com/docs/why/+&cd=1&hl=en&ct=clnk&gl=us)

and

Cobra compared to Python:
[http://webcache.googleusercontent.com/search?q=cache:GmrbTK9...](http://webcache.googleusercontent.com/search?q=cache:GmrbTK99decJ:cobra-
language.com/docs/python/+&cd=1&hl=en&ct=clnk&gl=us)

It sounds like basically the adoption strategy is to sell people coming from
.NET on a Python-like language with binary compatibility, rather than to sell
people coming from Python on a statically typed, compiled language with source
compatibility. So, not as much for me as a Python person, until the ecosystem
evolves. Too bad, because it doesn't seem like there was much of a win from
giving up forward compatibility. But maybe a cool thing for .NET people?

~~~
whiletrue
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.

~~~
JackC
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.

~~~
klibertp
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?

~~~
pjmlp
F# took over Python, when I am doing scripting on Windows.

Just because it is a nice excuse to use it on work projects, otherwise I am
bound to the languages required for the project.

~~~
klibertp
That's true, it's hard to use something different at work and F# seems
plausible as a tool enough to use it without risk :)

------
thomasz
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
    			result.length == length
    		test
    			utils = SmallSample()
    			assert utils.randomString(5, 'ab').length == 5
    			s = utils.randomString(1000, 'a')
    			for c in s, assert c == 'a'
    		body
    			sb = StringBuilder()
    			for i in length
    			c = alphabet[_random.next(alphabet.length)]
    			sb.append(c)
    			return sb.toString

~~~
jksmith
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.

~~~
draegtun
_> 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.

------
jcheng
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>

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

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

------
tomku
The syntax reminds me of a mixture of VB and Python, but it certainly seems to
have a lot of interesting features that you don't see together often. Anyone
here have experience using it?

------
pjmlp
This is what Go should have been.

Seems quite nice.

------
creatio
Am I the only one who read it as: The Clean Language (as in the functional
languagel CLean) and powerful Cobra Language gets major update.

------
whiletrue
Sorry guys, looks like the site is a little slow right now...

------
m1
Had to do a double take then, thought it said Cobol

