HOME

TheInfoList



OR:

Cobra is a discontinued general-purpose,
object-oriented Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code. The data is in the form of fields (often known as attributes or ''properties''), and the code is in the form of ...
programming language A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming ...
. Cobra is designed by Charles Esterbrook, and runs on the
Microsoft .NET The Microsoft .NET strategy is a marketing plan that Microsoft followed in the early 2000s. Steve Ballmer described it as the company's "most ambitious undertaking since Internet Strategy Day in 1995". In support of this strategy, between 2000 and ...
and
Mono Mono may refer to: Common meanings * Infectious mononucleosis, "the kissing disease" * Monaural, monophonic sound reproduction, often shortened to mono * Mono-, a numerical prefix representing anything single Music Performers * Mono (Japanes ...
platforms. It is strongly influenced by Python, C#, Eiffel,
Objective-C Objective-C is a general-purpose, object-oriented programming language that adds Smalltalk-style messaging to the C programming language. Originally developed by Brad Cox and Tom Love in the early 1980s, it was selected by NeXT for its NeXT ...
, and other programming languages. It supports both static and dynamic typing. It has support for unit tests and contracts. It has lambda expressions, closures, list comprehensions, and generators. Cobra is an
open-source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use the source code, design documents, or content of the product. The open-source model is a decentralized so ...
project; it was released under the
MIT License The MIT License is a permissive free software license originating at the Massachusetts Institute of Technology (MIT) in the late 1980s. As a permissive license, it puts only very limited restriction on reuse and has, therefore, high license comp ...
on February 29, 2008.


Features

;Object-oriented: :* Namespaces :*
Class Class or The Class may refer to: Common uses not otherwise categorized * Class (biology), a taxonomic rank * Class (knowledge representation), a collection of individuals or objects * Class (philosophy), an analytical concept used differently ...
es, interfaces, structs, extensions, enumerations :* Methods, properties, indexers :* Mixins, extension methods :*
Generics Generic or generics may refer to: In business * Generic term, a common name used for a range or class of similar things not protected by trademark * Generic brand, a brand for a product that does not have an associated brand or trademark, other ...
, attributes ;Quality control: :*
Contracts A contract is a legally enforceable agreement between two or more parties that creates, defines, and governs mutual rights and obligations between them. A contract typically involves the transfer of goods, services, money, or a promise to tr ...
, 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 Type inference refers to the automatic detection of the type of an expression in a formal language. These include programming languages and mathematical type systems, but also natural languages in some branches of computer science and linguistic ...
:* Lambdas and closures ;General productivity: :*
Exception handling In computing and computer programming, exception handling is the process of responding to the occurrence of ''exceptions'' – anomalous or exceptional conditions requiring special processing – during the execution of a program. In general, an ...
:* Postmortem exception report :*
Garbage collection Waste collection is a part of the process of waste management. It is the transfer of solid waste from the point of use and disposal to the point of treatment or landfill. Waste collection also includes the curbside collection of recyclabl ...
; 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

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 A name is a term used for identification by an external observer. They can identify a class or category of things, or a single thing, either uniquely, or within a given context. The entity identified by a name is called its referent. A persona ...
and I am ageyears old'


References


External links

*
The Cobra blog
by Charles Esterbrook
Cobra News Index
{{Common Language Infrastructure .NET programming languages Object-oriented programming languages Programming languages created in 2006 Software using the MIT license