Turbo Pascal In JavaScript
Written by David Conrad   
Wednesday, 30 October 2013

Everyone is now used to the idea that JavaScript can do amazing things, but Turbo Pascal in a browser is worth a look for anyone who remembers its original implementation. It includes a p-code virtual machine that is binary compatible with the UCSD compilers. 

Turbo Pascal was one of the breakthroughs of the 1980s. It was a PC implementation of the standard Pascal language, which was much used at the time to teach computer science. Pascal was one of the first modern languages to be available on the PC. Later it evolved into an object-oriented version that is still going strong as Delphi. 

 

turbopascalcover

 

The JavaScript implementation, which is on GitHub, isn't a complete implementation of Turbo Pascal 5.5, but if you look at the demos it is impressive, and it includes most of the language and most of the graphics module. The author, Lawrence Kesteloot, only implemented enough of the language and the standard library  to run five original programs written back in 1989 - programmers do difficult things for a range of crazy reasons!

The hand-coded recursive descent compiler, Pascal is a block structured language, takes about 6000 lines of JavaScript. The original Turbo Pascal compiled all the way to machine code, hence the "Turbo" in its name. Earlier implementations of Pascal used virtual machine that ran p-code. Today VMs are a very popular way of implementing a language but back then the technology wasn't so good and so "p-code" was synonymous with "slow".

Unlike Turbo Pascal proper, the JavaScript compiler outputs p-code. Of course, this means that the project needed a p-code VM and that is what you will find in the GitHub repository - and it's about 600 lines of commented JavaScript. It is claimed to be binary compatible with the original UCSD Pascal compiler, which implies that it could be used to run legacy UCSD Pascal, Fortran and Basic programs. In other words, the p-code VM might be useful in its own right.

 

turbopascal

 

The compiler has a user front end that mimics the original Turbo Pascal command interface - later it acquired a GUI. If you try it out here, note that not all of the commands have been implemented. To run one of the sample programs use the D command to list the directory and then use the W command to load the file followed by R to run it. Use Ctrl-C to stop it. 

 

turbopascalicon

 

More Information

Live Web Demo Of Turbo Pascal

Blog Post About The Compiler And Demos

GitHub Turbo Pascal

Related Articles

Pascal IDE Lazarus 1.0 Released       

Interpreters, VMs and JIT       

The Top Languages of 2012    

Programming Languages An Infographic          

 

To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, FacebookGoogle+ or Linkedin,  or sign up for our weekly newsletter.

 

blog comments powered by Disqus

 

Banner


Blockly Games Introduce Kids To Code
22/08/2014

Google has launched a set of games where instead of just playing you write the code. Using Blockly requires little or no typing and lets young or novice programmers discover core coding principles in  [ ... ]



Java JDK 9 Proposals
22/08/2014

Oracle has announced the first set of proposed improvements for inclusion in Java 9.


More News

 

Last Updated ( Monday, 24 February 2014 )
 
 

   
RSS feed of news items only
I Programmer News
Copyright © 2014 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.