All BASIC

Message Boards => Translators => Topic started by: John on September 22, 2013, 08:02:34 PM

Title: Nimrod
Post by: John on September 22, 2013, 08:02:34 PM
Quote
Nimrod is a statically typed, imperative programming language that tries to give the programmer ultimate power without compromises on runtime efficiency. This means it focuses on compile-time mechanisms in all their various forms.

---
Nimrod borrows features from lots of languages. Major influences are Pascal/Delphi, Modula 3, Ada, C++, Lisp, Python, Oberon.

Nimrod also has many unique and novel features that set it apart from the crowd:

  • An effect system in addition to a type system.
  • Part of the effect system is "exception tracking" which is Java's checked exceptions done right.
  • Overloading based on ASTs in addition to overloading based on types.
  • Term rewriting macros for user definable optimizations that can be based on side effect and alias analysis.
  • And lots more ...

Nimrod is a language that scales: You can use it for a whole software stack; both low level and high level code are right at home in Nimrod.

What is Nimrod?

Nimrod is a general purpose, statically-typed, imperative programming language that supports procedural, object-oriented, functional and generic programming styles while remaining simple and efficient.  Nimrod runs on Windows, Linux, BSD and MacOS X.

Nimrod Design

The Nimrod compiler generates optimized C code and defers compilation to a wide range of external compilers.  Nimrod supports objects with inheritance, overloading, polymorphism and multiple dispatch.  Nimrod treats procedures as first-class entities, meaning it can also be used for functional programming.  Nimrod also supports metaprogramming by a combination of generics, templates, macros, conditional compilation with compile-time function execution, and user-defined operators.

Nimrod has high-level data types, including strings, arrays, sequences, sets, tuples, enumerations, etc.  Most objects created on the heap are managed with garbage collection. Nimrod also supports a module mechanism to create independent libraries.  The Nimrod standard library has I/O and OS operations, string utilities, Unicode support, regular expressions, and various parsers such as command line options, XML, CSV, and SQL.

Nimrod History

Nimrod was created in 2004 by Andreas Rumpf.  It was originally coded in Object Pascal (FreePascal) and Python.  However, the first version that bootstrapped (was able to compile itself) was released in 2008.



Kent from the OxygenBasic forum (and now an advocate here) found a really nice BASIC like front end language to C. I think the author did an outstanding job and it seems to have a loyal following. The language is a conglomeration of many existing languages including SB. It has a strong Python and Pascal flavour to it but still has many of the BASIC constructs and high level language features. (garbage collection, OOP, truples, sequences and bit shifting if needed) The best part is it has bindings to most of the main stream libraries and embeddable scripting engines. A C header file converter is included if need to create your own custom binding.
 
Nimrod has an IDE (Aporia) that is written in Nimrod. It uses Gtk and the gtksourceview widget for the editor. The IDE is also a good resource to get a feel how Nimrod as a language flows.

