Fast, Expert Software Consulting and Programming HelpTM
TinyBasic (Java, Flex, C#)
Introduction
Tiny Basic is my port of Tom Pittmans's TinyBasic C rewrite to Java, C# and Flex/Actionscript. When I learn a new language/platform (in this case Adobe Flex), I always try to think of an outlandish first project to keep my interest level high and this was it. Those that know me also know that the TRS-80 was my first computer and I have a weakness for the early versions of BASIC and those books and magazines where you type in your own programs and games from the code listings.
For grins, I also decided to create Java and C# versions so I could mentally compare and contrast them.
Technical Details
Tom Pittman's C version is of course a console application. When porting this, I could have opted for the approach I followed in my Mips2Java port and have a "console" thread and GUI thread which piped input and output to each other bidirectionally. I thought this was overkill, though, (and it was out of the question for Flash/Flex, which is single-threaded). Instead, I opted to rework the interpreter loop, causing it to return if it either needed more input or if it had executed a predetermined number of instructions. The GUI would set a 250ms repeating timer which would re-enter the interpreter loop if it wasn't waiting on input. Finally, the text area would trap the enter key and re-enter the interpreter if it was waiting for more input and if more input was available. This would give the illusion of multithreading with only one thread.
The fact that I was able to do this in Java, Flex and C# kind of shows that in the end, things that seem different on the surface are just variations of the same theme. My understanding of how to do multithreaded GUI programming (have worker threads call the GUI thread asynchronously) has its roots in my Windows C++/MFC days and applies equally to Java (Swing and SWT) and C#. My understanding of how to use timer tasks to simulate multithreading also has its roots in my C++/MFC days. To me, coding in different languages and platforms is like traveling to different countries and speaking different foreign languages to people who in the end, are just as universally human as I am.
Java Version
Click here to see the Java applet.Adobe Flex Version
Click here to see the Adobe Flex version.C# Version
Click here for the C# version.Sample BASIC Programs
Click here for the Tiny Basic User's Guide and sample programs you can copy and paste into the interpreter window.Sources
I'm making the Java, C# and Flex/Actionscript sources available without precondition. This is as a token of gratitude to Tom Pittman for making his TinyBasic sources available, as well as to countless people who have selflessly provided programming answers and advice on the Internet.
If you need help or have questions about any of these platforms, feel free to purchase my consulting time with my easy-to-use web interface. (Shameless marketing plug: people with both my breadth and depth of knowledge are hard to come by; my experience with a wide variety of programming languages and environments might give you the perspective you need for your project.)
Sources: TinyBasic.tar.gz
If you enjoy this...
Would you consider visiting one or more of the following websites?
- http://www.thisiscool.com/mohan/ardiscus.html
- http://www.tryveg.com/cfi/toc/
- http://www.peta.org/
- http://www.vegfamcharity.org.uk/
- http://www.veganpeace.com/
- http://www.earthsave.org/lifestyle/chocolate.htm
- http://www.earthsave.org/health/what_about_dairy.htm
- http://www.earthsave.org/health/what_about_chicken.htm
- http://www.animalsong.org/
- http://www.mcspotlight.org/
Enjoy!