Objeck
- Appeared in:
- 2008
- Influenced by:
- Paradigm:
- Typing discipline:
- File extensions:
- .obs
- Versions and implementations (Collapse all | Expand all):
Objeck is an object-oriented programming language with some functional features (such as higher-order functions).
The language was developed by Randy Hollines. It received its modern appearance in late 2008; prior to that several prototypes tested compiler and VM concepts.
Language prototype was created to explore the process of translating stack instructions into register instructions and finally into machine code. Next, a virtual machine and a simple assembler were developed. Over time the assembly language was replaced with a much more complicated object-oriented front-end, and the language aquired the name Objeck.
At present moment the language is considered to be stable. Current development focuses on making it more light-weight. The language was never standartized, and the author’s implementation stays the only one. It includes a compiler, virtual machine (with associated garbage collector and JIT compiler) and command-line debugger.
All data types, except for higher-order functions, are considered to be objects.
Links:
Examples:
Hello, World!:
Example for versions Objeck 2.0.3bundle Default {
class Hello {
function : Main(args : String[]) ~ Nil {
"Hello, World!"->PrintLine();
}
}
}
Factorial:
Example for versions Objeck 2.0.3This example uses built-in Factorial()
function.
bundle Default {
class Factorial {
function : Main(args : String[]) ~ Nil {
for (i := 0; i <= 16; i += 1;) {
i->Print();
"! = "->Print();
i->Factorial()->PrintLine();
};
}
}
}
Fibonacci numbers:
Example for versions Objeck 2.0.3This example uses recursive definition of Fibonacci numbers.
bundle Default {
class Fib {
function : Fibonacci (n: Int) ~ Int {
if (n<=2) {
return 1;
};
return Fibonacci(n-1) + Fibonacci(n-2);
}
function : Main(args : String[]) ~ Nil {
for (i := 0; i <= 16; i += 1;) {
Fibonacci(i)->Print();
", "->Print();
};
"..."->PrintLine();
}
}
}
Quadratic equation:
Example for versions Objeck 2.0.3use IO;
bundle Default {
class Quadratic {
function : Main(args : String[]) ~ Nil {
A := Console->ReadString()->ToInt();
if (A=0) {
"Not a quadratic equation."->PrintLine();
return;
};
B := Console->ReadString()->ToInt();
C := Console->ReadString()->ToInt();
D := 1.0*(B*B-4*A*C);
if (D=0) {
"x = "->Print();
(0-B/2.0/A)->PrintLine();
};
if (D>0) {
"x1 = "->Print();
((0-B+(D->SquareRoot()))/2.0/A)->PrintLine();
"x2 = "->Print();
((0-B-(D->SquareRoot()))/2.0/A)->PrintLine();
};
if (D<0) {
out := "x1 = (";
out->Append(0-B/2.0/A);
out->Append(",");
out->Append(((D->Abs())->SquareRoot())/2/A);
out->Append(")");
out->PrintLine();
out := "x2 = (";
out->Append(0-B/2.0/A);
out->Append(",");
out->Append(0-((D->Abs())->SquareRoot())/2/A);
out->Append(")");
out->PrintLine();
};
}
}
}
Comments
]]>blog comments powered by Disqus
]]>