6 Replies - 4463 Views - Last Post: 21 February 2011 - 07:07 PM

#1 Amrykid  Icon User is offline

  • 4+1=Moo
  • member icon

Reputation: 148
  • View blog
  • Posts: 1,589
  • Joined: 16-December 08

Nimrod - the compiled, garbage-collected systems programming language.

Posted 09 January 2011 - 08:56 AM

I am pretty sure almost no one has heard of this language. It is called Nimrod. I have used the language a couple times and it looks promising.

Heres the description from the website:

Quote

Nimrod is a new statically typed, imperative programming language, that supports procedural, object oriented, functional and generic programming styles while remaining simple and efficient. A special feature that Nimrod inherited from Lisp is that Nimrod's abstract syntax tree (AST) is part of the specification - this allows a powerful macro system which allows domain specific languages.
Nimrod is a compiled, garbage-collected systems programming language which has an excellent productivity/performance ratio. Nimrod's design focuses on the 3E: efficiency, expressiveness, elegance (in the order of priority).
Nimrod is efficient
  • Native code generation (currently via compilation to C), not dependant on a virtual machine: Nimrod produces small executables without dependencies for easy redistribution.
  • A fast non-recursive incremental and generational garbage collector that should be well suited for soft real-time systems (like games).
  • System programming features: Ability to manage your own memory and access the hardware directly. Pointers to garbage collected memory are distinguished from pointers to manually managed memory.
  • Zero-overhead iterators.
  • Cross-module inlining.
  • Dynamic method binding with inlining and without virtual method table.
  • Compile time evaluation of user-defined functions.
  • Whole program dead code elimination: Only used functions are included in the executable.
  • Value-based datatypes: For instance, objects and arrays can be allocated on the stack.


Nimrod is expressive
  • The Nimrod compiler and all of the standard library are implemented in Nimrod.
  • Built-in high level datatypes: strings, sets, sequences, etc.
  • Modern type system with local type inference, tuples, variants, generics, etc.
  • User-defineable operators; code with new operators is often easier to read than code which overloads built-in operators. In the code snippet, the =~ operator is defined in the re module.
  • Macros can modify the abstract syntax tree at compile time.


Nimrod is elegant
  • Macros can use the imperative paradigm to construct parse trees. Nimrod does not require a different coding style for meta programming.
  • Macros cannot change Nimrod's syntax because there is no need for it.
  • Nimrod's syntax is flexible enough.
  • Statements are grouped by indentation but can span multiple lines.
  • Indentation must not contain tabulators so the compiler always sees the code the same way as you do.


Nimrod plays nice with others
  • The Nimrod Compiler runs on Windows, Linux, BSD and Mac OS X. Porting to other platforms is easy.
  • There are bindings to GTK2, the Windows API, the POSIX API, OpenGL, SDL, Cario, Python, Lua, TCL, X11, libzip, PRCE, ODBC, libcurl, mySQL and SQLite.
  • A C to Nimrod conversion utility: New bindings to C libraries are easily generated by c2nim.
  • A Pascal to Nimrod conversion utility: A large subset of Object Pascal can be translated to Nimrod automatically!


Here is a simple irc bot I wrote in Nimrod a few months ago:
import sockets
import strutils
import re
import httpclient
var tcp : TSocket
tcp = socket()
connect(tcp ,"irc.freenode.net" ,TPort(6667),TDomain.AF_INET)
proc Join (chan : string)  =
  send(tcp,"JOIN " & chan & "\r\n")
proc Part (chan : string) =
  send(tcp,"PART " & chan & "\r\n")
proc Logon(nick : string)  =
  send(tcp,"USER " & nick & " " & nick & " "  & nick & " "  & nick &"\r\n")
  send(tcp,"NICK " & nick & "\r\n")
proc SendText(msg : string, chan : string) = 
  send(tcp, "PRIVMSG " & chan & " :" & msg & "\r\n")
proc Substring(str : string, strt : int) : string = 
  var strng : string
  strng = str
  strng.delete(0,strt)
  return strng

var info_sent : bool
info_sent = false
if info_sent == false:
   Logon("Nimbot")
   Join("#()")
   info_sent = true
