naru programming language

naru is a programming language designed for world domination. To the best extent of our knowledge, this didn’t happen yet. Until then this website is under construction.

This website is available in multiple locations:, and a part of 이 문서의 한국어판은 여기서 볼 수 있습니다.

1 No, srsly!

Seriously, naru is a programming language being designed by Kang Seonghoon since 2005, and still in development. (“naru” is pronounced NAH-roo, and always written in lower case.) It has several major goals:

Reasonable expressiveness and conciseness

Expressiveness and conciseness often harm each other; more features you put in, less concise the resulting code is. naru provides the reasonable trade-off between them. (And the solution is not a lisp way—sorry, but s-expression is a bit too much.)

The Right Way to do things by default

Many users follow the default choice laid by the language designer (both unknowingly or intentionally), so the default choice is very important. For example, you may assume that one char maps to one real character in languages that do not support Unicode, but that’s not correct. (And this is similar even in languages with Unicode string.) naru makes the right way to do things much easier, so users actually do the right thing by following the simplest path.

Minding the gaps between static languages and dynamic languages

While static languages and dynamic languages are not complementary to each other, it is quite hard to see languages at the middle between them. That is because they do not offer advantages of two kinds of languages: performance, reliability and correctness (well, with a good typechecker) for static languages, expressiveness, rapid and easy development for dynamic languages. naru tries to provide both advantages.

The designer’s personal preference

Well, the syntax, for example, somewhat resembles Python and Ruby because the author is familiar to them. But many other aspects are originated from other languages (e.g. whitespace as a method/property access is inspired from ooc), or entirely new (e.g. with). Since the author prefers cleaner and intuitive (read: so obvious that mistake is impossible) design, it is well reflected in the language design.

So far, naru has underwent several revisions in order to meet these various goals (the current one is named revision 4). No implementation is available currently, but once the rough design is finished, the reference implementation will surface.

2 What will it look like?

This snippet implements a basic version of PHP’s getimagesize function:

use naru

ImageType := type (:png | :gif | :jpeg)

(-- Returns a tuple of image type, width and height for given image stream, or
    none if any error is occurred. Supports PNG, GIF (both 87a and 89a) and
    JPEG (JFIF only) for now. --)
imagesize(f: Reader) -> (ImageType,Int,Int)? := fun
    imgtype: Option{ImageType} = none

    f position = 0
    header = f read(24)
    if header length != 24 then return none end    -- too short!

    if header[..!8] == b"\x89PNG\x0d\x0a\x1a\x0a" then
        width, height = header[16..!24] asInt32(:big)
        imgtype = :png
    elseif header[..!6] in {b"GIF87a", b"GIF89a"} then
        width, height = header[6..!10] asUInt16(:little)
        imgtype = :gif
    elseif header[..!4] == b"\xff\xd8\xff\xe0" and header[6..!10] == b"JFIF" then
        blockgen() := fun
            f position = 2
            while f eof
                f skipwhile(0xff)
                blocktype, blocksize = f read(3) unpack([UInt8, UInt16], :big)
                savedpos = f position
                yield blocktype, blocksize
                f position = savedpos + blocksize - 2   -- 2 for blocksize

        -- filter out the SOFn block
        sofns = blockgen() map(fun (t, _) -> 0xc0 <= t <= 0xcf)
        for _ <- sofns
            -- ignore precision byte
            _, height, width = f read(5) unpack([Int8, UInt16, UInt16], :big)
            imgtype = :jpeg

    if t <- imgtype then
        return (t, width, height)
        return none

(-- Shortcut for imagesize(Reader). --)
imagesize(filename: String) := \
    fun -> imagesize(File(filename) open())

(-- Returns a suitable XHTML text for given image file. It may return the invalid XHTML
    (i.e. no width/height attributes) when the automatic size detection is failed. --)
htmlize(filename: String, alt: String = "") := fun
    escape(s) := fun s -> s replace("&", "&amp;") replace("<", "&lt;") replace(">", "&gt;")
        _, width, height = imagesize(filename)
        return #"""<img src="#(escape(filename))" width="#width" height="#height"
                        alt="#(escape(alt))" />"""
        -- no dimension information available
        return #"""<img src="#(escape(filename))" alt="#(escape(alt))" />"""

Note that nothing in this code is finalized yet.

3 Okay, it looks promising. Where to start?

Follow the links below:

3.1 List of Documents

Articles and reports for naru revision 4:

Obsolete articles and reports for naru:

3.2 Discussion

The official IRC channel for naru is #naru at Ozinger IRC network.