Everything you need to get started
git clone https://github.com/gokr/harding.git
cd harding
nimble harding
Requires Nim 2.2.6+
harding # Interactive REPL
harding script.hrd # Run a script
harding script.hrd -- one two # Run with runtime args
harding -e "3 + 4" # Evaluate expression
harding -e "System arguments size" -- red blue green # Eval with args
harding --ast script.hrd # Show AST then execute
harding --loglevel DEBUG script.hrd # Debug output
Use --loglevel DEBUG for verbose output
granite compile myapp.hrd -o myapp
granite build myapp.hrd --release
granite run myapp.hrd
Compile to native binaries with no runtime dependencies
"Hello, World!" println
# Extend Number with a factorial method
Number >> factorial [
(self <= 1) ifTrue: [^ 1].
^ self * ((self - 1) factorial)
]
5 factorial println # 120
10 factorial println # 3628800
| c |
Counter := Object derive: #(count)
Counter >> initialize [ count := 0 ]
Counter >> value [ ^count ]
Counter >> increment [ ^count := count + 1]
c := Counter new
c initialize
c increment
c value println # 1
numbers := #(1 2 3 4 5)
squares := numbers collect: [:n | n * n]
evens := numbers select: [:n | (n % 2) = 0]
sum := numbers inject: 0 into: [:a :n | a + n]
[
10 / 0
] on: DivisionByZero do: [:ex |
Transcript showCr: "Cannot divide by zero!".
ex resume: 0
]
result println # 0
System class for process/stdio access (arguments, cwd, stdin, stdout, stderr)File convenience API for file reads/writes (readAll:, write:to:, append:to:, exists:)FileStream native file primitives for stream-style I/Oobj size, binary 3 + 4, keyword dict at: key put: value;do:, select:, collect:, inject:into:# for comments (not double quotes)Point := Object derive: #(x y)| Feature | Smalltalk | Harding |
|---|---|---|
| Comments | "comment" |
# comment |
| Strings | 'string' |
"string" |
| Statement separator | Period . only |
Period or newline |
| Class creation | Class definition | Object derive: #(vars) |
| Persistence | Image-based | File-based, git-friendly |
| Execution | VM | VM or Native compilation (Granite) |
| Inheritance | Single | Multiple |
# Instance method
Person >> greet [ ^ "Hello" ]
# Class method - defined on the class itself
Person class >> newPerson [ ^ self new ]
nimble bona # Build the IDE
./bona # Launch
Features:
Next up: System Browser and Inspector (in progress), with a Debugger planned.
nimble vsix # Build the extension
code --install-extension harding-lang-*.vsix
Features: