AsciiDots - A Language Like A Racetrack |
Written by Ian Elliot |
Sunday, 10 September 2017 |
It looks different - ASCII art that computes! AsciiDots is a fun language that might just have something interesting to show us. The basic entity in AsciiDots is the dot . which roughly speaking is a variable that rushes around a track made up of | and -. You can also use \ and / to make corners and + to make tracks cross over without interaction. The symbols ><^V make T connections with the dot moving in the direction the symbols point at the T. So, for example:
is a loop. A dot that come in on the right goes around the loop and exits the way it came in. A program starts with a dot and ends when it exits the track or when it passes over an &. A dot starts off with a default id and a value of zero and as it races round the track it meets operators which change the value or id. For example: # sets the value and @ sets the id. So:
sets the dot's value to seven as it passes over. The $ operator outputs a string to the console when the dot passes over so, at last, the "Hello World" in AsciiDots is:
Notice that programs don't have to go left to right and top to bottom. You can start a program from any location and the dot will follow the track. This is disturbing to most programmers. The ? is an invitation for input and is only used after # or @. You can also use ( and ) to reflect dots back to where they came from. Be warned, * is not multiplication in the usual sense, instead it duplicates a dot and sets the copies off on alternative paths. What about conditionals? A language cannot be Turing complete without conditionals and AsciiDots has a very simple conditional - the tilde ~. This redirects the dot passing through it horizontally upward if the dot below is zero. You can turn that into a "not zero" by putting an exclamation mark below the tilde. So, using the example from the manual: /-$"The value is not equal to zero" | .-~-$"The value is equal to zero" | ? # | . This prompts the user for a value and prints an appropriate message. There are lots of other operators you can use to change the value of a dot and you can find out about them in the manual. The key idea is that a dot will wait for other dot at an operator. For example, to add two values together:
There are some advanced features such as warps and libraries but this is the essence of the language. There is one important thing to make clear - you can have multiple dots moving along tracks at the same time and a dot will wait for another dot when it meets an operator. So great fun but why bother? Well playing with languages, no matter how odd is a good way to fund out what might ore might not work. Asciidot is also an example of a data flow language where data flows though a network of operations as fast as it can go. It is a good way to implement parallel processing. Finally you can see the flow of control in Asciidot and it might be a good way to get beginners started. My only comment after using it for a short while is that it is a bit tedious to have to keep on typing all those spaces needed to align characters vertically. It's a lot easier to build things horizontally. Can this be overcome by a custom editor? Also aligning vertically is difficult and finally don't try to show someone your program in a font that isn't mono-spaced. Asciidots is an open source program and you can try it out online.
More InformationRelated ArticlesArnold C A Schwarzenegger Based Dolphin Smalltalk Goes Open Source NoFlo Kickstarter For Easy Programming
To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
Comments
or email your comment to: comments@i-programmer.info |
Last Updated ( Sunday, 10 September 2017 ) |