Friday, October 5, 2012

COBRA


      Cobra is a general purpose programming language with a clean, high-level syntax. It provides language level features for quality, including first class unit tests and Eiffel-style contracts. It supports both static and dynamic binding. Cobra is a compiled language with good run-time performance, but also provides some scripting conveniences such as a pound-bang line (#!) and one step compile-and-run. Cobra runs on Linux, Mac, Windows, and anywhere else that Novell Mono or MS .NET exist, including handhelds.

Sample Hello World Program:


class Hello
def main
print 'Hello, World'

FEATURES:

  • Functions as first class objects. All of the examples are inside of classes, which just seems silly. I also haven’t seen the syntax for passing a function around (can you even do that?) This is a powerful feature.
  • Metaclasses don’t seem to exist in Cobra. You don’t need them all the time, but you can make some APIs a lot nicer if you use them when appropriate.
  • Function parameter declaration is weaker. Function parameter capabilities seem to be the same as in any other .NET language. It allows you to have variable arguments, but that’s about as fancy as you can get.
  • Objects are not extensible. You can’t just go and hang random attributes off of an object, and there are actually some times when this is convenient to do.
  • OOP and friends:
    • classes, interfaces, structs
    • methods, properties, indexers
    • mixins, extension methods
    • generics, attributes
  • Quality control:
    • contracts, assertions
    • unit tests, doc strings
    • compile-time nil tracking
  • Expressiveness:
    • static and dynamic binding
    • literals for lists, dictionaries and sets
    • in and implies operators
    • for and if expressions
    • slicing
    • interpolated strings
    • compile-time type inference
    • lambdas and closures
  • General productivity:
    • exception handling
    • postmortem exception report
    • garbage collection
  • Scripting conveniences
    • clean syntax
    • one step run
    • pound-bang line (#!)
  • Compiled language performance

Comment:

  • Cobra is a mixed-bag. It is heavily influenced and similar to python and their names say it for themselves.
Mher John A. Pacheca 
2010-19289


http://freecode.com/projects/cobra-language
http://www.blueskyonmars.com/2008/02/08/cobra-programming-language/
http://cobra-language.com/docs/why/

No comments:

Post a Comment