(http://files.allbasic.info/Nimrod/nimrodide.png)

Nimrod Project Site (http://nimrod-code.org/)

Nimrod Manual (http://nimrod-code.org/manual.html)

Nimrod is also a supported language for the CompileOnline.com (http://www.compileonline.com/) site. (see attached)

Title: Nimrod - Tuples
Post by: John on September 22, 2013, 08:06:35 PM
Code: [Select]
type
    TPerson = tuple [name: string, age:int]

proc result(): TPerson = ("John",60)

var r = result()
echo(r)             # default stringification
echo (r.name)       # access by field name
var (name,age) = r  # tuple unpacking
echo (name,"|",age)

jrs@laptop:~/nimrod/examples$ nimrod c -d:release tuple.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: tuple [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/tuple.o examples/nimcache/tuple.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/system.o examples/nimcache/system.c
gcc   -o /home/jrs/nimrod/examples/tuple  examples/nimcache/system.o examples/nimcache/tuple.o  -ldl
Hint: operation successful (7450 lines compiled; 3.350 sec total; 8.870MB) [SuccessX]
jrs@laptop:~/nimrod/examples$ ./tuple
(name: John, age: 60)
John
John|60
jrs@laptop:~/nimrod/examples$
Title: Nimrod - head replacement
Post by: John on September 22, 2013, 08:08:09 PM
A Nimrod version of the Linux head console command.

Code: [Select]
import parseopt
from strutils import parseInt
from os import existsFile

const usage = """
head [flags] filename
  -n: number of lines (default 10)
  -h,--help: this help
  -v,--version: version
"""

proc showUsage(msg: string) =
  if msg != nil: echo("head: ",msg)
  quit(usage,1)
 
proc head(file: string, n: int) =
  if not existsFile(file):  quit("file " & file & " does not exist")
  var
    f = open(file)
    i = 0
  for line in f.lines:
    echo(line)
    i += 1
    if i == n: break
 
proc parseCommands() =
  var
    files: seq[string]
    n = 10
  newSeq(files,0)
  for kind, key, val in getopt():
    case kind
    of cmdArgument:
      files.add(key)
    of cmdLongOption, cmdShortOption:
      case key
      of "help", "h": showUsage(nil)
      of "n":
        n = parseInt(val)
      of "version", "v":
          echo("1.0")
          return
    of cmdEnd: assert(false) # cannot happen
  if len(files) == 0:
    # no filename has been given, so we show the help:
    showUsage("please supply filename")
  if len(files) == 1:
    head(files[0],n)
  else:
    for f in files:
      echo("----- ",f)
      head(f,n)
 
parseCommands()

jrs@laptop:~/nimrod/examples$ nimrod c -d:release nhead.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: nhead [Processing]
Hint: parseopt [Processing]
Hint: os [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: times [Processing]
Hint: posix [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/nhead.o examples/nimcache/nhead.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/parseopt.o examples/nimcache/parseopt.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/os.o examples/nimcache/os.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/strutils.o examples/nimcache/strutils.c
gcc   -o /home/jrs/nimrod/examples/nhead  examples/nimcache/posix.o examples/nimcache/times.o examples/nimcache/parseutils.o examples/nimcache/strutils.o examples/nimcache/os.o examples/nimcache/parseopt.o examples/nimcache/system.o examples/nimcache/nhead.o  -ldl
Hint: operation successful (14375 lines compiled; 0.569 sec total; 15.158MB) [SuccessX]
jrs@laptop:~/nimrod/examples$ ./nhead -n=5 nhead.nim
import parseopt
from strutils import parseInt
from os import existsFile

const usage = """
jrs@laptop:~/nimrod/examples$
jrs@laptop:~/nimrod/examples$ ls -l nhead
-rwxrwxr-x 1 jrs jrs 67253 Sep 21 23:34 nhead
jrs@laptop:~/nimrod/examples$
Title: Nimrod - polymorphic OOP example
Post by: John on September 22, 2013, 08:10:55 PM
Quote
Here we are making objects which are references (by default they are value types, like tuples, unlike java), initialized with the standard procedure new. Note the Pascal-like special variable result in procedures!

As expected, you may pass Germans to sayit, because a German is a person, but greeting has to be declared as a method for this to work; if it were a proc, we would get a warning about the second greeting being unused, and Germans are then addressed in English.

The cool thing about multi-methods is that they restore symmetry; a traditional polymorphic call a.foo(b) is only polymorphic in a. This makes sense in a language where dot method notation is just sugar for procedure calls where the first argument matches the type.

Code: [Select]
type
    TPerson = object of TObject
        name: string
        age: int

proc setPerson(p: ref TPerson, name: string, age:int) =
    p.name = name
    p.age = age

proc newPerson(name: string, age:int): ref TPerson =
    new(result)
    result.setPerson(name,age)

method greeting(p: ref TPerson):string = "Hello " & p.name & ", age " & $p.age

type
    TGerman = object of TPerson

proc newGerman(name: string, age:int): ref TGerman =
    new(result)
    result.setPerson(name,age)

method greeting(p: ref TGerman):string = "Hallo " & p.name & ", " & $p.age & " Jahre alt"

var john = newPerson("John",60)
var rene = newGerman("Rene",43)

proc sayit(p: ref TPerson) = echo p.greeting

sayit(john)
sayit(rene)

jrs@laptop:~/nimrod/examples$ nimrod c -d:release class.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: class [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/class.o examples/nimcache/class.c
gcc   -o /home/jrs/nimrod/examples/class  examples/nimcache/system.o examples/nimcache/class.o  -ldl
Hint: operation successful (7468 lines compiled; 0.297 sec total; 8.870MB) [SuccessX]
jrs@laptop:~/nimrod/examples$ ./class
Hello John, age 60
Hallo Rene, 43 Jahre alt
jrs@laptop:~/nimrod/examples$
Title: Re: Nimrod
Post by: kryton9 on September 22, 2013, 08:18:41 PM
Thanks John, I got no where with Nimrod. Your encouraging work and wonderful detailed posts of your progress are really motivating. I hope to catch up soon and contribute also.

I am glad you got Aporia working, as having a nice IDE is something I have been spoiled by in recent years with Code::Blocks, Lazarus and Visual Studio.

Do you do all of your development in Ubuntu and use Wine for Windows testing John?
Title: Re: Nimrod
Post by: John on September 22, 2013, 08:31:21 PM
My main development environment is Ubuntu 12.04 LTS 64 bit. I have a Win7 64 bit partition (always create your Windows partition first before Linux - less headaches)

I have a XP VirtualBox and Wine 1.6 (32/64 bit) I use for Windows related stuff.

Don't be shy. If you're having issues getting something going, that's what we're here for.

Our investment as developers in advocates is time well spent.

Title: Re: Nimrod
Post by: kryton9 on September 22, 2013, 08:48:20 PM
I got an online linux book to study, I had read one in the late 90's but forgot all I read.

Thanks, I always try things on my own and only ask for help when truly stumped so don't worry won't flood you with things I should learn on my own.
Title: Re: Nimrod
Post by: John on September 22, 2013, 08:53:48 PM
I think it's more fun than playing games.

Learning new languages and OSs only enriches your skill set and makes you more worthy to those knowing less.  8)

Title: Nimrod - OpenGL
Post by: John on September 23, 2013, 10:52:20 PM
Quote
GLFW is a lightweight utility library for use with OpenGL. It provides programmers with the ability to open windows, create and manage OpenGL contexts, as well as receive input from joystick, keyboard and mouse. The current release of GLFW supports OpenGL 3.0 and higher.

The box moves around the screen bouncing off its edges.

(http://files.allbasic.info/Nimrod/nimglfw.png)

Code: [Select]
import glfw
import opengl
import strutils


## -------------------------------------------------------------------------------

var
    running : bool = true
    frameCount: int = 0
    lastTime: float = 0.0
    lastFPSTime: float = 0.0
    currentTime: float = 0.0
    frameRate: int = 0
    frameDelta: float = 0.0
    x: float = 0.0
    y: float = 0.0
    vx: float = 200.0
    vy: float = 200.0
    windowW: cint = 640
    windowH: cint = 480

## -------------------------------------------------------------------------------

proc Initialize() =
   
    if glfwInit() == 0:
        write(stdout, "Could not initialize GLFW! \n")

    if glfwOpenWindow(windowW.cint, windowH.cint, 0, 0, 0, 0, 0, 0, GLFW_WINDOW) == 0:
        glfwTerminate()

    opengl.loadExtensions()

    glfwSwapInterval(0)

    glClearColor(0.1,0.1,0.1,1.0)
    glClearDepth(1.0)

    glEnable(GL_BLEND)
    glDisable(GL_LIGHTING)
    glCullFace(GL_BACK)
    glDisable(GL_DEPTH_TEST)

    glViewport(0,0,windowW,windowH)

    glMatrixMode(GL_PROJECTION)

    glOrtho(0.0, float(windowW), float(windowH), 0.0, 0.0, 1.0)

    lastTime = glfwGetTime()
    lastFPSTime = lastTime

## -------------------------------------------------------------------------------

proc Update() =
   
    currentTime = glfwGetTime()

    frameDelta = currentTime - lastTime

    lastTime = currentTime

    if currentTime - lastFPSTime > 1.0:
        frameRate = int(float(frameCount) / (currentTime - lastFPSTime))
        glfwSetWindowTitle("FPS: $1" % intToStr(frameRate))
       
        lastFPSTime = currentTime
        frameCount = 0

    frameCount += 1

    x += vx * frameDelta
    y += vy * frameDelta

    var w = float(windowW)
    var h = float(windowH)

    if x > w - 100.0:

        x = w - 100.0
        vx *= -1.0

    elif x < 0.0:

        x = 0.0
        vx *= -1.0

    if y > h - 100.0:

        y = h - 100.0
        vy *= -1.0

    elif y < 0.0:

        y = 0.0
        vy *= -1.0


## --------------------------------------------------------------------------------

proc Render() =
   
    glClear(GL_COLOR_BUFFER_BIT)

    glMatrixMode(GL_MODELVIEW)

    glLoadIdentity()

    glBegin(GL_QUADS)

    glColor3f(0.9,0.2,0.49)

    glVertex3f(x, y, 0.0)

    glVertex3f(x + 100.0, y, 0.0)

    glVertex3f(x + 100.0, y + 100.0, 0.0)

    glVertex3f(x, y + 100.0, 0.0)

    glEnd()

    glfwSwapBuffers()



## --------------------------------------------------------------------------------

proc Run() =
   
    while running:

        Update()

        Render()

        running = glfwGetKey(GLFW_KEY_ESC) == GLFW_RELEASE and
                  glfwGetWindowParam(GLFW_OPENED) == GL_TRUE


## ==============================================================================

Initialize()

Run()

glfwTerminate()

jrs@laptop:~/nimrod/examples$ nimrod c -d:release glfwtest.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: glfwtest [Processing]
Hint: glfw [Processing]
Hint: opengl [Processing]
Hint: x [Processing]
Hint: xlib [Processing]
Hint: xutil [Processing]
Hint: keysym [Processing]
Hint: dynlib [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/glfwtest.o examples/nimcache/glfwtest.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/system.o examples/nimcache/system.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/glfw.o examples/nimcache/glfw.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/opengl.o examples/nimcache/opengl.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/xlib.o examples/nimcache/xlib.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/xutil.o examples/nimcache/xutil.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/dynlib.o examples/nimcache/dynlib.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/strutils.o examples/nimcache/strutils.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/parseutils.o examples/nimcache/parseutils.c
gcc   -o /home/jrs/nimrod/examples/glfwtest  examples/nimcache/parseutils.o examples/nimcache/strutils.o examples/nimcache/dynlib.o examples/nimcache/keysym.o examples/nimcache/xutil.o examples/nimcache/xlib.o examples/nimcache/x.o examples/nimcache/opengl.o examples/nimcache/glfw.o examples/nimcache/system.o examples/nimcache/glfwtest.o  -ldl
Hint: operation successful (24526 lines compiled; 3.610 sec total; 26.266MB) [SuccessX]
jrs@laptop:~/nimrod/examples$ ./glfwtest
jrs@laptop:~/nimrod/examples$ ls -l glfwtest
-rwxrwxr-x 1 jrs jrs 67981 Sep 23 22:44 glfwtest
jrs@laptop:~/nimrod/examples$
Title: Nimrod - Gtk Cairo
Post by: John on September 24, 2013, 10:23:26 AM
Quote
Gtk Cairo is a software library used to provide a vector graphics-based, device-independent API for software developers. It is designed to provide primitives for 2-dimensional drawing across a number of different backends. Cairo is designed to use hardware acceleration when available.

Code: [Select]
import cairo

var surface = image_surface_create(FORMAT_ARGB32, 240, 80)
var cr = create(surface)

select_font_face(cr, "serif", FONT_SLANT_NORMAL,
                              FONT_WEIGHT_BOLD)
set_font_size(cr, 32.0)
set_source_rgb(cr, 0.0, 0.0, 1.0)
move_to(cr, 10.0, 50.0)
show_text(cr, "Hello, world")
destroy(cr)
discard write_to_png(surface, "hello.png")
destroy(surface)
Title: Nimrod - (lib)cURL
Post by: John on September 24, 2013, 10:50:08 AM
Quote
libcurl is a free and easy-to-use client-side URL transfer library, supporting DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, Telnet and TFTP. libcurl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, Kerberos), file transfer resume, http proxy tunneling and more!

A wget like web page download example in Nimrod using libcurl.

Code: [Select]
import
  libcurl

var hCurl = easy_init()
if hCurl != nil:
  discard easy_setopt(hCurl, OPT_VERBOSE, True)
  discard easy_setopt(hCurl, OPT_URL, "http://www.scriptbasic.info/index.html")
  discard easy_perform(hCurl)
  easy_cleanup(hCurl)

jrs@laptop:~/nimrod/examples$ nimrod c -d:release curlex.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: curlex [Processing]
Hint: libcurl [Processing]
Hint: times [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/curlex.o examples/nimcache/curlex.c
gcc   -o /home/jrs/nimrod/examples/curlex  examples/nimcache/parseutils.o examples/nimcache/strutils.o examples/nimcache/times.o examples/nimcache/libcurl.o examples/nimcache/system.o examples/nimcache/curlex.o  -ldl
Hint: operation successful (10438 lines compiled; 0.263 sec total; 11.112MB) [SuccessX]
jrs@laptop:~/nimrod/examples$ ./curlex
* About to connect() to www.scriptbasic.info port 80 (#0)
*   Trying 184.169.134.178... * connected
> GET /index.html HTTP/1.1
Host: www.scriptbasic.info
Accept: */*

< HTTP/1.1 200 OK
< Date: Sun, 15 Sep 2013 04:37:36 GMT
< Server: Apache/2.2.22 (Ubuntu)
< Last-Modified: Thu, 07 Jun 2012 05:37:46 GMT
< ETag: "2329b-41-4c1db48920d04"
< Accept-Ranges: bytes
< Content-Length: 65
< Vary: Accept-Encoding
< Content-Type: text/html
<
<html><body><h1>ScriptBasic Development Site</h1>
</body></html>
* Connection #0 to host www.scriptbasic.info left intact
* Closing connection #0
jrs@laptop:~/nimrod/examples$
Title: Nimrod - IUP
Post by: John on September 24, 2013, 01:48:03 PM
Quote
The IUP (Portable User Interface) is a computer software development kit that provides a portable, scriptable toolkit for GUI building using C and Lua. This allows rapid, zero-compile prototyping and refinement of deployable GUI applications.

(http://files.allbasic.info/Nimrod/nimrod_iup.png)

Code: [Select]
# IupTabs: Creates a IupTabs control.

import iup

discard iup.Open(nil, nil)

var vbox1 = Iup.Vbox(Iup.Label("Inside Tab A"), Iup.Button("Button A", ""), nil)
var vbox2 = Iup.Vbox(Iup.Label("Inside Tab B"), Iup.Button("Button B", ""), nil)

Iup.SetAttribute(vbox1, "TABTITLE", "Tab A")
Iup.SetAttribute(vbox2, "TABTITLE", "Tab B")

var tabs1 = Iup.Tabs(vbox1, vbox2, nil)

vbox1 = Iup.Vbox(Iup.Label("Inside Tab C"), Iup.Button("Button C", ""), nil)
vbox2 = Iup.Vbox(Iup.Label("Inside Tab D"), Iup.Button("Button D", ""), nil)

Iup.SetAttribute(vbox1, "TABTITLE", "Tab C")
Iup.SetAttribute(vbox2, "TABTITLE", "Tab D")

var tabs2 = Iup.Tabs(vbox1, vbox2, nil)
Iup.SetAttribute(tabs2, "TABTYPE", "LEFT")

var box = Iup.Hbox(tabs1, tabs2, nil)
Iup.SetAttribute(box, "MARGIN", "10x10")
Iup.SetAttribute(box, "GAP", "10")

var dlg = Iup.Dialog(box)
Iup.SetAttribute(dlg, "TITLE", "IupTabs")
Iup.SetAttribute(dlg, "SIZE", "200x100")

discard Iup.ShowXY(dlg, IUP_CENTER, IUP_CENTER)
discard Iup.MainLoop()
Iup.Close()

jrs@laptop:~/nimrod/examples$ nimrod c -d:release iupex1.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: iupex1 [Processing]
Hint: iup [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/iupex1.o examples/nimcache/iupex1.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/system.o examples/nimcache/system.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/iup.o examples/nimcache/iup.c
gcc   -o /home/jrs/nimrod/examples/iupex1  examples/nimcache/iup.o examples/nimcache/system.o examples/nimcache/iupex1.o  -ldl
Hint: operation successful (8425 lines compiled; 0.498 sec total; 9.922MB) [SuccessX]
jrs@laptop:~/nimrod/examples$ ./iupex1
jrs@laptop:~/nimrod/examples$ ls -l iupex1
-rwxrwxr-x 1 jrs jrs 24456 Sep 14 19:22 iupex1
jrs@laptop:~/nimrod/examples$
Title: Nimrod - Gtk
Post by: John on September 24, 2013, 02:18:28 PM
Quote
GTK+ (GIMP Toolkit) is a cross-platform widget toolkit for creating graphical user interfaces. It is licensed under the terms of the GNU LGPL.

Note: The Nimrod Aporia IDE is written in Nimrod and uses Gtk as its framework. It's a great resource if Gtk native is your GUI of choice.

(http://files.allbasic.info/Nimrod/smnimwin.png)

ex5.nim
Code: [Select]
import
  glib2, gtk2

proc destroy(widget: pWidget, data: pgpointer){.cdecl.} =
  main_quit()

proc widgetDestroy(w: PWidget) {.cdecl.} =
  destroy(w)

nimrod_init()
var window = window_new(WINDOW_TOPLEVEL)
var button = button_new("Click me")
set_border_width(Window, 5)
add(window, button)
discard signal_connect(window, "destroy",
                       SIGNAL_FUNC(ex5.destroy), nil)
discard signal_connect_object(button, "clicked",
                              SIGNAL_FUNC(widgetDestroy),
                              window)
show(button)
show(window)
main()

Title: Nimrod - Zero MQ
Post by: John on September 24, 2013, 02:55:15 PM
Quote
Zero MQ (0mq) is a lightweight messaging kernel library which extends the standard socket interfaces with features traditionally provided by specialised messaging middleware products. 0MQ sockets provide an abstraction of asynchronous message queues, multiple messaging patterns, message filtering (subscriptions), seamless access to multiple transport protocols and more.

Server
Code: [Select]
import zmq

var connection = zmq.open("tcp://*:5555", server=true)

while True:
  var request = receive(connection)
  echo("Received: ", request)
  send(connection, "World")
 
close(connection)

jrs@laptop:~/nimrod/examples/0mq$ nimrod c -d:release server.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: server [Processing]
Hint: zmq [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/0mq/nimcache/system.o examples/0mq/nimcache/system.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/0mq/nimcache/zmq.o examples/0mq/nimcache/zmq.c
gcc   -o /home/jrs/nimrod/examples/0mq/server  examples/0mq/nimcache/zmq.o examples/0mq/nimcache/system.o examples/0mq/nimcache/server.o  -ldl
Hint: operation successful (7773 lines compiled; 1.396 sec total; 9.922MB) [SuccessX]

jrs@laptop:~/nimrod/examples/0mq$ ./server
Received: Hello
Received: Hello
Received: Hello
Received: Hello
Received: Hello
Received: Hello
Received: Hello
Received: Hello
Received: Hello
Received: Hello
Received: Hello

Client
Code: [Select]
import zmq

var connection = zmq.open("tcp://localhost:5555", server=false)

echo("Connecting...")

for i in 0..10:
  echo("Sending hello...", i)
  send(connection, "Hello")
 
  var reply = receive(connection)
  echo("Received ...", reply)

close(connection)

jrs@laptop:~/nimrod/examples/0mq$ nimrod c -d:release client.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: client [Processing]
Hint: zmq [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/0mq/nimcache/client.o examples/0mq/nimcache/client.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/0mq/nimcache/system.o examples/0mq/nimcache/system.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/0mq/nimcache/zmq.o examples/0mq/nimcache/zmq.c
gcc   -o /home/jrs/nimrod/examples/0mq/client  examples/0mq/nimcache/zmq.o examples/0mq/nimcache/system.o examples/0mq/nimcache/client.o  -ldl
Hint: operation successful (7776 lines compiled; 1.494 sec total; 9.922MB) [SuccessX]

jrs@laptop:~/nimrod/examples/0mq$ ./client
Connecting...
Sending hello...0
Received ...World
Sending hello...1
Received ...World
Sending hello...2
Received ...World
Sending hello...3
Received ...World
Sending hello...4
Received ...World
Sending hello...5
Received ...World
Sending hello...6
Received ...World
Sending hello...7
Received ...World
Sending hello...8
Received ...World
Sending hello...9
Received ...World
Sending hello...10
Received ...World
jrs@laptop:~/nimrod/examples/0mq$

Title: Nimrod - parsexml
Post by: John on September 24, 2013, 04:49:35 PM
The parsexml module is being used to extract the links out of a HTML document. I use the www.oxygenbasic.org page for this test.

Code: [Select]
# Example program to show the new parsexml module
# This program reads an HTML file and writes all its used links to stdout.
# Errors and whitespace are ignored.

import os, streams, parsexml, strutils

proc `=?=` (a, b: string): bool =
  # little trick: define our own comparator that ignores case
  return cmpIgnoreCase(a, b) == 0

if paramCount() < 1:
  quit("Usage: htmlrefs filename[.html]")

var links = 0 # count the number of links
var filename = addFileExt(ParamStr(1), "html")
var s = newFileStream(filename, fmRead)
if s == nil: quit("cannot open the file " & filename)
var x: TXmlParser
open(x, s, filename)
next(x) # get first event
block mainLoop:
  while true:
    case x.kind
    of xmlElementOpen:
      # the <a href = "xyz"> tag we are interested in always has an attribute,
      # thus we search for ``xmlElementOpen`` and not for ``xmlElementStart``
      if x.elementName =?= "a":
        x.next()
        if x.kind == xmlAttribute:
          if x.attrKey =?= "href":
            var link = x.attrValue
            inc(links)
            # skip until we have an ``xmlElementClose`` event
            while true:
              x.next()
              case x.kind
              of xmlEof: break mainLoop
              of xmlElementClose: break
              else: nil
            x.next() # skip ``xmlElementClose``
            # now we have the description for the ``a`` element
            var desc = ""
            while x.kind == xmlCharData:
              desc.add(x.charData)
              x.next()
            Echo(desc & ": " & link)
      else:
        x.next()     
    of xmlEof: break # end of file reached
    of xmlError:
      Echo(errorMsg(x))
      x.next()
    else: x.next() # skip other events

echo($links & " link(s) found!")
x.close()

jrs@laptop:~/nimrod/examples$ nimrod c -d:release htmlrefs.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: htmlrefs [Processing]
Hint: os [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: times [Processing]
Hint: posix [Processing]
Hint: streams [Processing]
Hint: parsexml [Processing]
Hint: hashes [Processing]
Hint: lexbase [Processing]
Hint: unicode [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/htmlrefs.o examples/nimcache/htmlrefs.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/system.o examples/nimcache/system.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/os.o examples/nimcache/os.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/strutils.o examples/nimcache/strutils.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/streams.o examples/nimcache/streams.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/parsexml.o examples/nimcache/parsexml.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/hashes.o examples/nimcache/hashes.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/lexbase.o examples/nimcache/lexbase.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/unicode.o examples/nimcache/unicode.c
gcc   -o /home/jrs/nimrod/examples/htmlrefs  examples/nimcache/unicode.o examples/nimcache/lexbase.o examples/nimcache/hashes.o examples/nimcache/parsexml.o examples/nimcache/streams.o examples/nimcache/posix.o examples/nimcache/times.o examples/nimcache/parseutils.o examples/nimcache/strutils.o examples/nimcache/os.o examples/nimcache/system.o examples/nimcache/htmlrefs.o  -ldl
Hint: operation successful (16742 lines compiled; 2.079 sec total; 19.199MB) [SuccessX]

jrs@laptop:~/nimrod/examples$ ./htmlrefs o2.html
o2.html(17, 13) Error: '"' or "'" expected
o2.html(21, 11) Error: '"' or "'" expected
o2.html(24, 24) Error: '"' or "'" expected
o2.html(26, 35) Error: '"' or "'" expected
o2.html(30, 42) Error: '"' or "'" expected
Alpha Downloads: http://www.oxygenbasic.org/downloads.htm
Games: http://www.oxygenbasic.org/games.htm
Reference: http://www.oxygenbasic.org/reference.htm
Forum: http://www.oxygenbasic.org/forum/
Wiki: http://www.oxygenbasic.org/wiki/index.php/Main_Page
5 link(s) found!
jrs@laptop:~/nimrod/examples$

Title: Nimrod - FizzBuzz Test
Post by: John on September 24, 2013, 05:41:34 PM
Quote
The "Fizz-Buzz test" is an interview question designed to help filter out the 99.5% of programming job candidates who can't seem to program their way out of a wet paper bag. The text of the programming assignment is as follows:

    Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.

Code: [Select]
# Fizz Buzz program

const f = "Fizz"
const b = "Buzz"
for i in 1..100:
  if i mod 15 == 0:
    echo f, b
  elif i mod 5 == 0:
    echo b
  elif i mod 3 == 0:
    echo f
  else:
    echo i

jrs@laptop:~/nimrod/examples$ nimrod c -d:release fizzbuzz.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: fizzbuzz [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/fizzbuzz.o examples/nimcache/fizzbuzz.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/system.o examples/nimcache/system.c
gcc   -o /home/jrs/nimrod/examples/fizzbuzz  examples/nimcache/system.o examples/nimcache/fizzbuzz.o  -ldl
Hint: operation successful (7452 lines compiled; 1.390 sec total; 8.870MB) [SuccessX]

Results
Code: [Select]
jrs@laptop:~/nimrod/examples$ ./fizzbuzz
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
Fizz
22
23
Fizz
Buzz
26
Fizz
28
29
FizzBuzz
31
32
Fizz
34
Buzz
Fizz
37
38
Fizz
Buzz
41
Fizz
43
44
FizzBuzz
46
47
Fizz
49
Buzz
Fizz
52
53
Fizz
Buzz
56
Fizz
58
59
FizzBuzz
61
62
Fizz
64
Buzz
Fizz
67
68
Fizz
Buzz
71
Fizz
73
74
FizzBuzz
76
77
Fizz
79
Buzz
Fizz
82
83
Fizz
Buzz
86
Fizz
88
89
FizzBuzz
91
92
Fizz
94
Buzz
Fizz
97
98
Fizz
Buzz
jrs@laptop:~/nimrod/examples$
Title: Re: Nimrod
Post by: kryton9 on September 24, 2013, 06:02:15 PM
I can't get any programming language to run 100% in Ubuntu other than Code::Blocks and gcc and g++ stuff.
Anyways your nimrod work is really making me want to get it working. I will try in Windows7 next.
Title: Re: Nimrod
Post by: John on September 24, 2013, 06:47:54 PM
Kent,

How I got Nimrod to work.

1. Unzip archive into your ~/nimrod directory. (~ = /home/jrs for me)

2. I ran sh build64.sh which created the nimrod executable in my ~/nimrod/bin directory.

3. I then export PATH=$PATH:/home/jrs/nimrod/bin

I can then run nimrod from the examples directory or where ever I wish.

Nimrod may have some dependencies that need to installed first.

Advice: Get comfortable working in a console and using Linux console mode utilities. I use Nautilus for my file manager and Evolution for my mail client. I use Gimp for my Photoshop replacement and ssh/sftp for connecting to other servers and Firefox as my browser.  I spend 90% of my development time in a console environment.


 
Title: Re: Nimrod
Post by: kryton9 on September 24, 2013, 09:30:53 PM
I just got frustrated not getting anything to work as I expected.

I got nimrod and aporia installed and running in windows :)

Going to test out some of your examples now, thanks for putting them up.
Title: Re: Nimrod
Post by: John on September 24, 2013, 09:44:42 PM
That's it. I'm calling Linus and have you put on the list.

Windows backslider!

Title: GLFW Nimrod for Windows
Post by: kryton9 on September 24, 2013, 10:02:00 PM
I love it, thanks for the laughs John.

Your examples here helped test my setup.  I got the cairo example to work just fine, but had problems with the glfw example.

For windows, I downloaded the wrapper from here: https://github.com/rafaelvasco/nimrod-glfw  just click on the download zip button.
Once extracted you will have 2 subfolders:
src and test

of course substitute your path to your Nimrod directory, mine is D:\Nimrod
from the src folder, take the glfw.nim file and copy or move it to your D:\Nimrod\lib\wrappers directory.
from the test folder, I copied the glfw.dll to the D:\Nimrod\dist directory
from the test folder, I copied the glfwtest.nim to the D:\Nimrod\examples directory

If you do the above, then it should compile and run just fine.

Once I get all the dependencies and tests working, I will try to make a bundle download for Windows where everything is setup right from the get go without having to hunt dependencies for aporia and nimrod, that would include all the gtk+ stuff too.
Title: Re: Nimrod
Post by: John on September 24, 2013, 10:02:16 PM
Quote
Going to test out some of your examples now, thanks for putting them up.

I would install Gtk3 rather than Gtk2 under Windows. They compiled the Gtk3 version with MinGW-gcc and it runs a lot smoother.

I haven't looked what is needed yet to get theme support working under Windows with Nimrod. Should be pretty easy.
Title: Re: Nimrod
Post by: kryton9 on September 24, 2013, 10:07:44 PM
I am worried about the gtk3+ dependencies, like sourceview, libxml etc. Once I get everything working and a bundle figured out. Then I won't be afraid to try out GTK3 John, thanks I didn't know it was out and working with Nimrod.
Title: Re: Nimrod - FizzBuzz Test
Post by: kryton9 on September 24, 2013, 10:11:24 PM
Quote
The "Fizz-Buzz test" is an interview question designed to help filter out the 99.5% of programming job candidates who can't seem to program their way out of a wet paper bag. The text of the programming assignment is as follows:

    Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.

Amazing how easy the code is and nice to look at, to do, what it does!
Title: Re: Nimrod
Post by: John on September 24, 2013, 10:13:26 PM
Can you post a screen shot of your Nimrod Aporia IDE running on Windows?

Title: Screenshot Aporia on Windows
Post by: kryton9 on September 24, 2013, 10:21:36 PM
Here is a screenshot of Aporia running in Windows 7.

I really like this IDE!
Title: Re: Nimrod
Post by: John on September 24, 2013, 10:23:47 PM
Sweet!
Title: Re: Nimrod
Post by: kryton9 on September 24, 2013, 10:27:20 PM
I got to get some sleep, have a great evening John. I can sleep well knowing I got Nimrod and Aporia to come home to further play with tomorrow evening. THanks for your help!
Title: Re: Nimrod
Post by: John on September 24, 2013, 10:48:50 PM
The Nimrod language/translator is written Nimrod (bootstrapped from Pascal) so when you get through playing with the examples I posted, maybe we'll see some k9.nim extensions from you.  8)
Title: Nimrod - Towers of Hanoi
Post by: John on September 25, 2013, 12:09:43 AM
Quote
The Tower of Hanoi (also called the Tower of Brahma or Lucas' Tower and sometimes pluralised) is a mathematical game or puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape.

The objective of the puzzle is to move the entire stack to another rod, obeying the following rules:
  • Only one disk must be moved at a time.
  • Each move consists of taking the upper disk from one of the rods and sliding it onto another rod, on top of the other disks that may already be present on that rod.
  • No disk may be placed on top of a smaller disk.

With three disks, the puzzle can be solved in seven moves.

Code: [Select]
proc hanoi(disks: int, fromTower: string, toTower: string, viaTower: string) =
  if disks != 0:
    hanoi(disks - 1, fromTower, viaTower, toTower)
    echo("Move disk ", disks, " from ", fromTower, " to ", toTower)
    hanoi(disks - 1, viaTower, toTower, fromTower)
 
hanoi(3, "1", "2", "3")

jrs@laptop:~/nimrod/examples$ nimrod c -d:release hanoi.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: hanoi [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/hanoi.o examples/nimcache/hanoi.c
gcc   -o /home/jrs/nimrod/examples/hanoi  examples/nimcache/system.o examples/nimcache/hanoi.o  -ldl
Hint: operation successful (7445 lines compiled; 0.266 sec total; 8.870MB) [SuccessX]
jrs@laptop:~/nimrod/examples$ ./hanoi
Move disk 1 from 1 to 2
Move disk 2 from 1 to 3
Move disk 1 from 2 to 3
Move disk 3 from 1 to 2
Move disk 1 from 3 to 1
Move disk 2 from 3 to 2
Move disk 1 from 1 to 2
jrs@laptop:~/nimrod/examples$
Title: Nimrod - Sieve
Post by: John on September 25, 2013, 12:24:05 AM
Quote
The Sieve of Eratosthenes is a simple algorithm that finds the prime numbers up to a given integer.

Code: [Select]
import math, strutils
 
var is_prime: seq[Bool] = @[]
is_prime.add(False)

iterator iprimes_upto(limit: int): int =
    for n in high(is_prime) .. limit+2: is_prime.add(True)   
    for n in 2 .. limit + 1:
        if is_prime[n]:
            yield n
            for i in countup((n *% n), limit+1, n): # start at ``n`` squared
                try:
                    is_prime[i] = False
                except EInvalidIndex: break
 
 
echo("Primes are:")
for x in iprimes_upto(200):
   write(stdout, x, " ")
writeln(stdout,"")

jrs@laptop:~/nimrod/examples$ nimrod c -d:release sieve.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: sieve [Processing]
Hint: math [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/sieve.o examples/nimcache/sieve.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/system.o examples/nimcache/system.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/math.o examples/nimcache/math.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/strutils.o examples/nimcache/strutils.c
gcc   -o /home/jrs/nimrod/examples/sieve  examples/nimcache/parseutils.o examples/nimcache/strutils.o examples/nimcache/math.o examples/nimcache/system.o examples/nimcache/sieve.o  -ldl -lm
Hint: operation successful (9489 lines compiled; 1.661 sec total; 11.117MB) [SuccessX]

jrs@laptop:~/nimrod/examples$ time ./sieve
Primes are:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199

real   0m0.002s
user   0m0.000s
sys   0m0.000s
jrs@laptop:~/nimrod/examples$
Title: Re: Nimrod
Post by: Charles Pegge on September 25, 2013, 02:20:44 AM
This algorithm is a lot easier to understand when written in basic :)

Code: [Select]
'Sieve of Eratosthenes
includepath "$/inc/"
include "console.inc"
%max 200
sys n[max]
q=0
p=2 'first prime
print "Primes from 2.." & max & chr(13,10)
do
  for i=p*2 to max step p
    n[i]=1 'mark multiples of prime as non-prime
  next
  q=0
  for i=p+1 to max
    if n[i]=0
      q=i 'next prime located
      print i & chr(9)
      exit for
    end if
  next
  if q=0 then exit do 'no more primes
  p=q
end do
WaitKey
Title: Re: Nimrod - Sieve
Post by: John on September 25, 2013, 09:52:19 AM
Thanks Charles.

The Nimrod Sieve example was from the Rosettacode.org site. The comment was it was based on the Python example there. I noticed what I thought was a typo and removed the duplicate line. With or without the second line it produces the same results.
Code: [Select]
is_prime.add(False)
is_prime.add(False)

When you question if something is a typo or not you need more understandable code. Thanks for your example which did just that.

Update

Quote
Sequences are always indexed with an int starting at position 0.

It seems the two .add lines bumps the sequence position to start at 2. Not sure why it still works starting at 1.

Quote
Iterators look very similar to procedures, but there are several important differences:

    Iterators can only be called from for loops.
    Iterators cannot contain a return statement and procs cannot contain a yield statement.
    Iterators have no implicit result variable.
    Iterators do not support recursion.
Title: Re: Nimrod - NOT(Gtk3)
Post by: John on September 25, 2013, 07:14:33 PM
Kent,

Sorry, Gtk3 isn't supported yet with Nimrod.  :'(

Code: [Select]
F:\Nimrod\examples\gtk>ex5
could not import: gtk_signal_connect_full

F:\Nimrod\examples\gtk>

I have both Gtk2 & Gtk3 installed on Ubuntu. I'm not going back to Gtk2 on Windows. (Kludge)

I would use IUP 3.8 and Nimrod before resorting to having to use Gtk2 under Windows.

Title: Re: Nimrod
Post by: kryton9 on September 25, 2013, 08:00:18 PM
Thanks for the tip John, will keep that in mind.
Title: Re: Nimrod - Gtk2
Post by: John on September 25, 2013, 10:21:06 PM
Never say never.  :-*

(http://files.allbasic.info/Nimrod/ex3.png)

I was unable to run my compiled version of Aporia for Windows. (can't fine libxml2-2) I only have libxml2 installed. The -2 version is elusive.

Update

I found a libxml2-2.dll but I'm getting the following error when running Aporia.

F:\Nimrod\Aporia>aporia
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

F:\Nimrod\Aporia>
Title: Re: Nimrod - Aporia Windows
Post by: John on September 26, 2013, 01:22:02 AM
(http://files.allbasic.info/Nimrod/aporia_win.png)

Bad copy of Gtk2 for Windows.  :(

Quote
The GnuWin project provides Win32-versions of GNU tools, or tools with a similar open source licence. The ports are native ports, that is they rely only on libraries provided with any standard 32-bits MS-Windows operating system, such as MS-Windows 95 / 98 / ME / NT / 2000 / XP / 2003 / Vista. Unlike CygWin or Msys, native ports do not rely on some kind of Unix emulation, so that there is no need to install additional emulation libraries. At present, all developments have been done under MS-Windows-XP, using the Mingw port of the GNU C and C++ (GCC) compilers. Utilities and libraries provided by GnuWin, are used and distributed with packages such as GNU Emacs and KDE-Windows.

GnuWin at SourceForge (http://sourceforge.net/projects/gnuwin32/files/)
Title: Nimrod - Pyramid of Numbers
Post by: John on September 26, 2013, 06:17:11 PM
Quote
This puzzle involves a Pascals Triangle, also known as a Pyramid of Numbers.

           [ 151]
          [  ][  ]
        [40][  ][  ]
      [  ][  ][  ][  ]
    [ X][11][ Y][ 4][ Z]

Each brick of the pyramid is the sum of the two bricks situated below it.
Of the three missing numbers at the base of the pyramid, the middle one is the sum of the other two (that is, Y = X + Z).

Code: [Select]
import math, strutils
 
var B_X, B_Y, B_Z : int = 0
 
type
   Block_Value = object
      Known   : int
      X, Y, Z : int
 
let
   X: Block_Value = Block_Value(Known:0, X:1, Y:0, Z:0)
   Y: Block_Value = Block_Value(Known:0, X:0, Y:1, Z:0)
   Z: Block_Value = Block_Value(Known:0, X:0, Y:0, Z:1)
 
proc Add (L : var Block_Value, R : Block_Value) =
   # Symbolically adds one block to another
   L.Known = L.Known + R.Known
   L.X = L.X + R.X - R.Z    # Z is excluded as n(Y - X - Z) = 0
   L.Y = L.Y + R.Y + R.Z
 
proc Add (L: var Block_Value, R: int) =
   # Symbolically adds a value to the block
   L.Known = L.Known + R
 
proc Image (N : Block_Value): string =
   # The block value, when X,Y,Z are known
   result = $(N.Known + N.X * B_X + N.Y * B_Y + N.Z * B_Z)
 
proc Solve_2x2 (A11: int, A12:int, B1:int, A21:int, A22:int, B2: int) =
   # Don't care about things, supposing an integer solution exists
   if A22 == 0:
      B_X = toInt(B2 / A21)
      B_Y = toInt((B1 - (A11*B_X)) / A12)
   else:
      B_X = toInt((B1*A22 - B2*A12) / (A11*A22 - A21*A12))
      B_Y = toInt((B1 - A11*B_X) / A12)
   B_Z = B_Y - B_X
 
var B : array [1..5, array[1..5, Block_Value]]   # The lower triangle contains blocks
 
# The bottom blocks
Add(B[5][1],X)
Add(B[5][2],11)
Add(B[5][3],Y)
Add(B[5][4],4)
Add(B[5][5],Z)
 
# Upward run
for Row in countdown(4,1):
   for Column in 1 .. Row:
      Add (B[Row][Column], B[Row + 1][Column])
      Add (B[Row][Column], B[Row + 1][Column + 1])
 
# Now have known blocks 40=[3][1], 151=[1][1] and Y=X+Z to determine X,Y,Z
Solve_2x2( B[1][1].X,
           B[1][1].Y,
           151 - B[1][1].Known,
           B[3][1].X,
           B[3][1].Y, 
           40 - B[3][1].Known)
 
#Print the results
for Row in 1..5:
   writeln(stdout,"")
   for Column in 1..Row:
      write(stdout, Image(B[Row][Column]), " ")
writeln(stdout,"")

jrs@laptop:~/nimrod/examples$ nimrod c -d:release pon.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: pon [Processing]
Hint: math [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/pon.o examples/nimcache/pon.c
gcc   -o /home/jrs/nimrod/examples/pon  examples/nimcache/parseutils.o examples/nimcache/strutils.o examples/nimcache/math.o examples/nimcache/system.o examples/nimcache/pon.o  -ldl -lm
Hint: operation successful (9536 lines compiled; 0.314 sec total; 11.117MB) [SuccessX]
jrs@laptop:~/nimrod/examples$ ./pon

151
81 70
40 41 29
16 24 17 12
5 11 13 4 8
jrs@laptop:~/nimrod/examples$
Title: Nimrod - FFI
Post by: John on September 26, 2013, 08:25:33 PM
This FFI (foreign function interface) example calls the C strcmp (string compare) function at runtime.

Code: [Select]
proc strcmp(a, b: cstring): cint {.importc: "strcmp", nodecl.}
echo strcmp("abc", "def")
echo strcmp("hello", "hello")

jrs@laptop:~/nimrod/examples$ nimrod c -d:release ffi.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: ffi [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/ffi.o examples/nimcache/ffi.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/system.o examples/nimcache/system.c
gcc   -o /home/jrs/nimrod/examples/ffi  examples/nimcache/system.o examples/nimcache/ffi.o  -ldl
Hint: operation successful (7441 lines compiled; 1.406 sec total; 8.870MB) [SuccessX]

jrs@laptop:~/nimrod/examples$ ./ffi
-1
0
jrs@laptop:~/nimrod/examples$
Title: Re: Nimrod
Post by: kryton9 on September 27, 2013, 03:04:32 PM
Thanks for the updates John glad you got it all resolved.
Title: Re: Nimrod
Post by: John on September 28, 2013, 11:11:25 AM
My hope is that AIR finds some time and shows us an OSX example of Nimrod using ObjectC.
Title: Nimrod - Windows 7
Post by: John on September 28, 2013, 06:06:54 PM
I was able to get Nimrod going on my Windows 7 64 bit partition.

(http://files.allbasic.info/Nimrod/aporia_win7.png)
Title: Nimrod - using C header files
Post by: John on September 28, 2013, 09:17:09 PM
I notice a cool feature in the Nimrod docs about adding a C header file into your code. It was looking pretty bleak with trying to convert the SB header file to a .nim interface header file. (SB macros always seem to be an issue) I'll post something here if I get it to work.

Quote
Header pragma

The header pragma is very similar to the noDecl pragma: It can be applied to almost any symbol and specifies that it should not be declared and instead the generated code should contain an #include:

Code: [Select]
type
  PFile {.importc: "FILE*", header: "<stdio.h>".} = distinct pointer
    # import C's FILE* type; Nimrod will treat it as a new pointer type

The header pragma always expects a string constant. The string contant contains the header file: As usual for C, a system header file is enclosed in angle brackets: <>. If no angle brackets are given, Nimrod encloses the header file in "" in the generated C code.
Title: Nimrod - GUI windows manager
Post by: John on September 28, 2013, 10:17:45 PM
(http://files.allbasic.info/Nimrod/winman.png)

Code: [Select]
import
  gdk2, glib2, gtk2,
  os
 
proc thisDestroy(widget: pWidget, data: pgpointer){.cdecl.} =
  main_quit()
proc thisMax(widget: pWidget, data: pgpointer){.cdecl.} =
  maximize(get_parent_window(widget))
proc thisUnmax(widget: pWidget, data: pgpointer){.cdecl.} =
  unmaximize(get_parent_window(widget))
proc thisIcon(widget: pWidget, data: pgpointer){.cdecl.} =
  iconify(get_parent_window(widget))
proc thisDeicon(widget: pWidget, data: pgpointer){.cdecl.} =
  deiconify(get_parent_window(widget))
proc thisHide(widget: pWidget, data: pgpointer){.cdecl.} =
  hide(get_parent_window(widget))
  sleep(5)
  show(get_parent_window(widget))
 
proc thisShow(widget: pWidget, data: pgpointer){.cdecl.} =
  show(get_parent_window(widget))
 
var isshifted: bool = false
 
proc thisMove(widget: pWidget, data: pgpointer){.cdecl.} =
  var w, h: gint
  get_size(get_parent_window(widget), Addr(w), Addr(h))
  if isshifted:
     move(get_parent_window(widget), w-10, h-10)
  else:
     move(get_parent_window(widget), w+10, h+10)
  isshifted = not isshifted
 
 
nimrod_init()
var window = window_new(gtk2.WINDOW_TOPLEVEL)
discard allow_grow(window)
set_title(window,"Window management")
var stackbox = vbox_new(TRUE, 10)
var bmax = button_new("maximize")
var bunmax = button_new("unmaximize")
var bicon = button_new("iconize")
var bdeicon = button_new("deiconize")
var bhide = button_new("hide")
var bshow = button_new("show")
var bmove = button_new("move")
var bquit = button_new("Quit")
 
pack_start(stackbox, bmax, TRUE, TRUE, 0)
pack_start(stackbox, bunmax, TRUE, TRUE, 0)
pack_start(stackbox, bicon, TRUE, TRUE, 0)
pack_start(stackbox, bdeicon, TRUE, TRUE, 0)
pack_start(stackbox, bhide, TRUE, TRUE, 0)
pack_start(stackbox, bshow, TRUE, TRUE, 0)
pack_start(stackbox, bmove, TRUE, TRUE, 0)
pack_start(stackbox, bquit, TRUE, TRUE, 0)
set_border_width(Window, 5)
add(window, stackbox)
discard signal_connect(window, "destroy",
                   SIGNAL_FUNC(thisDestroy), nil)
 
discard signal_connect(bicon, "clicked",
                   SIGNAL_FUNC(thisIcon), nil)
discard signal_connect(bdeicon, "clicked",
                   SIGNAL_FUNC(thisDeicon), nil)
discard signal_connect(bmax, "clicked",
                   SIGNAL_FUNC(thisMax), nil)
discard signal_connect(bunmax, "clicked",
                   SIGNAL_FUNC(thisUnmax), nil)
discard signal_connect(bhide, "clicked",
                   SIGNAL_FUNC(thisHide), nil)
discard signal_connect(bshow, "clicked",
                   SIGNAL_FUNC(thisShow), nil)
discard signal_connect(bmove, "clicked",
                   SIGNAL_FUNC(thismove), nil)                   
discard signal_connect(bquit, "clicked",
                   SIGNAL_FUNC(thisDestroy), nil)
show_all(window)
main()

Title: Nimrod - POOP
Post by: John on September 28, 2013, 11:29:43 PM
Quote
Methods

In ordinary object oriented languages, procedures (also called methods) are bound to a class. This has disadvantages:

* Adding a method to a class the programmer has no control over is impossible or needs ugly workarounds.
* Often it is unclear where the method should belong to: is join a string method or an array method?

Nimrod avoids these problems by not assigning methods to a class. All methods in Nimrod are multi-methods. As we will see later, multi-methods are distinguished from procs only for dynamic binding purposes.

Method call syntax

There is a syntactic sugar for calling routines: The syntax obj.method(args) can be used instead of method(obj, args). If there are no remaining arguments, the parentheses can be omitted: obj.len (instead of len(obj)).

This method call syntax is not restricted to objects, it can be used for any type:

Code: [Select]
import strutils

echo("abc".len) # is the same as echo(len("abc"))
echo("abc".toUpper())
echo({'a', 'b', 'c'}.card)
stdout.writeln("Hello") # the same as writeln(stdout, "Hello")

(Another way to look at the method call syntax is that it provides the missing postfix notation.)

Pure  Object Oriented Programming

Code: [Select]
import strutils

stdout.writeln("Give a list of numbers (separated by spaces): ")
stdout.write(stdin.readLine.split.map(parseInt).max.`$`)
stdout.writeln(" is the maximum!")

jrs@laptop:~/nimrod/examples$ ./poop
Give a list of numbers (separated by spaces):
5 1 8 3 7
8 is the maximum!
jrs@laptop:~/nimrod/examples$
Title: Re: Nimrod
Post by: kryton9 on September 29, 2013, 06:22:04 PM
Wow you are flying along John, a coding machine!

The bundle post is nice too. Are you thinking of adding all the necessary dll's for the nimrod libraries into the distro folder John?
Title: Re: Nimrod
Post by: John on September 29, 2013, 07:33:54 PM
My effort was a temporary helper until you figure out what direction you're going with Nimrod. I'm an advocate just like you on the Nimrod project and counting on you taking the lead. Feel free to add to whatever you want to help the Nimrod project along. I find the language interesting and hope to pickup some tips from it.

Title: Re: Nimrod
Post by: kryton9 on October 01, 2013, 12:22:40 AM
John, I spent some time on the Nimrod site reading more in depth instead of glancing. It seems my bundle idea was really stupid ( about the dlls for the distro folder ). I see that they have many wrappers for various databases, scripting languages and the same for graphics and so forth, so it is not feasible or reasonable to do.

I think it is language worth keeping an eye on, but I don't think ready for prime time just yet. The forums and other learning material are good for introductory work, but for me not enough to do a bigger project.

I did a search for instance on a tutorial for Nimrod using sqlite3 and didn't find anything. With my poor memory, I need good references and tutorials to give me a start. Anyways I will finish the tutorials that they have and play with the examples.

I think I want to work on helping Charles get a front end for Oxygen. So I want to really get into gcc and its front end manuals and see if I can make a start for him.
Title: Re: Nimrod
Post by: John on October 01, 2013, 02:29:03 AM
Maybe you should start with ScriptBasic first before getting too frustrated with Nimrod.

Title: Re: Nimrod
Post by: Charles Pegge on October 01, 2013, 07:35:33 AM

I'm quite interested in the idea of multimethods, which seems to aggregate objects to a method, rather than methods to an object, (as in C style OOP).

It sounds like there are a number dependencies, requiring prior expertise to get Nimrod running though.
Title: Re: Nimrod
Post by: John on October 01, 2013, 10:43:21 AM
The Linux squeeze will continue to disable programmers that ignore the OS. Linux defines cross platform and the framework tools that are used. I highly recommend getting a FREE Cloud9 account and start honing your Linux skills before Windows as a development concept is no longer relevant.
Title: off topic slightly
Post by: kryton9 on October 01, 2013, 02:25:11 PM
John, have you tried Arch Linux? I tried to install it but didn't get to far, but in honesty, I tried it without looking at the installation instructions.

What I like about it is, once you install and get it setup, you never have to uninstall and reinstall a next version. It does continuing updates!

I found that Ubuntu does not come with lots of core programming things that are needed. I followed the lazarus free pascal Ubuntu install instructions and although I did each step and got no errors installing everything. When I went to run Lazarus, it gives me an error. 

Also, at least in Ubuntu, things are placed all over the place and many are protected for root and many operations you can't do.

My dream OS would be:
The OS is just an OS that you can get in 3 flavors. 1. Command line only: for servers and embedded devices. 2. Command Line with Ascii GUI: for people running servers and or businesses and want to keep employees from playing games. 3. A full OS with command line, command line and ascii GUI and regular modern GUI.

The system can't be touched by no one. It can only be updated from official servers or from dvd's from os source. It would be in its own partition and no access to anyone but from official OS sources.

Drive C: would be the users directory with each user being a root folder in the c root:

c:/kent
c:/john
c:/charles

When you log on as a user your root directory automatically is your directory. So if I log in as kent when I say cd /
it takes me into c:/kent
as kent I don't see any of the other users folders.

Only a root user can access any users folder. So some one logging in as root would see this when they type cd /
c:/kent
c:/john
c:/charles

Then there would be another partition that is shared data for all users this would be drive d:  for data :)

When I log in as kent, everything I do to the system settings configurations are stored in my folder that I have full access too.
all programs would be self contained in one folder for each program within a folder of the users choice.
Basically you allow the user to control where things are for their tastes and in naming the prefer. And each downloaded and installed packages would be in one folder and not put files all over the place.

Now the big thing. Each library that has a dynamic dll that is for a major project, submits their latest dynamic library and headers to the OS maker. They in turn in updates install these into the OS system.

For a dynamic library a user makes, that would be in their choice of how they want to store dll's and headers.

So basically all major projects and the operating system are taken care of for the end user and always up to date.

The last big things is that the OS can talk to new hardware, download the interface, dll and header to make that device work from the firmware of the hardware. So any OS designed with this interface to query and get stuff from the firmware can support the hardware.
Title: Linux development environments
Post by: John on October 01, 2013, 02:28:27 PM
Sounds like your talking about Cloud9 IDE. (and it's online and sharable)
Title: Re: Nimrod
Post by: kryton9 on October 01, 2013, 02:30:51 PM
Going to check it out tonight John, you got me intrigues with your other impressive posts!
Title: Re: off topic slightly
Post by: AIR on October 04, 2013, 04:35:04 PM
Responses inline, I couldn't ignore this post... :-*

I found that Ubuntu does not come with lots of core programming things that are needed. I followed the lazarus free pascal Ubuntu install instructions and although I did each step and got no errors installing everything. When I went to run Lazarus, it gives me an error.
 

Most OS distributions are User-centric; if you want to develop on a given platform, you have to add support for it.

Quote
Also, at least in Ubuntu, things are placed all over the place and many are protected for root and many operations you can't do.

This is to protect you from yourself. ;D  It's real easy to destroy a system otherwise.

Quote
My dream OS would be:
The OS is just an OS that you can get in 3 flavors. 1. Command line only: for servers and embedded devices. 2. Command Line with Ascii GUI: for people running servers and or businesses and want to keep employees from playing games. 3. A full OS with command line, command line and ascii GUI and regular modern GUI.

Most Unix-like OS's already provide 1 and 3, while 2 reminds me of Linux in the late 80's.  As an aside, without a modern GUI most end-users would not be inclined to play games.  :)

Quote
The system can't be touched by no one. It can only be updated from official servers or from dvd's from os source. It would be in its own partition and no access to anyone but from official OS sources.

Sounds like you want Debian.


Quote
Drive C: would be the users directory with each user being a root folder in the c root:

c:/kent
c:/john
c:/charles

That would end up being an administrative nightmare, I think.

Quote
When you log on as a user your root directory automatically is your directory. So if I log in as kent when I say cd /
it takes me into c:/kent
as kent I don't see any of the other users folders.

When you log on, or start a terminal from a GUI session, you are already in your home folder. 

If you're somewhere else in the file system, "cd" by itself takes you back to your home folder.

Quote
Only a root user can access any users folder. So some one logging in as root would see this when they type cd /
c:/kent
c:/john
c:/charles

Not sure what the advantage to this would be over doing "cd /Users" (if supported) or "cd /home".  In your example, you would also see all of the folders/files that are at the root:  /bin /sbin /home /usr /etc

Quote
Then there would be another partition that is shared data for all users this would be drive d:  for data :)

Very easy to do if your partition your drives and edit /etc/fstab

Quote
When I log in as kent, everything I do to the system settings configurations are stored in my folder that I have full access too.

In Linux, a user's home folder generally has a hidden folder called ".config"

In it, you can over-ride most system-wide settings.

Quote
all programs would be self contained in one folder for each program within a folder of the users choice.
Basically you allow the user to control where things are for their tastes and in naming the prefer. And each downloaded and installed packages would be in one folder and not put files all over the place.

This would lead to tremendous duplication on a multi-user system.  For example, say you and I use the system.  We both want to use OpenOffice.  In your scenario, we each would have our own copy in our home folders.  Come update time, if it's automated, the system would have to upgrade each copy.  If it's not automated, each user is responsible, which now involves downloading the update twice.  Pretty soon, we'd be fighting a drive-space issue.

Quote
Now the big thing. Each library that has a dynamic dll that is for a major project, submits their latest dynamic library and headers to the OS maker. They in turn in updates install these into the OS system.

That's sort of what happens now, if you think about it.  Keep in mind, thought, that all sorts of regression testing has to take place, which is why all distro's may not have the latest and greatest SW/Libraries available.

Quote
For a dynamic library a user makes, that would be in their choice of how they want to store dll's and headers.

Then you would have to contend with additional compiler and linker switches, so that your software can find the libraries and headers.

Quote
The last big things is that the OS can talk to new hardware, download the interface, dll and header to make that device work from the firmware of the hardware. So any OS designed with this interface to query and get stuff from the firmware can support the hardware.

Hardware is proprietary; it falls to the hardware producer to create the drivers for a given OS.  How would you even begin to manage that, since most Linux distributions aren't heavily funded?

Even Microsoft can't do this 100%; it's a logistical and monetary nightmare.  Sure, you can go with reference drivers released by the manufacturer, but you would probably want to go with what the Vendor provides instead.

Take Graphic cards, for example.  A Vendor may have added an enhancement that the reference drivers don't support.  So now, using ATI as an example, you have to provide drivers for just about every conceivable Vendor implementation. 

All in all, your ideas are interesting, but (just my opinion) they aren't practical.

AIR.
Title: Nimrod - C9 Red Hat Project
Post by: John on October 07, 2013, 10:13:18 PM
I created a Nimrod Red Hat 64 bit project on Cloud9 IDE (https://c9.io/scriptbasic/nimrod). I built Nimrod from scratch using git.

Nimrod git build log (http://files.allbasic.info/Nimrod/c9_nimrod_compile.txt)

Babel
Code: [Select]
scriptbasic@nimrod:~/639761/Nimrod/babel-master (master) $ ls -l
total 72
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   207 Oct  5 14:14 babel.babel
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0 12080 Oct  5 14:14 babel.nim
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0     7 Oct  5 14:14 babel.nimrod.cfg
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   314 Oct  5 14:14 common.nim
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  4031 Oct  5 14:14 download.nim
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  1624 Oct  5 14:14 license.txt
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  8680 Oct  5 14:14 packageinfo.nim
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  8949 Oct  5 14:14 readme.markdown
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   603 Oct  5 14:14 todo.markdown
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  1681 Oct  5 14:14 tools.nim
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  6503 Oct  5 14:14 version.nim
scriptbasic@nimrod:~/639761/Nimrod/babel-master (master) $ nimrod c -d:release babel.nim
config/nimrod.cfg(36, 2) Hint: added path: '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/' [Path]
Hint: used config file '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/config/nimrod.cfg' [Conf]
Hint: used config file '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel.nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: babel [Processing]
Hint: httpclient [Processing]
Hint: sockets [Processing]
Hint: os [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: times [Processing]
Hint: posix [Processing]
Hint: openssl [Processing]
Hint: parseurl [Processing]
Hint: strtabs [Processing]
Hint: hashes [Processing]
Hint: base64 [Processing]
Hint: parseopt [Processing]
Hint: osproc [Processing]
Hint: streams [Processing]
Hint: pegs [Processing]
Hint: unicode [Processing]
Hint: tables [Processing]
Hint: math [Processing]
Hint: packageinfo [Processing]
Hint: parsecfg [Processing]
Hint: lexbase [Processing]
Hint: json [Processing]
Hint: version [Processing]
Hint: common [Processing]
babel-master/packageinfo.nim(141, 5) Warning: 'existsKey' is deprecated [Deprecated]
babel-master/packageinfo.nim(149, 5) Warning: 'existsKey' is deprecated [Deprecated]
Hint: tools [Processing]
Hint: download [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/babel-master_babel.o babel-master/nimcache/babel-master_babel.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/Nimrod_system.o babel-master/nimcache/Nimrod_system.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_httpclient.o babel-master/nimcache/pure_httpclient.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_sockets.o babel-master/nimcache/pure_sockets.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_os.o babel-master/nimcache/pure_os.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_strutils.o babel-master/nimcache/pure_strutils.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_parseutils.o babel-master/nimcache/pure_parseutils.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_times.o babel-master/nimcache/pure_times.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/posix_posix.o babel-master/nimcache/posix_posix.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/wrappers_openssl.o babel-master/nimcache/wrappers_openssl.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_parseurl.o babel-master/nimcache/pure_parseurl.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_strtabs.o babel-master/nimcache/pure_strtabs.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_hashes.o babel-master/nimcache/pure_hashes.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_base64.o babel-master/nimcache/pure_base64.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_parseopt.o babel-master/nimcache/pure_parseopt.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_osproc.o babel-master/nimcache/pure_osproc.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_streams.o babel-master/nimcache/pure_streams.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_pegs.o babel-master/nimcache/pure_pegs.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_unicode.o babel-master/nimcache/pure_unicode.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/collections_tables.o babel-master/nimcache/collections_tables.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_math.o babel-master/nimcache/pure_math.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/babel-master_packageinfo.o babel-master/nimcache/babel-master_packageinfo.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_parsecfg.o babel-master/nimcache/pure_parsecfg.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_lexbase.o babel-master/nimcache/pure_lexbase.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_json.o babel-master/nimcache/pure_json.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/babel-master_version.o babel-master/nimcache/babel-master_version.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/babel-master_common.o babel-master/nimcache/babel-master_common.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/babel-master_tools.o babel-master/nimcache/babel-master_tools.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/babel-master_download.o babel-master/nimcache/babel-master_download.c
gcc   -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel  babel-master/nimcache/babel-master_download.o babel-master/nimcache/babel-master_tools.o babel-master/nimcache/babel-master_common.o babel-master/nimcache/babel-master_version.o babel-master/nimcache/pure_json.o babel-master/nimcache/pure_lexbase.o babel-master/nimcache/pure_parsecfg.o babel-master/nimcache/babel-master_packageinfo.o babel-master/nimcache/pure_math.o babel-master/nimcache/collections_tables.o babel-master/nimcache/pure_unicode.o babel-master/nimcache/pure_pegs.o babel-master/nimcache/pure_streams.o babel-master/nimcache/pure_osproc.o babel-master/nimcache/pure_parseopt.o babel-master/nimcache/pure_base64.o babel-master/nimcache/pure_hashes.o babel-master/nimcache/pure_strtabs.o babel-master/nimcache/pure_parseurl.o babel-master/nimcache/wrappers_openssl.o babel-master/nimcache/posix_posix.o babel-master/nimcache/pure_times.o babel-master/nimcache/pure_parseutils.o babel-master/nimcache/pure_strutils.o babel-master/nimcache/pure_os.o babel-master/nimcache/pure_sockets.o babel-master/nimcache/pure_httpclient.o babel-master/nimcache/Nimrod_system.o babel-master/nimcache/babel-master_babel.o  -ldl -lm
Hint: operation successful (25622 lines compiled; 10.480 sec total; 44.455MB) [SuccessX]
scriptbasic@nimrod:~/639761/Nimrod/babel-master (master) $ ./babel install
Installing babel-0.1.0
Building babel/babel using c backend...
config/nimrod.cfg(36, 2) Hint: added path: '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/' [Path]
Hint: used config file '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/config/nimrod.cfg' [Conf]
Hint: used config file '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel.nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: babel [Processing]
Hint: httpclient [Processing]
Hint: sockets [Processing]
Hint: os [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: times [Processing]
Hint: posix [Processing]
Hint: openssl [Processing]
Hint: parseurl [Processing]
Hint: strtabs [Processing]
Hint: hashes [Processing]
Hint: base64 [Processing]
Hint: parseopt [Processing]
Hint: osproc [Processing]
Hint: streams [Processing]
Hint: pegs [Processing]
Hint: unicode [Processing]
Hint: tables [Processing]
Hint: math [Processing]
Hint: packageinfo [Processing]
Hint: parsecfg [Processing]
Hint: lexbase [Processing]
Hint: json [Processing]
Hint: version [Processing]
Hint: common [Processing]
babel-master/packageinfo.nim(141, 5) Warning: 'existsKey' is deprecated [Deprecated]
babel-master/packageinfo.nim(149, 5) Warning: 'existsKey' is deprecated [Deprecated]
Hint: tools [Processing]
Hint: download [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/babel-master_babel.o babel-master/nimcache/babel-master_babel.c
gcc   -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel  babel-master/nimcache/babel-master_download.o babel-master/nimcache/babel-master_tools.o babel-master/nimcache/babel-master_common.o babel-master/nimcache/babel-master_version.o babel-master/nimcache/pure_json.o babel-master/nimcache/pure_lexbase.o babel-master/nimcache/pure_parsecfg.o babel-master/nimcache/babel-master_packageinfo.o babel-master/nimcache/pure_math.o babel-master/nimcache/collections_tables.o babel-master/nimcache/pure_unicode.o babel-master/nimcache/pure_pegs.o babel-master/nimcache/pure_streams.o babel-master/nimcache/pure_osproc.o babel-master/nimcache/pure_parseopt.o babel-master/nimcache/pure_base64.o babel-master/nimcache/pure_hashes.o babel-master/nimcache/pure_strtabs.o babel-master/nimcache/pure_parseurl.o babel-master/nimcache/wrappers_openssl.o babel-master/nimcache/posix_posix.o babel-master/nimcache/pure_times.o babel-master/nimcache/pure_parseutils.o babel-master/nimcache/pure_strutils.o babel-master/nimcache/pure_os.o babel-master/nimcache/pure_sockets.o babel-master/nimcache/pure_httpclient.o babel-master/nimcache/Nimrod_system.o babel-master/nimcache/babel-master_babel.o  -ldl -lm
Hint: operation successful (25622 lines compiled; 1.524 sec total; 44.455MB) [SuccessX]
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/license.txt -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/license.txt
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/download.nim -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/download.nim
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/common.nim -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/common.nim
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel.babel -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/babel.babel
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel.nimrod.cfg -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/babel.nimrod.cfg
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel.babel -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/babel.babel
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/tools.nim -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/tools.nim
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel.nim -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/babel.nim
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/packageinfo.nim -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/packageinfo.nim
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/babel
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/todo.markdown -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/todo.markdown
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/version.nim -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/version.nim
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/readme.markdown -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/readme.markdown
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel.babel -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/babel.babel
Creating symlink: /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/babel -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/bin/babel
babel installed successfully.
scriptbasic@nimrod:~/639761/Nimrod/babel-master (master) $ ./babel -h
Usage: babel COMMAND [opts]

Commands:
  install      [pkgname, ...] Installs a list of packages.
  build                       Builds a package.
  update       [url]          Updates package list. A package list URL can be optionally specified.
  search       pkg/tag        Searches for a specified package. Search is performed by tag and by name.
  list                        Lists all packages.

Options:
  -h                          Print this help message.
  -v                          Print version information.

scriptbasic@nimrod:~/639761/Nimrod/babel-master (master) $ ./babel update
Downloading package list from https://github.com/nimrod-code/packages/raw/master/packages.json
Done.
scriptbasic@nimrod:~/639761/Nimrod/babel-master (master) $ ./babel build
Building babel/babel using c backend...
config/nimrod.cfg(36, 2) Hint: added path: '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0' [Path]
config/nimrod.cfg(36, 2) Hint: added path: '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/' [Path]
Hint: used config file '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/config/nimrod.cfg' [Conf]
Hint: used config file '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel.nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: babel [Processing]
Hint: httpclient [Processing]
Hint: sockets [Processing]
Hint: os [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: times [Processing]
Hint: posix [Processing]
Hint: openssl [Processing]
Hint: parseurl [Processing]
Hint: strtabs [Processing]
Hint: hashes [Processing]
Hint: base64 [Processing]
Hint: parseopt [Processing]
Hint: osproc [Processing]
Hint: streams [Processing]
Hint: pegs [Processing]
Hint: unicode [Processing]
Hint: tables [Processing]
Hint: math [Processing]
Hint: packageinfo [Processing]
Hint: parsecfg [Processing]
Hint: lexbase [Processing]
Hint: json [Processing]
Hint: version [Processing]
Hint: common [Processing]
babel-master/packageinfo.nim(141, 5) Warning: 'existsKey' is deprecated [Deprecated]
babel-master/packageinfo.nim(149, 5) Warning: 'existsKey' is deprecated [Deprecated]
Hint: tools [Processing]
Hint: download [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/babel-master_babel.o babel-master/nimcache/babel-master_babel.c
gcc   -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel  babel-master/nimcache/babel-master_download.o babel-master/nimcache/babel-master_tools.o babel-master/nimcache/babel-master_common.o babel-master/nimcache/babel-master_version.o babel-master/nimcache/pure_json.o babel-master/nimcache/pure_lexbase.o babel-master/nimcache/pure_parsecfg.o babel-master/nimcache/babel-master_packageinfo.o babel-master/nimcache/pure_math.o babel-master/nimcache/collections_tables.o babel-master/nimcache/pure_unicode.o babel-master/nimcache/pure_pegs.o babel-master/nimcache/pure_streams.o babel-master/nimcache/pure_osproc.o babel-master/nimcache/pure_parseopt.o babel-master/nimcache/pure_base64.o babel-master/nimcache/pure_hashes.o babel-master/nimcache/pure_strtabs.o babel-master/nimcache/pure_parseurl.o babel-master/nimcache/wrappers_openssl.o babel-master/nimcache/posix_posix.o babel-master/nimcache/pure_times.o babel-master/nimcache/pure_parseutils.o babel-master/nimcache/pure_strutils.o babel-master/nimcache/pure_os.o babel-master/nimcache/pure_sockets.o babel-master/nimcache/pure_httpclient.o babel-master/nimcache/Nimrod_system.o babel-master/nimcache/babel-master_babel.o  -ldl -lm
Hint: operation successful (25622 lines compiled; 1.530 sec total; 44.455MB) [SuccessX]
scriptbasic@nimrod:~/639761/Nimrod/babel-master (master) $ ./babel list
argument_parser:
  url:         git://github.com/gradha/argument_parser/ (git)
  tags:        library, commandline, arguments, switches, parsing
  description: Provides a complex commandline parser
  license:     MIT
 
genieos:
  url:         git://github.com/gradha/genieos/ (git)
  tags:        library, commandline, sound, recycle, os
  description: Too awesome procs to be included in nimrod.os module
  license:     MIT
 
jester:
  url:         git://github.com/dom96/jester/ (git)
  tags:        web, http, framework, dsl
  description: A sinatra-like web framework for Nimrod.
  license:     MIT
 
libtcod-nim:
  url:         git://github.com/Vladar4/libtcod-nim/ (git)
  tags:        roguelike, game, library, engine, sdl, opengl, glsl
  description: Wrapper of the libtcod library for the Nimrod language.
  license:     MIT
 
nimepak:
  url:         git://github.com/gradha/epak/ (git)
  tags:        library, serialization, file, compression
  description: File compression routines in C for iOS and Nimrod
  license:     Allegro 4 Giftware
 
nimgame:
  url:         git://github.com/Vladar4/nimgame/ (git)
  tags:        game, engine, sdl
  description: Simple 2D game engine for Nimrod language.
  license:     MIT
 
sfml:
  url:         git://github.com/fowlmouth/nimrod-sfml/ (git)
  tags:        game, library, opengl
  description: High level OpenGL-based Game Library
  license:     MIT
 
enet:
  url:         git://github.com/fowlmouth/nimrod-enet/ (git)
  tags:        game, networking, udp
  description: Wrapper for ENet UDP networking library
  license:     MIT
 
nim-locale:
  url:         git://github.com/Amrykid/nim-locale/ (git)
  tags:        library, locale, i18n, localization, localisation, globalization
  description: A simple library for localizing Nimrod applications.
  license:     MIT
 
fowltek:
  url:         git://github.com/fowlmouth/nimlibs/ (git)
  tags:        game, opengl, wrappers, library, assorted
  description: A collection of reusable modules and wrappers.
  license:     MIT
 
nake:
  url:         git://github.com/fowlmouth/nake/ (git)
  tags:        build, automation, sortof
  description: make-like for Nimrod. Describe your builds as tasks!
  license:     DATWPL
 
nimrod-glfw:
  url:         git://github.com/rafaelvasco/nimrod-glfw/ (git)
  tags:        library, glfw, opengl, windowing, game
  description: Nimrod bindings for GLFW library.
  license:     MIT
 
chipmunk:
  url:         git://github.com/fowlmouth/nimrod-chipmunk/ (git)
  tags:        library, physics, game
  description: Binding for Chipmunk 6.1
  license:     MIT
 
nim-glfw3:
  url:         git://github.com/EXetoC/nim-glfw3/ (git)
  tags:        library, glfw, opengl, windowing, game
  description: A High-level GLFW 3 wrapper for the Nimrod programming language
  license:     MIT
 
nim-ao:
  url:         git://github.com/EXetoC/nim-ao/ (git)
  tags:        library, audio
  description: A libao wrapper for the Nimrod programming language
  license:     MIT
 
termbox:
  url:         git://github.com/fowlmouth/nim-termbox (git)
  tags:        library, terminal, io
  description: Termbox wrapper.
  license:     MIT
 
linagl:
  url:         https://bitbucket.org/TheLonelyByte/linagl (hg)
  tags:        library, opengl, math, game
  description: OpenGL math library
  license:     CC0
 
kwin:
  url:         git://github.com/reactormonk/nim-kwin (git)
  tags:        library, javascript, kde
  description: KWin JavaScript API wrapper
  license:     MIT
 
opencv:
  url:         git://github.com/dom96/nim-opencv (git)
  tags:        library, wrapper, opencv, image, processing
  description: OpenCV wrapper
  license:     MIT
 
babel:
  url:         git://github.com/nimrod-code/babel (git)
  tags:        app, binary, package, manager
  description: Babel package manager
  license:     BSD
 
aporia:
  url:         git://github.com/nimrod-code/Aporia (git)
  tags:        app, binary, ide, gtk, nimrod
  description: A Nimrod IDE.
  license:     GPLv2
 
ipsumgenera:
  url:         git://github.com/dom96/ipsumgenera (git)
  tags:        app, binary, blog, static, generator
  description: Static blog generator ala Jekyll.
  license:     MIT
 
pastebin:
  url:         git://github.com/achesak/nimrod-pastebin (git)
  tags:        library, wrapper, pastebin
  description: Pastebin API wrapper
  license:     MIT
 
yahoo-weather:
  url:         git://github.com/achesak/nimrod-yahoo-weather (git)
  tags:        library, wrapper, weather
  description: Yahoo! Weather API wrapper
  license:     MIT
 
scriptbasic@nimrod:~/639761/Nimrod/babel-master (master) $

cairoex
Code: [Select]
import cairo

var surface = image_surface_create(FORMAT_ARGB32, 240, 80)
var cr = create(surface)

select_font_face(cr, "serif", FONT_SLANT_NORMAL,
                              FONT_WEIGHT_BOLD)
set_font_size(cr, 32.0)
set_source_rgb(cr, 0.0, 0.0, 1.0)
move_to(cr, 10.0, 50.0)
show_text(cr, "Hello, world")
destroy(cr)
discard write_to_png(surface, "hello.png")
destroy(surface)


criptbasic@nimrod:~/639761/Nimrod/examples (master) $ nimrod c -d:release cairoex.nim
config/nimrod.cfg(36, 2) Hint: added path: '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0' [Path]
config/nimrod.cfg(36, 2) Hint: added path: '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/' [Path]
Hint: used config file '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: cairoex [Processing]
Hint: cairo [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o examples/nimcache/examples_cairoex.o examples/nimcac
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o examples/nimcache/Nimrod_system.o examples/nimcache/
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o examples/nimcache/cairo_cairo.o examples/nimcache/ca
gcc   -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/examples/cairoex  examples/nimcache/cairo_cairo.o examples/nimcache/Nimrod_system.o exa
Hint: operation successful (8439 lines compiled; 6.252 sec total; 9.922MB) [SuccessX]
scriptbasic@nimrod:~/639761/Nimrod/examples (master) $

(http://files.allbasic.info/Nimrod/c9_ciaro.png)
Title: Nimrod - nimgame
Post by: John on October 08, 2013, 12:08:51 AM
nimgame

Simple 2D game engine for Nimrod language.

This is a Babel installed library. I have posted the API docs HERE (http://files.allbasic.info/Nimrod/nimgame/index.html).

UFO Attack nimgame API Windows example.

(http://files.allbasic.info/Nimrod/nimgame_ufo.png)

Code: [Select]
import
  sdl, math, common, state, entity, image, imageex, sprite, text, input, engine, collider,
  ufoattack_player, ufoattack_ufo, ufoattack_stars

type
  PGameState* = ref TGameState
  TGameState* = object of TState
    player: PPlayer
    score: PEntity
    addStarCounter, addStarInterval: int
    addStarIntervalMin, addStarIntervalMax, addStarNum: int
    addUfoCounter, addUfoInterval: int


proc free*(obj: PGameState) =
  PState(obj).free()


proc init*(obj: PGameState) =
  obj.player = newPlayer(obj)
  obj.add(obj.player)
  obj.score = newEntity(newText("fnt/DejaVuSans.ttf", text="0",
                                size=18, color=color(250, 250, 0)),
                        2, 580)
  obj.add(obj.score)
  # stars
  initStars()
  obj.addStarCounter = 0
  obj.addStarIntervalMin = 10
  obj.addStarIntervalMax = 30
  obj.addStarInterval = random(obj.addStarIntervalMax - obj.addStarIntervalMin) + obj.addStarIntervalMin
  obj.addStarNum = 3
  for i in 0..50:
    addStar(random(screen().h))
  # ufo
  obj.addUfoCounter = 0
  obj.addUfoInterval = 50

proc newGameState*(): PGameState =
  new(result, free)
  init(PState(result))
  init(result)


# Update

proc updateGameState*(obj: PGameState) =
  obj.updateState()
  # Stars
  if obj.addStarCounter >= obj.addStarInterval:
    for i in 0..random(obj.addStarNum):
      addStar()
    obj.addStarCounter = 0
    obj.addStarInterval = random(obj.addStarIntervalMax - obj.addStarIntervalMin) + obj.addStarIntervalMin
  else:
    obj.addStarCounter += 1
  updateStars()
  # Ufo
  if obj.addUfoCounter >= obj.addUfoInterval:
    obj.add(newUfo(4))
    obj.addUfoCounter = 0
  else:
    obj.addUfoCounter += 1
  # Collide
  if obj.collideWith(obj.player, "ufo") != nil:
    obj.player.delete()
  let collisions = obj.collideList("shot", "ufo")
  for pair in collisions.items():
    pair.a.delete()
    pair.b.delete()
    obj.player.score += 10
  # Update score
  PText(obj.score.graphic).text = obj.player.score.repr
  # Toggle FPS
  if isKeyDown(K_f):
    if game.fps:
      game.fps = false
    else:
      game.fps = true

method update*(obj: PGameState) {.inline.} =
  obj.updateGameState()

# Render

proc renderGameState*(obj: PGameState) =
  blitStars()
  obj.renderState()

method render*(obj: PGameState) {.inline.} =
  obj.renderGameState()
Title: Nimrod - Inline ASM
Post by: John on October 08, 2013, 02:01:31 AM
Assembler statement

The direct embedding of assembler code into Nimrod code is supported by the unsafe asm statement. Identifiers in the assembler code that refer to Nimrod identifiers shall be enclosed in a special character which can be specified in the statement's pragmas. The default special character is '`':

Code: [Select]
proc addInt(a, b: int): int {.noStackFrame.} =
  # a in eax, and b in edx
  asm """
      mov eax, `a`
      add eax, `b`
      jno theEnd
      call `raiseOverflow`
    theEnd:
  """

I would think that Nimrod would be a much better language for Charles to use for OxygenBasic. He could use Nimrod to handle the platform specifics while he gets cross platform ASM code stable. The C emitter is already done for him.

arithm.nim (std lib)
Code: [Select]
#
#
#            Nimrod's Runtime Library
#        (c) Copyright 2012 Andreas Rumpf
#
#    See the file "copying.txt", included in this
#    distribution, for details about the copyright.
#


# simple integer arithmetic with overflow checking

proc raiseOverflow {.compilerproc, noinline, noreturn.} =
  # a single proc to reduce code size to a minimum
  sysFatal(EOverflow, "over- or underflow")

proc raiseDivByZero {.compilerproc, noinline, noreturn.} =
  sysFatal(EDivByZero, "divison by zero")

proc addInt64(a, b: int64): int64 {.compilerProc, inline.} =
  result = a +% b
  if (result xor a) >= int64(0) or (result xor b) >= int64(0):
    return result
  raiseOverflow()

proc subInt64(a, b: int64): int64 {.compilerProc, inline.} =
  result = a -% b
  if (result xor a) >= int64(0) or (result xor not b) >= int64(0):
    return result
  raiseOverflow()

proc negInt64(a: int64): int64 {.compilerProc, inline.} =
  if a != low(int64): return -a
  raiseOverflow()

proc absInt64(a: int64): int64 {.compilerProc, inline.} =
  if a != low(int64):
    if a >= 0: return a
    else: return -a
  raiseOverflow()

proc divInt64(a, b: int64): int64 {.compilerProc, inline.} =
  if b == int64(0):
    raiseDivByZero()
  if a == low(int64) and b == int64(-1):
    raiseOverflow()
  return a div b

proc modInt64(a, b: int64): int64 {.compilerProc, inline.} =
  if b == int64(0):
    raiseDivByZero()
  return a mod b

#
# This code has been inspired by Python's source code.
# The native int product x*y is either exactly right or *way* off, being
# just the last n bits of the true product, where n is the number of bits
# in an int (the delivered product is the true product plus i*2**n for
# some integer i).
#
# The native float64 product x*y is subject to three
# rounding errors: on a sizeof(int)==8 box, each cast to double can lose
# info, and even on a sizeof(int)==4 box, the multiplication can lose info.
# But, unlike the native int product, it's not in *range* trouble:  even
# if sizeof(int)==32 (256-bit ints), the product easily fits in the
# dynamic range of a float64. So the leading 50 (or so) bits of the float64
# product are correct.
#
# We check these two ways against each other, and declare victory if they're
# approximately the same. Else, because the native int product is the only
# one that can lose catastrophic amounts of information, it's the native int
# product that must have overflowed.
#
proc mulInt64(a, b: int64): int64 {.compilerproc.} =
  var
    resAsFloat, floatProd: float64
  result = a *% b
  floatProd = toBiggestFloat(a) # conversion
  floatProd = floatProd * toBiggestFloat(b)
  resAsFloat = toBiggestFloat(result)

  # Fast path for normal case: small multiplicands, and no info
  # is lost in either method.
  if resAsFloat == floatProd: return result

  # Somebody somewhere lost info. Close enough, or way off? Note
  # that a != 0 and b != 0 (else resAsFloat == floatProd == 0).
  # The difference either is or isn't significant compared to the
  # true value (of which floatProd is a good approximation).

  # abs(diff)/abs(prod) <= 1/32 iff
  #   32 * abs(diff) <= abs(prod) -- 5 good bits is "close enough"
  if 32.0 * abs(resAsFloat - floatProd) <= abs(floatProd):
    return result
  raiseOverflow()


proc absInt(a: int): int {.compilerProc, inline.} =
  if a != low(int):
    if a >= 0: return a
    else: return -a
  raiseOverflow()

const
  asmVersion = defined(I386) and (defined(vcc) or defined(wcc) or
               defined(dmc) or defined(gcc) or defined(llvm_gcc))
    # my Version of Borland C++Builder does not have
    # tasm32, which is needed for assembler blocks
    # this is why Borland is not included in the 'when'

when asmVersion and not defined(gcc) and not defined(llvm_gcc):
  # assembler optimized versions for compilers that
  # have an intel syntax assembler:
  proc addInt(a, b: int): int {.compilerProc, noStackFrame.} =
    # a in eax, and b in edx
    asm """
        mov eax, `a`
        add eax, `b`
        jno theEnd
        call `raiseOverflow`
      theEnd:
    """

  proc subInt(a, b: int): int {.compilerProc, noStackFrame.} =
    asm """
        mov eax, `a`
        sub eax, `b`
        jno theEnd
        call `raiseOverflow`
      theEnd:
    """

  proc negInt(a: int): int {.compilerProc, noStackFrame.} =
    asm """
        mov eax, `a`
        neg eax
        jno theEnd
        call `raiseOverflow`
      theEnd:
    """

  proc divInt(a, b: int): int {.compilerProc, noStackFrame.} =
    asm """
        mov eax, `a`
        mov ecx, `b`
        xor edx, edx
        idiv ecx
        jno  theEnd
        call `raiseOverflow`
      theEnd:
    """

  proc modInt(a, b: int): int {.compilerProc, noStackFrame.} =
    asm """
        mov eax, `a`
        mov ecx, `b`
        xor edx, edx
        idiv ecx
        jno theEnd
        call `raiseOverflow`
      theEnd:
        mov eax, edx
    """

  proc mulInt(a, b: int): int {.compilerProc, noStackFrame.} =
    asm """
        mov eax, `a`
        mov ecx, `b`
        xor edx, edx
        imul ecx
        jno theEnd
        call `raiseOverflow`
      theEnd:
    """

elif false: # asmVersion and (defined(gcc) or defined(llvm_gcc)):
  proc addInt(a, b: int): int {.compilerProc, inline.} =
    # don't use a pure proc here!
    asm """
      "addl %%ecx, %%eax\n"
      "jno 1\n"
      "call _raiseOverflow\n"
      "1: \n"
      :"=a"(`result`)
      :"a"(`a`), "c"(`b`)
    """
    #".intel_syntax noprefix"
    #/* Intel syntax here */
    #".att_syntax"

  proc subInt(a, b: int): int {.compilerProc, inline.} =
    asm """ "subl %%ecx,%%eax\n"
            "jno 1\n"
            "call _raiseOverflow\n"
            "1: \n"
           :"=a"(`result`)
           :"a"(`a`), "c"(`b`)
    """

  proc mulInt(a, b: int): int {.compilerProc, inline.} =
    asm """  "xorl %%edx, %%edx\n"
             "imull %%ecx\n"
             "jno 1\n"
             "call _raiseOverflow\n"
             "1: \n"
            :"=a"(`result`)
            :"a"(`a`), "c"(`b`)
            :"%edx"
    """

  proc negInt(a: int): int {.compilerProc, inline.} =
    asm """ "negl %%eax\n"
            "jno 1\n"
            "call _raiseOverflow\n"
            "1: \n"
           :"=a"(`result`)
           :"a"(`a`)
    """

  proc divInt(a, b: int): int {.compilerProc, inline.} =
    asm """  "xorl %%edx, %%edx\n"
             "idivl %%ecx\n"
             "jno 1\n"
             "call _raiseOverflow\n"
             "1: \n"
            :"=a"(`result`)
            :"a"(`a`), "c"(`b`)
            :"%edx"
    """

  proc modInt(a, b: int): int {.compilerProc, inline.} =
    asm """  "xorl %%edx, %%edx\n"
             "idivl %%ecx\n"
             "jno 1\n"
             "call _raiseOverflow\n"
             "1: \n"
             "movl %%edx, %%eax"
            :"=a"(`result`)
            :"a"(`a`), "c"(`b`)
            :"%edx"
    """

# Platform independent versions of the above (slower!)
when not defined(addInt):
  proc addInt(a, b: int): int {.compilerProc, inline.} =
    result = a +% b
    if (result xor a) >= 0 or (result xor b) >= 0:
      return result
    raiseOverflow()

when not defined(subInt):
  proc subInt(a, b: int): int {.compilerProc, inline.} =
    result = a -% b
    if (result xor a) >= 0 or (result xor not b) >= 0:
      return result
    raiseOverflow()

when not defined(negInt):
  proc negInt(a: int): int {.compilerProc, inline.} =
    if a != low(int): return -a
    raiseOverflow()

when not defined(divInt):
  proc divInt(a, b: int): int {.compilerProc, inline.} =
    if b == 0:
      raiseDivByZero()
    if a == low(int) and b == -1:
      raiseOverflow()
    return a div b

when not defined(modInt):
  proc modInt(a, b: int): int {.compilerProc, inline.} =
    if b == 0:
      raiseDivByZero()
    return a mod b

when not defined(mulInt):
  #
  # This code has been inspired by Python's source code.
  # The native int product x*y is either exactly right or *way* off, being
  # just the last n bits of the true product, where n is the number of bits
  # in an int (the delivered product is the true product plus i*2**n for
  # some integer i).
  #
  # The native float64 product x*y is subject to three
  # rounding errors: on a sizeof(int)==8 box, each cast to double can lose
  # info, and even on a sizeof(int)==4 box, the multiplication can lose info.
  # But, unlike the native int product, it's not in *range* trouble:  even
  # if sizeof(int)==32 (256-bit ints), the product easily fits in the
  # dynamic range of a float64. So the leading 50 (or so) bits of the float64
  # product are correct.
  #
  # We check these two ways against each other, and declare victory if
  # they're approximately the same. Else, because the native int product is
  # the only one that can lose catastrophic amounts of information, it's the
  # native int product that must have overflowed.
  #
  proc mulInt(a, b: int): int {.compilerProc.} =
    var
      resAsFloat, floatProd: float

    result = a *% b
    floatProd = toFloat(a) * toFloat(b)
    resAsFloat = toFloat(result)

    # Fast path for normal case: small multiplicands, and no info
    # is lost in either method.
    if resAsFloat == floatProd: return result

    # Somebody somewhere lost info. Close enough, or way off? Note
    # that a != 0 and b != 0 (else resAsFloat == floatProd == 0).
    # The difference either is or isn't significant compared to the
    # true value (of which floatProd is a good approximation).

    # abs(diff)/abs(prod) <= 1/32 iff
    #   32 * abs(diff) <= abs(prod) -- 5 good bits is "close enough"
    if 32.0 * abs(resAsFloat - floatProd) <= abs(floatProd):
      return result
    raiseOverflow()

# We avoid setting the FPU control word here for compatibility with libraries
# written in other languages.

proc raiseFloatInvalidOp {.noinline, noreturn.} =
  sysFatal(EFloatInvalidOp, "FPU operation caused a NaN result")

proc nanCheck(x: float64) {.compilerProc, inline.} =
  if x != x: raiseFloatInvalidOp()

proc raiseFloatOverflow(x: float64) {.noinline, noreturn.} =
  if x > 0.0:
    sysFatal(EFloatOverflow, "FPU operation caused an overflow")
  else:
    sysFatal(EFloatUnderflow, "FPU operations caused an underflow")

proc infCheck(x: float64) {.compilerProc, inline.} =
  if x != 0.0 and x*0.5 == x: raiseFloatOverflow(x)


Those """'s sure look familiar.  :)
Title: Other libraries
Post by: kryton9 on October 10, 2013, 07:11:01 PM
I found today while researching that other libraries(wrappers) do exist for Nimrod that are not listed in their list.
So something to keep in mind, if there is a library you would like to use that is not on the list.
The current list: http://nimrod-code.org/lib.html

Here is one I found today:
https://github.com/fowlmouth/nimrod-sfml



Title: Re: Nimrod
Post by: John on October 10, 2013, 08:25:09 PM
Here are a couple screen shots from their included demos. I had to install an older version (1.5 / current 1.6) of GLEW to get it to run.

Title: Re: Nimrod
Post by: kryton9 on October 10, 2013, 09:09:05 PM
Thanks John, glad to know it works.
Title: Re: Nimrod
Post by: AIR on October 13, 2013, 04:27:30 PM
Quick tip:  Even though you can generate the html documentation files for the included libraries when you download the source, they're not complete due to the size of the complete set (about 34M).

If you want to get a complete set of the current STABLE library docs, use wget:

Code: [Select]
wget -rl 2 http://nimrod-code.org/lib.html
This is especially useful for viewing offline.

A.
Title: Re: Nimrod
Post by: John on October 13, 2013, 05:10:19 PM
Thanks for the tip AIR!

Is there a current Doxygen for Nimrod floating around?
Title: Re: Nimrod
Post by: kryton9 on October 13, 2013, 06:24:41 PM
Thanks AIR this will help a lot!
Title: Re: Nimrod
Post by: kryton9 on October 13, 2013, 10:59:15 PM
I was getting an error about unable to resolve host on Ubuntu Server when I tried entering AIR's wget command.

Found out when you have to add DNS servers in your /etc/network/interfaces
So I added these to the end of the file and restarted the VM of Ubuntu Server and it worked.
dns-nameservers 8.8.8.8 8.8.4.4

These are Google's name servers.
Title: Re: Nimrod
Post by: John on October 14, 2013, 01:05:33 AM
AIR's wget worked fine for me as is.

FINISHED --2013-10-14 01:05:36--
Total wall clock time: 1m 32s
Downloaded: 167 files, 34M in 59s (582 KB/s)
jrs@laptop:~/nimrod/full_html_docs$
Title: Re: Nimrod
Post by: kryton9 on October 15, 2013, 03:01:09 PM
Found this today too while reading Nimrod's forums.

Jester
The sinatra-like web framework for Nimrod. Jester provides a DSL for quickly creating web applications in Nimrod, it currently mimics sinatra almost completely:

Code: Text
  1. # myapp.nim
  2. import jester, strtabs, htmlgen
  3.  
  4. get "/":
  5.   resp h1("Hello world")
  6.  
  7. run()
Compile and run with:

nimrod c -r myapp.nim

https://github.com/dom96/jester
Title: Re: Nimrod
Post by: John on October 15, 2013, 04:31:55 PM
I briefly saw the Jester API but haven't had time to look at it in detail.

Update - After taking a second look at the Nimrod interface to Jester / Sinatra, it looks like a Ruby scripting front end. I have heard good and bad things about Ruby. I haven't spent any time with Ruby so I can't give an opinion either way.

What does interest me is Nimrod's ability to generate JavaScript as well as C and a couple others. Cloud9 IDE is written in JavaScript. (using Node.js) Being able to create client side web applications in a language native to all browsers makes Nimrod the more valuable and the right language to develop with.

@ALL - If you want developer access to the Cloud9 IDE site for this project, you need to let me know with a post here or an e-mail. I'm not granting access to strangers.

Title: Re: Nimrod
Post by: John on October 15, 2013, 07:22:47 PM
Quote from: Daniel
I just released uCalc Transform just moments ago.  Sorry for the delay in response.  I plan to take a look at this thread & other messages and get back with everybody tomorrow.  I'm interested in this project.

Thanks for your interest in the BAS2NIM project. I'm looking forward to seeing what you are able to come up with translating BASIC code to Nimrod.

Quote from: uCalc Transform page (http://www.ucalc.com/transform.html)
uCalc Transform is an innovative tool designed to let you transform text in unprecedented ways. Some of the things you might use it for include:
  • Converting old legacy source code to a new format
  • Refactoring source code
  • Translating source code from one programming language to another
  • Convert text between various formats: XML, HTML, CSV, JSON, etc.
  • Automating repetitive search replace operations on any text
  • Advanced search/replace using patterns instead of just words

(http://www.ucalc.com/images/transform.gif)
Title: Re: Nimrod
Post by: AIR on October 27, 2013, 02:28:34 PM
I wanted to see how easy or hard it would be do try the old wordcount challenge in Nimrod, so I gave it a go.

It's not quite finished, because it doesn't tally the number of individual word occurrences, but I still found it fairly easy to get to this point.

Code: [Select]
Import os,  strutils

proc QuickSort*(list: seq[string]): seq[string] =

    if list.len == 0:
        return @[]
    var pivot = list[0]
    var left,right: seq[string] = @[]
   
    for value in list:
        if value < pivot:
            left.add(value)     
        elif value > pivot:
            right.add(value)

    result = QuickSort(left) & pivot & QuickSort(right)
     

 
if existsFile("kjv.txt"):
    let src = readFile("kjv.txt")
   
    let separators = {'\32', '(', ')', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '\39',  '.', ',', ';', ':', '!', '?','\10'}
    var x = src.tolower().split(separators)
   
    echo "Total Number of Words: ", x.len   
    var list = x.QuickSort()
   
    echo "Total Unique Words: ",list.len

    var output = open("output.txt",fmWrite)
    output.writeln("Total Number of Words: " & $x.len)
    output.writeln("Total Unique Words: " & $list.len & "\n")
    for x in list:
        output.writeln(x)
    output.close()


A.
Title: Re: Nimrod
Post by: John on October 27, 2013, 02:35:38 PM
Nice!

Please don't get me wrong, I think Nimrod is an easy to use compilable high level language. I will take your initial advice to me and ...
Quote
Why not just write it in Nimrod from the start?

An that is exactly what I will be doing from now on unless your pyBAS2NIM materializes.

Title: Re: Nimrod
Post by: AIR on October 27, 2013, 07:52:40 PM
Ok, I reworked the example and was able to finish it:

Code: [Select]
Import os,  strutils, tables

var tab = initOrderedTable[string,int]()
     
if existsFile("kjv.txt"):
    let src = readFile("kjv.txt")
   
    let separators = {'\32', '(', ')', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '\39',  '.', ',', ';', ':', '!', '?','\10'}
    var x = src.tolower().split(separators)
   
    for word in x:
        if tab.hasKey(word):
            tab[word] = tab[word]+1
        else:
            tab[word] = 1

    tab.sort(proc (x, y: tuple[key: string, val: int]): int = cmp(x.key, y.key))

    var Total  =  "Total Words: " & $x.len
    var Unique =  "Total Unique Words: " & $tab.len & "\n"
   
    echo Total
    echo Unique
   
    var output = open("output.txt",fmWrite)
    output.writeln(Total)
    output.writeln(Unique)
    for key, val in tab.pairs():
        output.writeln(key, ": ", val)
    output.close()   

Quote from: OUTPUT
[riveraa@dev ~/Projects/nim] $ time ./wcount2
Total Words: 822529
Total Unique Words: 12591

real   0m0.331s
user   0m0.287s
sys   0m0.042s

Down in Oxygen Basic Territory!

Run on a Macbook AIR Core i7 @ 1.8Ghz.

Output.txt file is attached.


AIR.
Title: Re: Nimrod
Post by: John on October 27, 2013, 09:34:46 PM
If that doesn't get you to switch to Nimrod, you're hopeless.  :)

The more I play with Nimrod the more I love it. It's like Santa Claus moved in.  ;D
Title: Nimrod - SDL2
Post by: John on October 29, 2013, 07:40:00 PM
From the author of nimgame a new SDL2 Nimrod Extension Module (https://github.com/Vladar4/sdl2-nim) has been  released on Github.

Quote from: README.md
sdl2-nim 0.9 alpha

sdl2-nim is a wrapper of the SDL 2 library for the Nimrod language.

    SDL homepage: http://www.libsdl.org/
    Nimrod homepage: http://nimrod-code.org/

You need to have SDL 2 dynamic libraries installed on your system.

NOTE: project in alpha-phase, not all features are supported yet, work in progress.