PRESENTATION OUTLINE
NIMROD (n.): Hebrew
Great Hunter
NIMROD is a programming language that focuses on compile time mechanisms in various forms
# compute average line length
var count = 0
var sum = 0
for line in stdin.lines:
count += 1
sum += line.len
echo "Average line length: ",
if count > 0: sum / count else: 0
efficiency
- native code generation
- ability to manage own memory
- access hardware directly
- value based datatypes
- dead code elimination
EXPRESSIVE
- compiler & library are implemented
- built-in high datatypes
- modern type system
- user-definable operators
- macros can modify abstract syntax
ELEGANCE
- imperative paradigm
- flexible syntax
- statements grouped by indentation
COMPATIBILITY
- runs on several platforms
- can generate C++ and Objective C
- several bindings
- C to Nimrod conversion
# This is a comment
echo("What's your name? ")
var name: string = readLine(stdin)
echo("Hi, ", name, "!")
let name = readLine(stdin)
if name == "":
echo("Poor soul, you lost your name?")
elif name == "name":
echo("Very funny, your name is name.")
else:
echo("Hi, ", name, "!")
let name = readLine(stdin)
case name
of "":
echo("Poor soul, you lost your name?")
of "name":
echo("Very funny, your name is name.")
of "Dave", "Frank":
echo("Cool name!")
else:
echo("Hi, ", name, "!")
from strutils import parseInt
echo("A number please: ")
let n = parseInt(readLine(stdin))
case n
of 0..2, 4..7: echo("The number is in the set: {0, 1, 2, 4, 5, 6, 7}")
of 3, 8: echo("The number is 3 or 8")
echo("What's your name? ")
var name = readLine(stdin)
while name == "":
echo("Please tell me your name: ")
name = readLine(stdin)
# no ``var``, because we do not declare a new variable here
echo("Counting to ten: ")
for i in countup(1, 10):
echo($i)
# --> Outputs 1 2 3 4 5 6 7 8 9 10 on different lines
BASIC TYPES
boolean
character
string
integer
float
IT02 finals
Chelsea Mendoza
24 March 2014