Discussion:
Introducing Cobra
(too old to reply)
Chuck Esterbrook
2008-01-02 04:48:17 UTC
Permalink
Hi everybody,

I've created a programming language that could be described as a cross
between Python, Eiffel, Objective-C and C#. It runs on Linux, Mac and
Windows via Novell Mono or MS .NET.

More details on why I created it can be found in "Why Cobra?" at
http://cobralanguage.com/docs/why/

Other documents of interest include:
http://cobralanguage.com/docs/hello-world/
http://cobralanguage.com/docs/quality/
http://cobralanguage.com/docs/python/

I'm interested to hear your impressions, comments and questions.

-Chuck
--
http://CobraLanguage.com/
David Brown
2008-01-02 05:24:33 UTC
Permalink
Post by Chuck Esterbrook
I'm interested to hear your impressions, comments and questions.
First impression question. Did you have any parsing problems not using the
trailing ':' that python likes to use before indent blocks?

I definitely like the idea. I looked at Boo a little bit, and it looks
like you got some inspiration from that.

I'm mostly glad that you seem to understand the value/importance of
generics. A semi-statically typed language with a python-like syntax with
nice generics could be a very useful language.

I'll definitely be looking into it when I get a chance.

Just curious if you plan on distributing source.

Dave
Chuck Esterbrook
2008-01-02 06:39:10 UTC
Permalink
Post by David Brown
Post by Chuck Esterbrook
I'm interested to hear your impressions, comments and questions.
First impression question. Did you have any parsing problems not using the
trailing ':' that python likes to use before indent blocks?
No problems. Although it becomes required if you want to put a
statement on the same line:

branch state
on State.On: print 'on'
on State.Off: print 'off'
Post by David Brown
I definitely like the idea. I looked at Boo a little bit, and it looks
like you got some inspiration from that.
A little bit, but the static+dynamic support which people often
attribute to Boo actually comes from my old Objective-C days.
Post by David Brown
I'm mostly glad that you seem to understand the value/importance of
generics. A semi-statically typed language with a python-like syntax with
nice generics could be a very useful language.
Thanks and agreed.
Post by David Brown
I'll definitely be looking into it when I get a chance.
Just curious if you plan on distributing source.
Definitely. MIT license.

There is some "old style" Cobra code in the compiler which would give
a false impression of current coding style and features. Also, there
are just a few more warts that I wish to remove. It doesn't have to be
perfect, though. Hopefully this month, but certainly no later than
Feb.

-Chuck
David Brown
2008-01-02 06:46:32 UTC
Permalink
Post by Chuck Esterbrook
Post by David Brown
Post by Chuck Esterbrook
I'm interested to hear your impressions, comments and questions.
First impression question. Did you have any parsing problems not using the
trailing ':' that python likes to use before indent blocks?
No problems. Although it becomes required if you want to put a
branch state
on State.On: print 'on'
on State.Off: print 'off'
Is the ':' allowed? The vim python indent plugin seems to use the ':' to
determine when to indent. Teaching vim how to color and indent a new
language is always the frustrating part.

Dave
Chuck Esterbrook
2008-01-02 16:39:32 UTC
Permalink
Post by David Brown
Post by Chuck Esterbrook
Post by David Brown
Post by Chuck Esterbrook
I'm interested to hear your impressions, comments and questions.
First impression question. Did you have any parsing problems not using the
trailing ':' that python likes to use before indent blocks?
No problems. Although it becomes required if you want to put a
branch state
on State.On: print 'on'
on State.Off: print 'off'
Is the ':' allowed? The vim python indent plugin seems to use the ':' to
determine when to indent. Teaching vim how to color and indent a new
language is always the frustrating part.
The indent for a colon language would be at least two keystrokes: [Shift] [;/:]

And maybe it's three?[Shift] [;/:] [Return]

The indent for Cobra is exactly two: [Enter] [Tab]

The colon is allowed because I don't want Python people to get
frustrated when starting out with Cobra. *But* It generates a warning
because Cobra has a theme of "syntax normalization" which I need to
write about. Essentially, most Cobra programs look mostly the same so
that code you see in a blog, email, wiki or in a project you just
inherited differs more by semantics than syntax. Examples rules
include:
* Classes must be capped
* Arguments and locals must start lower
* Blocks must be indented

I got the idea straight out of English where everything I read has
about the same syntax and consequently I dive immediately into
semantics regardless of what I'm reading.

The above rules generate errors. Some rules, like the extraneous
colon, generate warnings. Another example warning is treating return
like a function call instead of a statement: return(x)

