Cobra (programming language)

Last updated
Cobra
Paradigm Multi-paradigm: object-oriented
Designed by Charles Esterbrook
Developer Cobra Language LLC
First appeared2006;18 years ago (2006)
Final release
0.9.6 / December 23, 2013;10 years ago (2013-12-23)
Typing discipline strong, static, dynamic, inferred
OS Microsoft .NET, Mono
License MIT
Filename extensions .cobra
Website cobra-language.com
Influenced by
Python, Eiffel, C#, Objective-C

Cobra is a discontinued general-purpose, object-oriented programming language. [1] Cobra is designed by Charles Esterbrook, and runs on the Microsoft .NET and Mono platforms. [2] It is strongly influenced by Python, C#, Eiffel, Objective-C, and other programming languages. [3] It supports both static and dynamic typing. [4] [5] It has support for unit tests and contracts. [4] It has lambda expressions, closures, list comprehensions, and generators. [6]

Contents

Cobra is an open-source project; it was released under the MIT License on February 29, 2008. [7] [8]

Features

Object-oriented
Quality control
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
Scripting conveniences
  • Clean syntax
  • Dynamic binding
  • One-step run
  • Shebang line (#!)
Miscellaneous

Examples

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

Hello World

classHellodefmainprint'HELLO WORLD'

A simple class

classPersonvar_nameasStringvar_ageasintcueinit(nameasString,ageasint)_name,_age=name,agedeftoStringasStringisoverridereturn'My name is [_name] and I am [_age] years old.'

Related Research Articles

In computer programming, the scope of a name binding is the part of a program where the name binding is valid; that is, where the name can be used to refer to the entity. In other parts of the program, the name may refer to a different entity, or to nothing at all. Scope helps prevent name collisions by allowing the same name to refer to different objects – as long as the names have separate scopes. The scope of a name binding is also known as the visibility of an entity, particularly in older or more technical literature—this is in relation to the referenced entity, not the referencing name.

In programming languages, a closure, also lexical closure or function closure, is a technique for implementing lexically scoped name binding in a language with first-class functions. Operationally, a closure is a record storing a function together with an environment. The environment is a mapping associating each free variable of the function with the value or reference to which the name was bound when the closure was created. Unlike a plain function, a closure allows the function to access those captured variables through the closure's copies of their values or references, even when the function is invoked outside their scope.

In programming languages, name binding is the association of entities with identifiers. An identifier bound to an object is said to reference that object. Machine languages have no built-in notion of identifiers, but name-object bindings as a service and notation for the programmer is implemented by programming languages. Binding is intimately connected with scoping, as scope determines which names bind to which objects – at which locations in the program code (lexically) and in which one of the possible execution paths (temporally).

<span class="mw-page-title-main">F Sharp (programming language)</span> Microsoft programming language

F# is a general-purpose, strongly typed, multi-paradigm programming language that encompasses functional, imperative, and object-oriented programming methods. It is most often used as a cross-platform Common Language Infrastructure (CLI) language on .NET, but can also generate JavaScript and graphics processing unit (GPU) code.

In mathematics and computer science, a higher-order function (HOF) is a function that does at least one of the following:

<span class="mw-page-title-main">Apache Groovy</span> Programming language

Apache Groovy is a Java-syntax-compatible object-oriented programming language for the Java platform. It is both a static and dynamic language with features similar to those of Python, Ruby, and Smalltalk. It can be used as both a programming language and a scripting language for the Java Platform, is compiled to Java virtual machine (JVM) bytecode, and interoperates seamlessly with other Java code and libraries. Groovy uses a curly-bracket syntax similar to Java's. Groovy supports closures, multiline strings, and expressions embedded in strings. Much of Groovy's power lies in its AST transformations, triggered through annotations.

In computer programming, a function object is a construct allowing an object to be invoked or called as if it were an ordinary function, usually with the same syntax. In some languages, particularly C++, function objects are often called functors.

This article compares two programming languages: C# with Java. While the focus of this article is mainly the languages and their features, such a comparison will necessarily also consider some features of platforms and libraries. For a more detailed comparison of the platforms, see Comparison of the Java and .NET platforms.

<span class="mw-page-title-main">C Sharp (programming language)</span> Programming language

C# is a general-purpose high-level programming language supporting multiple paradigms. C# encompasses static typing, strong typing, lexically scoped, imperative, declarative, functional, generic, object-oriented (class-based), and component-oriented programming disciplines.

<span class="mw-page-title-main">Scala (programming language)</span> General-purpose programming language

Scala is a strong statically typed high-level general-purpose programming language that supports both object-oriented programming and functional programming. Designed to be concise, many of Scala's design decisions are intended to address criticisms of Java.

<span class="mw-page-title-main">Python syntax and semantics</span> Set of rules defining correctly structured programs

The syntax of the Python programming language is the set of rules that defines how a Python program will be written and interpreted. The Python language has many similarities to Perl, C, and Java. However, there are some definite differences between the languages. It supports multiple programming paradigms, including structured, object-oriented programming, and functional programming, and boasts a dynamic type system and automatic memory management.

Haxe is a high-level cross-platform programming language and compiler that can produce applications and source code for many different computing platforms from one code-base. It is free and open-source software, released under the MIT License. The compiler, written in OCaml, is released under the GNU General Public License (GPL) version 2.

In computer programming, an anonymous function is a function definition that is not bound to an identifier. Anonymous functions are often arguments being passed to higher-order functions or used for constructing the result of a higher-order function that needs to return a function. If the function is only used once, or a limited number of times, an anonymous function may be syntactically lighter than using a named function. Anonymous functions are ubiquitous in functional programming languages and other languages with first-class functions, where they fulfil the same role for the function type as literals do for other data types.

This article describes the syntax of the C# programming language. The features described are compatible with .NET Framework and Mono.

The syntax and semantics of PHP, a programming language, form a set of rules that define how a PHP program can be written and interpreted.

The programming language C# version 3.0 was released on 19 November 2007 as part of .NET Framework 3.5. It includes new features inspired by functional programming languages such as Haskell and ML, and is driven largely by the introduction of the Language Integrated Query (LINQ) pattern to the Common Language Runtime. It is not currently standardized by any standards organisation.

Nemerle is a general-purpose, high-level, statically typed programming language designed for platforms using the Common Language Infrastructure (.NET/Mono). It offers functional, object-oriented, aspect-oriented, reflective and imperative features. It has a simple C#-like syntax and a powerful metaprogramming system.

Xtend is a general-purpose high-level programming language for the Java Virtual Machine. Syntactically and semantically Xtend has its roots in the Java programming language but focuses on a more concise syntax and some additional functionality such as type inference, extension methods, and operator overloading. Being primarily an object-oriented language, it also integrates features known from functional programming, e.g. lambda expressions. Xtend is statically typed and uses Java's type system without modifications. It is compiled to Java code and thereby seamlessly integrates with all existing Java libraries.

Objective-C is a high-level 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 NeXTSTEP operating system. Due to Apple macOS’s direct lineage from NeXTSTEP, Objective-C was the standard programming language used, supported, and promoted by Apple for developing macOS and iOS applications until the introduction of the Swift programming language in 2014.

<span class="mw-page-title-main">Nim (programming language)</span> Programming language

Nim is a general-purpose, multi-paradigm, statically typed, compiled high-level systems programming language, designed and developed by a team around Andreas Rumpf. Nim is designed to be "efficient, expressive, and elegant", supporting metaprogramming, functional, message passing, procedural, and object-oriented programming styles by providing several features such as compile time code generation, algebraic data types, a foreign function interface (FFI) with C, C++, Objective-C, and JavaScript, and supporting compiling to those same languages as intermediate representations.

References

  1. "The Cobra Programming Language". Cobra Language LLC. Retrieved 2012-09-26.
  2. Charles Esterbrook (Jan 28, 2008). Lang.NET Symposium 2008 – The Cobra Programming Language. Microsoft. Archived from the original (wmv) on March 26, 2009. Retrieved 2010-08-31.
  3. Bridgwater, Adrian (5 March 2008). "Cobra takes a bite at open source". ZDNet UK. Retrieved 2010-08-31.
  4. 1 2 Neward, Ted (June 2009). "Reaping the Benefits of Cobra". MSDN Magazine.
  5. Erickson, Jonathan (April 2008). "Was George Costanza a Computer Programmer?". Dr. Dobb's Journal .
  6. Morris, Richard (April 2010). "Chuck Esterbrook: Geek of the Week". Simple-talk.
  7. Krill, Paul (Feb 7, 2008). "Cobra language slithering to open source". InfoWorld . Retrieved 2010-08-31.
  8. "The Cobra Programming Language". Cobra Language LLC. Retrieved 2008-02-29.