3
votes
What is the most advanced or creative program you can create using the LOX programming language?
Lox is a toy programming language that is designed in Java and C at craftinginterpreters.com.
My challenge to you is: given the constraints of the Lox language, what are some creative or advanced programs you can create?
This page provides a rundown of the design of Lox.
To kick it off, here's a simple function that estimates the value of pi:
fun estimatePi(rounds) {
var pi = 0;
var alt = 1;
for (var i = 0; i < rounds; i = i + 1) {
pi = pi + alt * 4/(2 * i + 1);
alt = -alt;
}
return pi;
}
print "The value of pi is:";
print getPi(100000);
I'll admit I skimmed the whole thing, but besides the lack of a standard library and I/O, are there any other limitations?
This seems perfectly suited for mathematical problems as long as you can implement most concepts. Also you can probably do some really fun ASCII stuff since you have string concatenation.
The syntax is nice, not the greatest, but considering it's a theoretical language that isn't meant to solve a real-world problem, it's completely adequate.
I agree, this seems to have basically everything you would need to make any non-graphical program you wanted? There's no default list, but it has classes so you could create a pretty simple LinkedList to handle that.
Honestly, the more interesting questions is what cant you make. What features are missing that prohibit certain styles of application.
Off the top of my head, it's missing:
print
ing, so no way to store informationWhat do you mean by modularity?