Should be: return x

Back to indentation: I think you're okay in vim with [Return] [Tab]
but let me know if that's a problem. Indentation can be one tab or 4
spaces. No mixture of tabs and spaces on the same line as that causes
hell in Python.

-Chuck
David Brown
2008-01-02 17:07:16 UTC
Permalink
Post by Chuck Esterbrook
The indent for Cobra is exactly two: [Enter] [Tab]
With proper indentation support in the editor, the programmer should
_never_ have to explicitly indent the code. I think that is largely why
the colon is present in python, to make this somewhat possible.

It can still be done, but the editor has to be taught a whole lot more
about the grammar of the language.

Honestly, lack of proper indentation support would be enough to keep me
from using a language.
Post by Chuck Esterbrook
The colon is allowed because I don't want Python people to get
frustrated when starting out with Cobra. *But* It generates a warning
because Cobra has a theme of "syntax normalization" which I need to
write about. Essentially, most Cobra programs look mostly the same so
that code you see in a blog, email, wiki or in a project you just
inherited differs more by semantics than syntax. Examples rules
* Classes must be capped
* Arguments and locals must start lower
* Blocks must be indented
I would argue that the colon _is_ the normalized syntax, and that you have
to know more about the language to parse it without the colon present.

I would encourage you to pick a grammar and just use it.

You're defining the language, so you get to decide how much is style vs how
much is enforced.
Post by Chuck Esterbrook
I got the idea straight out of English where everything I read has
about the same syntax and consequently I dive immediately into
semantics regardless of what I'm reading.
English grammar is a terrible place to look for inspiration for a
programming language. In fact, _all_ spoken human languages are riddled
with inconsistencies, often around the core aspects of the languages
(prepositions, to-be, etc).
Post by Chuck Esterbrook
The above rules generate errors. Some rules, like the extraneous
colon, generate warnings. Another example warning is treating return
like a function call instead of a statement: return(x)
Should be: return x
What about return (x + 4) ?

Warning about extra parens seems rather pedantic to me.
Post by Chuck Esterbrook
Back to indentation: I think you're okay in vim with [Return] [Tab]
but let me know if that's a problem. Indentation can be one tab or 4
spaces. No mixture of tabs and spaces on the same line as that causes
hell in Python.
_never_ hit tab in vim. If you want manual indentation, set sw=4, and use
^T and ^D to adjust indentation. Indentation depth and tab with are
unrelated.

Can I indent arbitrarily, or do you enforce a specific amount. The python
parser has some strange rules for this that work well (other than the
oddities of tabs and spaces). But, Python is perfectly happy with the
first indentation being 4 spaces, and the second level being a single tab.
There are numerous editors that will do this, since it is how tabs have
been defined for a long time. If you're different, you'll need to be very
explicit about it.

Please do not assume that tabs are 4 spaces. You will offend people by
doing that. If you want indentation to be hard tabs, please _enforce_
that, and disallow spaces. This is actually Guido's recommendation for
Python code. Most Unix-like editors are configured to display tabs as 8
spaces, and it is frustrating to keep changing that for different
languages.

When I write Python, I'll type 'if foo:' and when I hit [Return] my
cursor is automatically indented one level. It can do this because of the
standardized use of the ':' at the end of a line to indicate something is
expecting a block.

Having the editor auto-indent is often the quickest feedback that something
is syntaxically wrong. Of course, it doesn't mean quite as much in Python,
since the indentation _is_ what determines the nesting.

