I have been living this last week in a pleasant fiction: I live in a world populated by regular updates, intelligent conversation, educated topics, and unlimited ice-cream. This pleasant fiction sustained me for a whole day, then I blew the rest of the week in learning a new programming language and researching what makes good language design vs bad language design, pros and cons of programming languages, and compilers for making my own language. You may be saying "Boring!", and in truth I often wonder why I find it so fascinating, but I still keep going back to the internet night after night trying to compile, learn, and educate myself about a language that will probably have no real application in ANY job I have, but leaning an entirely new language is quite informative.
In fact, for the last month, I've been growing frustrated with the rigidity of C++ and was looking for something similar to Squeak without the big footprint. The only languages I had heard about that might be able to help were dolphin (smalltalk variant) and Self. Neither of which are currently freely available for the windows system. My conclusion: develop my own programming language. I've had been making quite good progress until I ran across the
IO programming language, and everything I was planning had been implemented and then some!
Warning: The following post will be technical and boring to those un-initiated into the world of computer programming. I also don't hold out much hope if this being interesting to those who are interested in programming.
IO Language: How is it different from C++ and Java? Let's do a quick comparison. C++ and Java are class based languages using function calls as the main process of execution. The IO language is completely different. The closest similarity I've seen is the language Self. (Javascript is also a similar language, but I don't know enough about it to vouch for that). IO is a prototypical, message based language. Everything is an object, and a message is required to do anything. There are no function calls - which makes for a very powerful threading pardigm. Hello world is an example of the language; just keep in mind that this is an interpreted language that a virtual machine translates (like Java).
"Hello World!" printlnprints:
Hello World!Wasn't that cool? Let's try a larger, more typical example using obvious procreate a generic object we can use. the clone message create an exact copy
Hat := Object clone // create a "Hat" objectHat size := 8 // size & 8 are Number classesHat refit := method( newSize, // we create a function here Hat size = 9)"Hat size started out at " printHat size println"Hat size after refit is " printHat refitHat size printlnThe output:
Hat size started out at 8Hat size after refit is 9Remember - even though the code looks like it uses function calls it doesn't. Let's take a look at the last line: Hat size println. Hat is an Object. size is a message sent to Hat which has a result of evaluating the code in the "size" slot which has a final value of the Number object 9. println is a message sent to Number which prints a number on the screen. You may say, "What does it matter? function calls and methods end up do the same thing." Ha. You've never worked with threads in MFC then. :-)
I would have given up on this language except for two breakthroughs. My first breakthrough came around hour six in trying to get IO to do things beyond simple assignments and methods: I managed to get the addons (like OpenGL) working! 3 hours later, I was ready to give up. I
really, really, really wanted to be able to do a
simple console application. And I found it. I'll post the answer below, but first I just have to explain my genius ( random luck) in figuring it out. I'm looking at the online reference for IO, and I see a core prototype called CLI. It was undocumented and I didn't have the source in the download I had, but no worries! The IO language provides self inspections. I can print ANY io code used/declared in the current object. I'm looking through the various functions and I see about 5 lines of code that composes the main loop to the entire program. Turns out that CLI is the main window! I quickly copied the CLI code and made my own, simple, easy, short console application template that does not depend on any addons! The cumulative effort of 9 solid hours of research and grunt work:
//Do the prototype creation and setup herestdout := File clone standardOutputstdin := File clone standardInputwhile(true, write("Your next wish? ") line := stdin readLine if(stdin isAtEnd, writeln; Lobby exit) // Do actions here depending on user's typing)My next goal: implement Legends11. Legends11 is an unpublished game that my brother got for me about 10 years ago. It was text based, short (under 4 hours), simple, and fun. I've played it though 5-10 times and I still enjoy playing it.
Hint: doFile("
filename.io") is a lifesaver if you decide to try out IO