Nu (programming Language) - Example Code

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 code; 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 snippet, from the nuke tool bundled with Nu, also shows the influence of Objective-C, Lisp, and Ruby in the design of the language.

Read more about this topic:  Nu (programming Language)

Famous quotes containing the word code:

    Many people will say to working mothers, in effect, “I don’t think you can have it all.” The phrase for “have it all” is code for “have your cake and eat it too.” What these people really mean is that achievement in the workplace has always come at a price—usually a significant personal price; conversely, women who stayed home with their children were seen as having sacrificed a great deal of their own ambition for their families.
    Anne C. Weisberg (20th century)

    Hollywood keeps before its child audiences a string of glorified young heroes, everyone of whom is an unhesitating and violent Anarchist. His one answer to everything that annoys him or disparages his country or his parents or his young lady or his personal code of manly conduct is to give the offender a “sock” in the jaw.... My observation leads me to believe that it is not the virtuous people who are good at socking jaws.
    George Bernard Shaw (1856–1950)