#!/usr/bin/env spike-1
main(argv) {
stdout.puts("Yip!\n");
return 0;
}
Spike is a brand-new programming language. It was born out of frustration with existing programming languages, and a love of Smalltalk. In essence, Spike is Smalltalk with a C-like syntax.
Spike is still a puppy. He's still in alpha. You may download an alpha release here.
There is no documentation except for this page. There is no linker; but you won't miss it, because there are no libraries (not even a standard library). I'll stop here, because the number of things that are missing are too numerous to mention.
make # add 'spike-1' to your PATH ./examples/hello.spk
#!/usr/bin/env spike-1
fib(x) {
if (x<=2) return 1;
return fib(x-1) + fib(x-2);
}
main(argv) {
stdout.printf("%d\n", fib(10));
return 0;
}
#!/usr/bin/env spike-1
class Point {
var x, y;
// initializing
init(newX, newY) {
x = newX;
y = newY;
}
// accessing
x { return x; }
y { return y; }
x = newX { x = newX; }
y = newY { y = newY; }
self x: newX y: newY {
x = newX;
y = newY;
return self;
}
// arithmetic
self + delta {
return self.class
x: x + delta.x
y: y + delta.y;
}
self * scale {
return self.class
x: scale * x
y: scale * y;
}
-self {
return self.class
x: -x
y: -y;
}
self + 1 {
return self.class
x: x + 1
y: y + 1;
}
self - 1 {
return self.class
x: x - 1
y: y - 1;
}
// printing
print() {
stdout.printf("(%d, %d)\n", x, y);
}
} meta {
self x: xValue y: yValue {
return self.new() x: xValue y: yValue;
}
}
main(argv) {
var a, b, c;
a = (Point) x: 4 y: 2;
b = (Point) x: 22 y: 44;
stdout.printf("a is "); a.print();
stdout.printf("b is "); b.print();
c = a + b;
stdout.printf("c is "); c.print();
return 0;
}