Cobra (programming language)

{{Short description|Discontinued programming language}}

{{Infobox programming language

| name = Cobra

| logo =

| paradigm = Multi-paradigm: object-oriented

| discontinued = yes

| year = {{Start date and age|2006}}

| designer = Charles Esterbrook

| developer = Cobra Language LLC

| latest_release_version = 0.9.6

| latest_release_date = {{Start date and age|2013|12|23}}

| latest_test_version =

| latest_test_date =

| typing = strong, static, dynamic, inferred

| influenced_by =

Python, Eiffel, C#, Objective-C

| operating_system = Microsoft .NET, Mono

|

| website = {{url|http://cobra-language.com/}}

| license = MIT

| file_ext = .cobra

}}

{{Portal|Free and open-source software}}

Cobra is a discontinued general-purpose, object-oriented programming language.{{cite web|url=http://cobra-language.com|title=The Cobra Programming Language|publisher=Cobra Language LLC|accessdate=2012-09-26}} Cobra is designed by Charles Esterbrook, and runs on the Microsoft .NET and Mono platforms.{{cite video |people=Charles Esterbrook |date=Jan 28, 2008 |title=Lang.NET Symposium 2008 – The Cobra Programming Language |url=https://www.facultyresourcecenter.com/curriculum/pfv.aspx?ID=7259 |format=wmv |publisher=Microsoft |accessdate=2010-08-31 |archive-url=https://web.archive.org/web/20090326203941/http://www.facultyresourcecenter.com/curriculum/pfv.aspx?ID=7259 |archive-date=March 26, 2009 |url-status=dead }} It is strongly influenced by Python, C#, Eiffel, Objective-C, and other programming languages.{{cite news|url=http://www.zdnet.co.uk/news/application-development/2008/03/05/cobra-takes-a-bite-at-open-source-39362140/|title=Cobra takes a bite at open source |last=Bridgwater|first=Adrian|date=5 March 2008|work=ZDNet UK|accessdate=2010-08-31}} It supports both static and dynamic typing.{{cite journal|last=Neward|first=Ted|date=June 2009|title=Reaping the Benefits of Cobra|journal=MSDN Magazine|url=http://msdn.microsoft.com/en-us/magazine/dd882513.aspx}}{{cite journal|last=Erickson|first=Jonathan|date=April 2008|title=Was George Costanza a Computer Programmer?|journal=Dr. Dobb's Journal|url=http://www.ddj.com/architect/207400254}} It has support for unit tests and contracts. It has lambda expressions, closures, list comprehensions, and generators.{{cite journal|last=Morris|first=Richard|date=April 2010|title=Chuck Esterbrook: Geek of the Week|journal=Simple-talk|url=http://www.simple-talk.com/opinion/geek-of-the-week/chuck-esterbrook-geek-of-the-week/}}

Cobra is an open-source project; it was released under the MIT License on February 29, 2008.{{cite news|url=http://www.infoworld.com/d/developer-world/cobra-language-slithering-open-source-202|title=Cobra language slithering to open source|last=Krill|first=Paul|date=Feb 7, 2008|work=InfoWorld|accessdate=2010-08-31}}{{cite web|url=http://cobra-language.com/downloads/source/ |title=The Cobra Programming Language |accessdate=2008-02-29|publisher=Cobra Language LLC}}

Features

;Object-oriented:

:* Namespaces

:* Classes, interfaces, structs, extensions, enumerations

:* Methods, properties, indexers

:* Mixins, extension methods

:* Generics, attributes

;Quality control:

:* Contracts, assertions

:* Unit tests, docstrings

:* Compile-time nil-tracking

;Expressiveness:

:* Static and dynamic binding

:* List, dictionary, and set literals

:* in and implies operator

:* for expressions

:* Slicing

:* Interpolated strings

:* Compile-time type inference

:* Lambdas and closures

;General productivity:

:* Exception handling

:* Postmortem exception report

:* Garbage collection

;Scripting conveniences:

:* Clean syntax

:* Dynamic binding

:* One-step run

:* Shebang line (#!)

;Miscellaneous:

:* Documentation tool (cobra -doc)

:* Syntax highlighting tool (cobra -highlight)

Examples

The following examples can be run from a file using cobra <filename>.

=[["Hello, World!" program|Hello World]]=

class Hello

def main

print 'HELLO WORLD'

=A simple class=

class Person

var _name as String

var _age as int

cue init(name as String, age as int)

_name, _age = name, age

def toString as String is override

return 'My name is [_name] and I am [_age] years old.'

References

{{Reflist}}