while true:
    var line : string
    line = tcp.recv()
    var data : seq[string]
    data = split(line)
    if line != nil and line != "":
       echo(line)
       if startsWith(line,"PING :"):
          var l2 : string
          l2 = line.replace("PING :","PONG :")
          send(tcp,l2)
          Echo(l2)
       if data[1] == "PRIVMSG":
          var channel : string
          var nick : string
          var msg : string
          channel = data[2]
          nick = data[0]
          nick.delete(0,0)
          nick.delete(nick.find("!") + 1,len(nick))
          msg = Substring(line,line.find(data[3]))        
          if msg.startsWith("*"):
             msg = Substring(msg,0)
             if msg.toLower.startsWith("say"):
                msg = Substring(msg,3)
                SendText(msg,channel)
             elif msg.toLower.startsWith("ping"):
                SendText("pong",channel)
             elif msg.toLower.startsWith("join"):
                msg = Substring(msg,4)
                Join(msg)
             elif msg.toLower.startsWith("part"):
                msg = Substring(msg,4)
                Part(msg)
             elif msg.toLower.startsWith("title"):
                SendText("Feature disabled.",channel)
                #var url : string 
                #url = Substring(msg,5)
                #Echo(url)
                #if url.startsWith("http://"):
                #  url = Substring(url,6)
                #  Echo(url)
                #url = replace(url,"\c\L","")
                #var html : string = getContent(url)
                #echo(html)
                #if html =~ re"<title>.*?</title>":
                #  SendText(matches[0],channel)

                
          
          



Nimrod is available on Github here and from the website here.

This post has been edited by Amrykid: 09 January 2011 - 08:59 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Nimrod - the compiled, garbage-collected systems programming language.

#2 dom96  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 256
  • Joined: 29-December 08

Re: Nimrod - the compiled, garbage-collected systems programming language.

Posted 09 January 2011 - 09:02 AM

I have been using this language for the past about year(But you know that :) It is an amazing language, i'm really curious what people on DIC will think of it.
Was This Post Helpful? 0
  • +
  • -

#3 lordofduct  Icon User is offline

  • I'm a cheeseburger
  • member icon


Reputation: 2538
  • View blog
  • Posts: 4,641
  • Joined: 24-September 10

Re: Nimrod - the compiled, garbage-collected systems programming language.

Posted 09 January 2011 - 11:12 AM

Something I'd like to look into when I have more time. I like what the creators are shooting for (the description above).
Was This Post Helpful? 0
  • +
  • -

#4 Raynes  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 611
  • View blog
  • Posts: 2,815
  • Joined: 05-January 09

Re: Nimrod - the compiled, garbage-collected systems programming language.

Posted 09 January 2011 - 04:11 PM

I'm impressed with the whole concept, and I'm always a fan of putting lispiness in non-lisp languages, but I can't bring myself to pay any attention to a language who's designer feels that anonymous functions and closures are unimportant features.

Besides that, it's case-insensitive and ignores underscores which is another thing I don't like. The author's rationale is "this way, people can write with whatever conventions or styles they like!" which is the exact opposite of what one should shoot for.

The macro system slightly impresses me, but that's about it.
Was This Post Helpful? 0
  • +
  • -

#5 lordofduct  Icon User is offline

  • I'm a cheeseburger
  • member icon


Reputation: 2538
  • View blog
  • Posts: 4,641
  • Joined: 24-September 10

Re: Nimrod - the compiled, garbage-collected systems programming language.

Posted 10 January 2011 - 10:59 AM

I don't know why they would ignore underscores.

But being case-insensitive is growing on me. What does being case sensitive really let you do? You can still use bad naming conventions when case sensitive. The only difference is that when case sensitive all of these members can technically exist and be independent of each other...

VALUE
value
Value
vAlUe
vAlUE
...


of course this has never bothered me enough to make me dislike Case-Sensitivity. I just don't get the argument against case insensitivity.
Was This Post Helpful? 0
  • +
  • -

#6 Raynes  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 611
  • View blog
  • Posts: 2,815
  • Joined: 05-January 09

Re: Nimrod - the compiled, garbage-collected systems programming language.

Posted 10 January 2011 - 04:46 PM

It isn't so much that it is case insensitive that bothers me as much as his stupid reason for making it case insensitive does. I don't want everybody using whatever random coding conventions and styles they thought up that morning over coffee. I want to be able to actually read their code. In my opinion, his rationale is the precise opposite of what he should be shooting for. Especially with the ignore-underscores bit. That's just weird.
Was This Post Helpful? 0
  • +
  • -

#7 Guest_Doug*


Reputation:

Re: Nimrod - the compiled, garbage-collected systems programming language.

Posted 21 February 2011 - 07:07 PM

It does support closures and anonymous functions.

With an IDE and a language that supports macros, case-insensitivity is better (you can create DSLs that might have different case conventions) but also doesn't matter (the IDE will correct the case as you type). So someone should just make a plugin for eclipse or whatever for nimrod.
Was This Post Helpful? 0

Page 1 of 1