Page 1 of 4

New to the Cobra

PostPosted: Thu Mar 22, 2012 6:29 pm
by Charles
The following was posted as a reply to one of the sticky threads:
Hi,

My name is Gianni.
I am new to the Cobra programming language and
I have some questions;

1. Like, Python, does Cobra cover everything/or most in programming?

2. Is Cobra easy to learn?

3. Can you use Cobra in Databases?

Thanks//

Gianni

1. Yes to full featured. See LanguageTopics and OtherLanguages for starters.

2. Cobra is easy to learn if you are already familiar with an object-oriented, imperative language such as Python, Ruby, C#, Java, etc. If you are new to programming, we do not have "total beginner" instructional material at this point.

3. Yes to databases. See for example, SetUpMySqlOnUnixLike.

Re: New to the Cobra

PostPosted: Fri Apr 13, 2012 5:13 pm
by DelphiGuy
Charles:

I'm a pretty bad but tenacious Delphi programmer, with very little understanding of some advanced general programming concepts, so please bear with me.

I'm porting legacy code to .net , and prefer to let go of Delphi altogether and move to C#. My long term intention is to write for win and mono on the mac, and try to use the same basic code for the engine part of my app to run under monotouch for iOS. Your arguments about the advantages of Cobra sound enticing enough to me to consider using it as my main language, but as a beginner I'm frankly intimidated by the lack of an IDE and integrated debugger.

I completely believe you that coding under Cobra would be substantially more concise and more productive, but if that's offset by my struggling with debugging then obviously Cobra is better suited to knowledgable programmers at this stage of its growth.

Can Cobra run under Mono, Monomac, Monotouch? I gather that dynamic binding is unavailable under Monotouch/iOS. Is that a problem for Cobra, or is the solution as simple as not using the dynamic binding parts of the language?

Any comments you have on any of my thoughts above would be much appreciated.

Have any comm'l apps been written with Cobra? Any iOS apps?

Finally, I see old posts about Cobra on Google saying that Cobra is really a preprocessor for C#, the Cobra code is automatically converted to C# and then the C# must be compiled. If that ever was true, is it still?

Thanks, Charles. I am very appreciative of your obvious long and hard thought about creating an optimal balance of language strengths, but what is even more amazing is that you sat down and wrote an entire new language to implement the ideas.

Best,

Paul

Re: New to the Cobra

PostPosted: Sun Apr 15, 2012 3:01 pm
by Charles
Hi Paul,

For IDE support, check out Visual Cobra. If you have feedback on the experience, please contact Matthew Strawbridge who maintains it.

Unfortunately, we don't have autocomplete/intellisense at this time, which is annoying. It's on my radar to provide a library to support it, but I don't have a timeline.

I feel fairly comfortable with debugging for which we have multiple options described at DebuggingTopics.

Cobra definitely runs under Mono. MonoMac is a library which Cobra can use like any other. I wish we had a sample for it like we do the other GUI frameworks, but we don't just yet. Btw I do most of my Cobra development on the Mac.

Re: dynamic binding, Cobra implements it's own even under .NET 2.0, so you do not need .NET 4.0 to use it like you do with C#.

I don't know that anyone has attempted to get Cobra working with iOS/MonoTouch.

There has been contract-based work in Cobra, but I'm not aware of any public commerical apps. Of course, there are plenty for .NET whose coattails Cobra rides on.

Re: C#, yes, Cobra uses other high level languages as it's back-end. We have a working C# back-end and a Java one under development thanks to Hops. I stubbed out an Objective-C one, but never have time to work on it. Based on the recent survey, it looks like the C# and Java back-ends will continue to be the focus.

You're welcome regarding Cobra. If you continue to investigate it, please share your impressions and feedback.

Best regards,
Charles

Re: New to the Cobra

PostPosted: Sun Apr 15, 2012 8:34 pm
by Charles
Btw I forgot to mention I'm an old hand at Turbo Pascal which was the predecessor to Delphi. Back in the day. 8-)

Re: New to the Cobra

PostPosted: Mon Apr 16, 2012 2:15 am
by DelphiGuy
Charles:

Please forgive the cross-posting to stackoverflow today, but i suspect that because i added to an ancient thread i will never hear a response:

"cobra is essentially a C# (and java) preprocessor, so how would cobra (or any other non-monotouch-aware .net lang) know how to preprocess the non-.net function calls made available by monotouch? wouldn't cobra's compiler rightly reject a bunch of unknown function calls rather than pass them through to the back-end C# code that cobra's compiler generates?"

on another topic, although i don't yet really understand what dynamic binding vs static binding is, i believe that monotouch (well, actually iOS) requires all static binding. you said that the dynamic binding is implemented in cobra itself, so from the point of view of cobra's C# back end, and ultimately monotouch and native iOS code, is there dynamic binding that the ultimate targets would even know about?

thanks.

- paul

Re: New to the Cobra

PostPosted: Mon Apr 16, 2012 3:47 am
by DelphiGuy
charles:

is preprocessing, with C# as the back end the way most langs are written? or do some of the .net langs actually bypass C# and instead compile directly to whatever intermediate code runs directly on .net?

i'd think that compiling to C# would be so easy to understand (though i'm sure quite challenging to implement), that that would be the route that .net language developers would generally take. yes?

-paul

Re: New to the Cobra

PostPosted: Mon Apr 16, 2012 9:25 am
by Charles
You are over-thinking the whole "preprocessing" thing which isn't even the word I would use anyway. Cobra is a compiler with a lexer, parser, symbol tables, code analysis, error checking, etc. at the end of which some other code must be generated such as:

1. machine code
2. assembly code
3. virtual machine code
4. another language that is higher level than 1 - 3

Cobra does 4 for various benefits. For example, it helps ensure that the programs it produces are .NET friendly and that any libraries can be easily consumed by other .NET developers whether they are on C#, VB or whatever.

But you don't need to be aware of it or contemplate the consequences. If Cobra was doing 3 there would be no difference in syntax or semantics to Cobra programmers.

The reason I would not call it a "preprocessor" is that the term is usually applied to situations where the user still has to think in terms of what comes after the preprocessor, as is the case for the ANSI C preprocessor. It does not encapsulate C, it just adds some goodies.

Re: dynamic binding, Cobra implements it using the elements that are .NET 2.0, namely System.Reflection. If System.Reflection is not available in iOS then yes, you will need to use all static types.

Re: New to the Cobra

PostPosted: Mon Apr 16, 2012 9:30 am
by Charles
DelphiGuy wrote:is preprocessing, with C# as the back end the way most langs are written? or do some of the .net langs actually bypass C# and instead compile directly to whatever intermediate code runs directly on .net?

i'd think that compiling to C# would be so easy to understand (though i'm sure quite challenging to implement), that that would be the route that .net language developers would generally take. yes?

I haven't done a survey to see what technique most .NET compilers are using. I did observe that one language was generating bytecode directly, but that the users often reported various problems related to that such as bugs, lack of support for generics, etc. which then took quite a bit of time to work out--longer than if the generated code was C#.

Since Cobra was developed there is a more mature alternative called Cecil that could be suitable, but swapping out the back-end (~5000 raw lines of Cobra) is a bigger project than making other kinds of improvements.

Re: New to the Cobra

PostPosted: Mon Apr 16, 2012 7:23 pm
by DelphiGuy
"Cecil was a research language, with an implementation that worked for the research team but was difficult to use externally. It hasn't been touched in quite a while." - Craig Chambers, inventor of Cecil.

Re: New to the Cobra

PostPosted: Mon Apr 16, 2012 8:53 pm
by Charles