Jump to content

Nu (programming language)

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Monkbot (talk | contribs) at 20:57, 3 January 2021 (Task 18 (cosmetic): eval 1 template: hyphenate params (1×);). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Nu
Paradigmstructured, imperative, functional, object-oriented
Designed byTim Burks
DeveloperTim Burks
First appeared2007; 17 years ago (2007)
Stable release
2.2.2 / April 17, 2017; 7 years ago (2017-04-17)
Typing disciplinedynamic
Platformx86
OSOS X
LicenseApache, v. 2.0
Websiteprogramming-nu.github.io
Influenced by
Lisp, Objective-C, Ruby

Nu is an interpreted object-oriented programming language, with a Lisp-like syntax, created by Tim Burks as an alternative scripting language to program OS X through its Cocoa application programming interface (API). Implementations also exist for iPhone and Linux.

The language was first announced at C4,[1] a conference for indie Mac developers held in August 2007.

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 code in Nu and the equivalent in Objective-C; it also shows the similarity with Ruby.

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

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

This sample, from the nuke tool bundled with Nu, also shows the influence of Objective-C, Lisp, and Ruby in the design of the language.

See also

References

  1. ^ "Burks: Bridges and Beyond". Archived from the original on 2011-05-14. Retrieved 2011-04-11.