Nu (programming language)
Encyclopedia
Nu is an interpreted object-oriented programming
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...

 language, with a Lisp-like syntax, created by Tim Burks as an alternative scripting language to program Mac OS X
Mac OS X
Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

 through its Cocoa
Cocoa (API)
Cocoa is Apple's native object-oriented application programming interface for the Mac OS X operating system and—along with the Cocoa Touch extension for gesture recognition and animation—for applications for the iOS operating system, used on Apple devices such as the iPhone, the iPod Touch, and...

 application programming interface
Application programming interface
An application programming interface is a source code based specification intended to be used as an interface by software components to communicate with each other...

 (API). Implementations also exist for Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

, and iPhone
IPhone
The iPhone is a line of Internet and multimedia-enabled smartphones marketed by Apple Inc. The first iPhone was unveiled by Steve Jobs, then CEO of Apple, on January 9, 2007, and released on June 29, 2007...

.

The language was first announced at C4
C4 (conference)
C4 was a Macintosh software developers conference held in Chicago, Illinois. The conference ran from 2006 through 2009. It was created by Jonathan Rentzsch after the demise of MacHack...

, a conference for indie Mac developers held in August 2007.

Although being for the moment confined as a niche tool, possibly because of its Lisp-like syntax, it is generally considered stable, and is notable as part of a recent rise in use of functional programming languages.

Example code

This Nu code defines a simple complex numbers 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 Nu code and the equivalent Objective-C
Objective-C
Objective-C is a reflective, object-oriented programming language that adds Smalltalk-style messaging to the C programming language.Today, it is used primarily on Apple's Mac OS X and iOS: two environments derived from the OpenStep standard, though not compliant with it...

 code; it also shows the similarity with Ruby
Ruby (programming language)
Ruby is a dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. Ruby originated in Japan during the mid-1990s and was first developed and designed by Yukihiro "Matz" Matsumoto...

.


(unless @prefix
(set @prefix
"#{((((NSProcessInfo processInfo) arguments) 0) dirName)}.."))

(unless @icon_files
(set @icon_files
(array "#{@prefix}/share/nu/resources/nu.icns")))


This snippet, from the nuke tool bundled with Nu, also shows the influence of Objective-C
Objective-C
Objective-C is a reflective, object-oriented programming language that adds Smalltalk-style messaging to the C programming language.Today, it is used primarily on Apple's Mac OS X and iOS: two environments derived from the OpenStep standard, though not compliant with it...

, Lisp, and Ruby
Ruby (programming language)
Ruby is a dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. Ruby originated in Japan during the mid-1990s and was first developed and designed by Yukihiro "Matz" Matsumoto...

 in the design of the language.

See also

  • F-Script (programming language)
  • MacRuby
    MacRuby
    MacRuby is an implementation of the Ruby language that runs on the Objective-C runtime and CoreFoundation framework under development by Apple Inc. which "is supposed to replace RubyCocoa". It is based on Ruby 1.9 and uses the high performance Low Level Virtual Machine compiler infrastructure...

  • RubyCocoa
    RubyCocoa
    RubyCocoa is a Mac OS X framework that provides a bridge between the Ruby and the Objective-C programming languages, allowing the user to manipulate Objective-C objects from Ruby, and vice-versa. It makes it possible to write a Cocoa application completely in Ruby as well as to write an application...


External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK