Version 1 of Nim Programming Language

Updated 2015-06-14 21:11:43 by AMG

Nim (formerly Nimrod) is a statically typed, imperative programming language that tries to give the programmer ultimate power without compromising runtime efficiency. It is designed to rival C in execution speed.

It supports soft realtime garbage collection on thread-local heaps and uses asynchronous message passing between threads. There are language features for parallelizing functions via a binding to OpenMP. It has system programming features such as direct access to memory. Pointers to garbage collected memory are distinguished from pointers to manually managed memory.

It compiles to commented C code. The compiler can create standard shared libraries linkable from C programs. It can also be made to output JavaScript, C++ or Objective C.

The Nim distribution contains an officially supported wrapper for Tcl that makes calling Tcl code from Nim code easy. Example:

# Example to embed TCL in Nim

import tcl, os

const
  myScript = """puts "Hello, World - In quotes" """
  myScript2 = """
package require Tk
pack [entry .e -textvar e -width 50]
bind .e <Return> {
set e [regsub { *=.*} $e ""] ;# remove evaluation (Chris)
catch {expr [string map {/ *1./} $e]} res
append e " = $res"
}
"""

FindExecutable(getAppFilename())
var interp = CreateInterp()
if interp == nil: quit("cannot create TCL interpreter")
if Init(interp) != TCL_OK:
  quit("cannot init interpreter")
if tcl.Eval(interp, myScript) != TCL_OK:
  quit("cannot execute script.tcl")