Nu is an interpreted
object-oriented programming
Object-oriented programming (OOP) is a programming paradigm based on the concept of '' objects''. Objects can contain data (called fields, attributes or properties) and have actions they can perform (called procedures or methods and impl ...
language, with a
Lisp
Lisp (historically LISP, an abbreviation of "list processing") is a family of programming languages with a long history and a distinctive, fully parenthesized Polish notation#Explanation, prefix notation.
Originally specified in the late 1950s, ...
-like syntax, created by Tim Burks as an alternative scripting language to program
OS X through its
Cocoa application programming interface
An application programming interface (API) is a connection between computers or between computer programs. It is a type of software Interface (computing), interface, offering a service to other pieces of software. A document or standard that des ...
(API). Implementations also exist for
iPhone
The iPhone is a line of smartphones developed and marketed by Apple that run iOS, the company's own mobile operating system. The first-generation iPhone was announced by then–Apple CEO and co-founder Steve Jobs on January 9, 2007, at ...
and
Linux
Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
.
The language was first announced at
C4,
a conference for indie Mac developers held in August 2007.
Example code
This Nu code defines a simple
complex number
In mathematics, a complex number is an element of a number system that extends the real numbers with a specific element denoted , called the imaginary unit and satisfying the equation i^= -1; every complex number can be expressed in the for ...
s class.
(class Complex is NSObject
(ivar (double) real
(double) imaginary)
(- initWithReal:(double) x imaginary:(double) y is
(super init)
(set @real x)
(set @imaginary y)
self))
The example is a basic definition of a complex number: it defines the instance variables, and a method to initialize the object. It shows the similarity between the code in Nu and the equivalent in
Objective-C
Objective-C is a high-level general-purpose, object-oriented programming language that adds Smalltalk-style message passing (messaging) to the C programming language. Originally developed by Brad Cox and Tom Love in the early 1980s, it was ...
; it also shows the similarity with
Ruby
Ruby is a pinkish-red-to-blood-red-colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sapph ...
.
(unless @prefix
(set @prefix
"#.."))
(unless @icon_files
(set @icon_files
(array "#/share/nu/resources/nu.icns")))
This sample, from the ''nuke'' tool bundled with Nu, also shows the influence of
Objective-C
Objective-C is a high-level general-purpose, object-oriented programming language that adds Smalltalk-style message passing (messaging) to the C programming language. Originally developed by Brad Cox and Tom Love in the early 1980s, it was ...
,
Lisp
Lisp (historically LISP, an abbreviation of "list processing") is a family of programming languages with a long history and a distinctive, fully parenthesized Polish notation#Explanation, prefix notation.
Originally specified in the late 1950s, ...
, and
Ruby
Ruby is a pinkish-red-to-blood-red-colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sapph ...
in the design of the language.
See also
* F-Script
*
MacRuby
*
RubyCocoa
References
External links
*
* {{github, programming-nu/nu, Nu - Git repository
Lisp programming language family
Class-based programming languages
Free and open source compilers
Procedural programming languages
Object-oriented programming languages
Programming languages created in 2007