Dave
James G. Sack (jim)
2008-01-02 07:12:24 UTC
Permalink
Post by Chuck Esterbrook
Hi everybody,
I've created a programming language that could be described as a cross
between Python, Eiffel, Objective-C and C#. It runs on Linux, Mac and
Windows via Novell Mono or MS .NET.
More details on why I created it can be found in "Why Cobra?" at
http://cobralanguage.com/docs/why/
http://cobralanguage.com/docs/hello-world/
http://cobralanguage.com/docs/quality/
http://cobralanguage.com/docs/python/
I'm interested to hear your impressions, comments and questions.
Do I win $2.56? I found an "assert false" in Sizes:populateList() :-)
Here's another funny:
mono WordCount.exe file .. works
cobra wordcount file .. seems to give various error
(maybe there's something wrong w/ argument passing?)

But, it looks like an impressive accomplishment in what -- a little
under 1 year?

If you don't have something like it, some design "reflections" might be
a nice thing to write down before getting too much further along.

License: See Cobra/Docs/License.text
I can't find that. Maybe you're still deciding?

Hmmm, I suppose I might have to learn a bit about mono, after all.

Anyway, congratulations. I look forward to spending some time playing
with it.

Regards,
..jim
David M. Cook
2008-01-02 11:46:47 UTC
Permalink
Post by Chuck Esterbrook
I'm interested to hear your impressions, comments and questions.
Some impressive work. I really like the testing support.

Kind of hard to use a language without a reference manual, though.

Cobra uses method overloading instead of optional parameters? Or do we get
optional parameters, too?

One thing I don't like about generics is how nested angle brackets can tend
to accumulate and quickly make code difficult to read. So it would be nice
to have some kind of typedef. (I think I read that Java 7 will be getting
something like a typedef).

Dave Cook
Chuck Esterbrook
2008-01-02 16:50:55 UTC
Permalink
Post by David M. Cook
Post by Chuck Esterbrook
I'm interested to hear your impressions, comments and questions.
Some impressive work. I really like the testing support.
Thanks.
Post by David M. Cook
Kind of hard to use a language without a reference manual, though.
I agree more docs are needed, but I was hoping the How To's, Samples
and current docs could get people bootstrapped:
http://cobralanguage.com/how-to/
http://cobralanguage.com/samples/
http://cobralanguage.com/docs/manual/

Also the parser checks for some Python and C#/Java syntax and gives
specific error messages. Like if you say "int x" for a parameter, it
will remind you that the syntax is "x as int".
Post by David M. Cook
Cobra uses method overloading instead of optional parameters? Or do we get
optional parameters, too?
Right now just overloading. I'm in favor of optional parameters, but
haven't put any brain power into the design or implementation. There
are some bigger fish to fry like supporting events so you can write
GUIs.
Post by David M. Cook
One thing I don't like about generics is how nested angle brackets can tend
to accumulate and quickly make code difficult to read. So it would be nice
to have some kind of typedef. (I think I read that Java 7 will be getting
something like a typedef).
I think inheritance is sufficient:

class SymbolTable
inherits Dictionary<of String, Symbol>
pass

...

table = SymbolTable()


Though I admit it's not an alias.

-Chuck
David M. Cook
2008-01-02 18:23:36 UTC
Permalink
Post by Chuck Esterbrook
class SymbolTable
inherits Dictionary<of String, Symbol>
pass
...
table = SymbolTable()
Good enough for me. And the type inference elimimnates the

Foo foo = new Foo()

nonsense.

Dave Cook
John H. Robinson, IV
2008-01-02 17:22:22 UTC
Permalink
Post by Chuck Esterbrook
I've created a programming language that could be described as a cross
between Python, Eiffel, Objective-C and C#. It runs on Linux, Mac and
Windows via Novell Mono or MS .NET.
Does it support # style comments, so we can begin with
#!/usr/bin/cobra
?

On a personal note, COBOL-like whitespace significance is enough to turn
me off of a language that any other problem it has will prevent me from
using it.

I noticed that the POSIX ``compiler'' just creates a mono object. What
it the benefit of using the mono object, instead of calling the cobra
interpreter directly?

-john
Chuck Esterbrook
2008-01-02 19:00:31 UTC
Permalink
Post by John H. Robinson, IV
Post by Chuck Esterbrook
I've created a programming language that could be described as a cross
between Python, Eiffel, Objective-C and C#. It runs on Linux, Mac and
Windows via Novell Mono or MS .NET.
Does it support # style comments, so we can begin with
#!/usr/bin/cobra
?
Yes. I'm a Unix-like command line junkie.
Post by John H. Robinson, IV
On a personal note, COBOL-like whitespace significance is enough to turn
me off of a language that any other problem it has will prevent me from
using it.
I'm not familiar with COBOL's whitespace rules. I doubt they're identical.

Cobra simply requires that you indent blocks with one tab or 4 spaces.
Every professional programmer I know indents his code. And every
newbie programmer who writes this:

if (something) {
foo();
bar();
}

...gets schooled as soon as someone sees his code.
Post by John H. Robinson, IV
I noticed that the POSIX ``compiler'' just creates a mono object. What
it the benefit of using the mono object, instead of calling the cobra
interpreter directly?
mono is just a command line tool that runs .exe's made for the
.NET/Mono VM which is what comes out of Cobra. It's just a wee bit
faster when you already have the .exe.

You can say "cobra myprog.cobra" and forget about the mono "shortcut"
and "exe" if you prefer. Some people think like that. Other people
think about compilation and .exe's. Cobra can operate in both modes.

-Chuck
Christopher Smith
2008-01-02 19:16:23 UTC
Permalink
Post by Chuck Esterbrook
Cobra simply requires that you indent blocks with one tab or 4 spaces.
Wait, I thought you made a call on the tab-vs-spaces debate!

Now I'm thoroughly disappointed.

--Chris
Christopher Smith
2008-01-02 19:21:57 UTC
Permalink
Post by Christopher Smith
Post by Chuck Esterbrook
Cobra simply requires that you indent blocks with one tab or 4 spaces.
Wait, I thought you made a call on the tab-vs-spaces debate!
Now I'm thoroughly disappointed.
"Cobra may support space-based indentation in the future, if it is
determined that the TAB approach is too unfriendly to popular editors."

Now I'm thoroughly confused.

--Chris

Gus Wirth
2008-01-02 17:51:11 UTC
Permalink
Post by Chuck Esterbrook
Hi everybody,
I've created a programming language that could be described as a cross
between Python, Eiffel, Objective-C and C#. It runs on Linux, Mac and
Windows via Novell Mono or MS .NET.
More details on why I created it can be found in "Why Cobra?" at
http://cobralanguage.com/docs/why/
http://cobralanguage.com/docs/hello-world/
http://cobralanguage.com/docs/quality/
http://cobralanguage.com/docs/python/
I'm interested to hear your impressions, comments and questions.
On the comparison page on Python, you state "Cobra compiles down to
machine code right out of the box". That can't be true if you need Mono
or .NET. Did you mean to say it compiles down to CLR bytecode, or is
there some other reason you need Mono/.NET?

How does the language support distributed programming? Does it solve the
lock problem that Python has?

Gus
David Brown
2008-01-02 18:23:06 UTC
Permalink
Post by Gus Wirth
How does the language support distributed programming? Does it solve the
lock problem that Python has?
Which lock problem is that? I didn't find anything specific when
searching.

CLR has support for reflection-based distributed programming, so if Cobra
is complete enough, it should just be able to use that.

Doing distributed programming in Cobra could be very confusing with Corba.

Dave
Chuck Esterbrook
2008-01-02 18:53:19 UTC
Permalink
Post by David Brown
Post by Gus Wirth
How does the language support distributed programming? Does it solve the
lock problem that Python has?
Which lock problem is that? I didn't find anything specific when
searching.
Python's Global Interpreter Lock or GIL. Cobra has no such thing. Plus
its primitives (ints, chars, etc.) are boiled down to machine code. So
performance is quite good all around.
Post by David Brown
CLR has support for reflection-based distributed programming, so if Cobra
is complete enough, it should just be able to use that.
One of my goals for Cobra is high compatibility with .NET/Mono so that
you can vend libraries back out to C# and VB users and leverage any
third party tools. Consequently, Cobra generates C# classes for the
backend and makes their interfaces look as normal as possible. You can
do all the normal reflection stuff, use interfaces, etc.

-Chuck
Gus Wirth
2008-01-02 19:07:02 UTC
Permalink
Post by David Brown
Post by Gus Wirth
How does the language support distributed programming? Does it solve the
lock problem that Python has?
Which lock problem is that? I didn't find anything specific when
searching.
CLR has support for reflection-based distributed programming, so if Cobra
is complete enough, it should just be able to use that.
Doing distributed programming in Cobra could be very confusing with Corba.
Dave
http://www.kernel-panic.org/pipermail/kplug-lpsg/2007-September/006787.html

Gus
Christopher Smith
2008-01-02 19:13:42 UTC
Permalink
Post by David Brown
Doing distributed programming in Cobra could be very confusing with Corba.
CORBA was literally the first thing that popped in my head when I read
the original announcement. ;-)

--Chris
Christopher Smith
2008-01-02 17:57:29 UTC
Permalink
Post by Chuck Esterbrook
Hi everybody,
I've created a programming language that could be described as a cross
between Python, Eiffel, Objective-C and C#. It runs on Linux, Mac and
Windows via Novell Mono or MS .NET.
More details on why I created it can be found in "Why Cobra?" at
http://cobralanguage.com/docs/why/
http://cobralanguage.com/docs/hello-world/
http://cobralanguage.com/docs/quality/
http://cobralanguage.com/docs/python/
I'm interested to hear your impressions, comments and questions.
http://xblog.xman.org/articles/2008/01/02/now-someone-needs-to-make-a-language-called-mongoose

--Chris
Continue reading on narkive:
Loading...