#? stdtmpl | standard #proc generateHTMLPage(c: var TConfigData, currentTab, title, content, rss, # rootDir = ""): string = # result = "" ${title} - $c.projectTitle #if len(rss) > 0: #end if
Fund Nim and help us develop it further!
# if currentTab == "index":
# else:
# end
# if currentTab == "index":

Nim is simple..

# compute average line length
var
  sum = 0
  count = 0

for line in stdin.lines:
  sum += line.len
  count += 1

echo("Average line length: ",
  if count > 0: sum / count else: 0)

..and type safe...

# create and greet someone
type Person = object
  name: string
  age: int

proc greet(p: Person) =
  echo "Hi, I'm ", p.name, "."
  echo "I am ", p.age, " years old."

let p = Person(name:"Jon", age:18)
p.greet() # or greet(p)

C FFI is easy in Nim..

# declare a C procedure..
proc unsafeScanf(f: File, s: cstring)
  {.varargs,
    importc: "fscanf",
    header: "<stdio.h>".}

# ..and use it...
var x: cint
stdin.unsafeScanf("%d", addr x)

Compile and run with:
    $ nim c -r example.nim

..and DSLs are too...

# a simple html server
import
  jester, asyncdispatch, htmlgen

routes:
  get "/":
    resp h1("Hello world")

runForever()

View in browser at:
    localhost:5000

# end
$content
# if currentTab == "index": # end if # if c.gaId != nil: # end if #end proc # # #proc generateSponsors(sponsors: seq[Sponsor]): string = #result = "" #for sponsor in sponsors:
#if sponsor.url.len > 0: ${sponsor.name} #else: ${sponsor.name} #end if
Donated $$${sponsor.thisMonth} this month
Donated $$${sponsor.allTime} in total since ${sponsor.since}
#end for #end proc #proc generateSponsorsPage(activeSponsors, inactiveSponsors: seq[Sponsor]): string = #result = ""

Our Current Sponsors

This section lists the companies and individuals that are, very kindly, contributing a monthly amount to help sustain Nim's development. For more details take a look at the Bountysource campaign.

Last updated: ${getTime().getGMTime().format("dd/MM/yyyy")}

${generateSponsors(activeSponsors)}
#

Our Past Sponsors

This section lists the companies and individuals that have contributed money in the past to help sustain Nim's development. For more details take a look at the Bountysource campaign.

${generateSponsors(inactiveSponsors)}
# #end proc