
Turbo Pascal Compiler (2013) - bootload
https://www.teamten.com/lawrence/projects/turbo_pascal_compiler/
======
oso2k
I'm surprised that no one here seems to have noticed that this is a Tubro
Pascal compatible compiler written in JS that writes binaries compatible with
1978 UCSD p-System p-code, and, a p-code VM also written in JS that will run
in a web page displaying x86 PC/DOS graphics. No less than 4 architectures to
juggle (PC/CGA/EGA/VGA, JS, Web/DOM, p-code).

Early 8 & 16-bit architecture BASICs and Pascals worked on by several people
all strived for p-code compatibility [0][1] and this guy wrote this by
himself. I thought that was most remarkable when I found this a couple years
ago.

[0]
[https://en.wikipedia.org/wiki/P-code_machine](https://en.wikipedia.org/wiki/P-code_machine)

[1]
[https://en.wikipedia.org/wiki/UCSD_Pascal](https://en.wikipedia.org/wiki/UCSD_Pascal)

~~~
GregBuchholz
Anyone know what the source language for Turbo Pascal was? Assembly?
Bootstrapped Pascal? Turbo C?

~~~
cyberferret
I remember reading an interview with Anders Hejlsberg (the main guy who wrote
Turbo Pascal) many years ago where he said it was mostly Assembly, with some C
(not sure which flavour of C though). Apparently Anders was one of the few
people at the time who could write large blocks of 8088 assembler off the top
of his head.

~~~
the_d00d
He is such a badass. Anders also gave us Delphi, C#, and Typescript.

------
cyberferret
The first ever computer program I wrote for $$$ was a retail point of sale
system for a local pharmacy. I used Turbo Pascal for it, complete with my own
proprietary database files etc.!

Later on, I wrote a front end menu system (which simply gave a customisable
easy to select option of applications to run in DOS) that ended up being used
on thousands of PC's throughout businesses and almost every government
department in my town.

Good Days. I downloaded the original Turbo Pascal v 1.x a couple of years
back, and intended to try re-writing that point of sale system again to see
how much I still remembered > 30 years later. Never got around to it, but I
will make a concerted effort this year to try it out. I may just try it on
this web emulator, seeing as I am now on a Mac!

Thank you Anders Heljsberg! And to these guys for building a web emulator of
the original compiler.

~~~
rasjani
First ever paid lines of code: in pascal, for pharmacy. Albeit, i did stock
ordering portion. Stock only had 300baud demodulator so all verifications had
to done by eavesdropping the line with phone and if one didn't hear the
correct signal, you had to press keyboard to retrigger the batch again. I had
to code all this blind too because there was no test environment :)

~~~
cyberferret
Nice! You are one better than me though, because I didn't have any
connectivity with another system - it was all running standalone on their LAN.
The stock room had to key in goods receipts manually after downloading info
from their Vax PDP-8 stock management system. If I had more time (and they had
more money) I might have worked out a way to automate that. :)

------
linker3000
I too found some old floppies a few months back and one contained the Turbo
Pascal source code for a map editor I wrote for the original Rockford game on
the PC.

I fired up Turbo Pascal in a DOS box on Windows 10 and got the code to
compile. Sadly, I don't have the game any more and the 'Rockford' available
online is actually a remake / emulation using a different game engine and the
maps are in a different format.

Code here for anyone who wants to laugh at my skills as a non-programmer:

[https://github.com/linker3000/Historic-code-PC-Pascal-and-
AS...](https://github.com/linker3000/Historic-code-PC-Pascal-and-ASM-)

PS: Does anyone here have a copy of the original Rockford game!!??

~~~
Narishma
[https://archive.org/details/msdos_Rockford_-
_The_Arcade_Game...](https://archive.org/details/msdos_Rockford_-
_The_Arcade_Game_1987)

~~~
linker3000
Thanks - sadly that's the version that uses the other game engine and is not
the original version.

~~~
linker3000
PS: My other 'proper' TP programs were a staff time management and reporting
app, a materials control system and a file upload program for a Stag device
programmer - it took a PROM/EPROM/PAL/GAL binary or hex file in whatever
format you had, identified the format, parsed it for checksum and file errors,
set the Stag programmer device and file parameters (which saved a LOT of time
and avoided setup errors), uploaded the file, verified the upload and
programmed & verified the device.

At one point, Stag came down and checked over the code with a view to making
it their stock program but I think things became too complex when legal got in
the loop.

------
pawadu
The original compiler can be downloaded from Borland:

[http://edn.embarcadero.com/museum/](http://edn.embarcadero.com/museum/)

IIRC someone has posted the complete source code online but I cant find it
right now...

edit: [http://turbopascal.org/turbo-pascal-
download](http://turbopascal.org/turbo-pascal-download)

~~~
clouddrover
Free Pascal also implements a Turbo Pascal compatibility mode. They have a
porting guide:
[http://freepascal.org/port.var](http://freepascal.org/port.var)

~~~
Animats
I've been converting a large system from the 1980s from Berkeley Pascal to
Free Pascal, and it's going quite well. Free Pascal implements a superset of
Turbo Pascal, ISO Pascal, and Delphi. So you can revive most old Pascal code
with it.

~~~
vram22
Interesting. Did you use Pascal in your networking or other work in earlier
years? (Saw your profile.)

~~~
Animats
[https://github.com/John-Nagle/pasv](https://github.com/John-Nagle/pasv)

------
lumberjack
Turbo Pascal was my introduction to programming. Using just the CRT library
(Graph if you wanted to be fancy was also easy to use) and learning about
loops and procedures was enough to be able to write simple Nintendo 64 style
games. I still don't think any programming languages today match that kind of
mild learning curve.

~~~
muterad_murilax
> Nintendo 64 style games.

Are you sure you don't mean NES/SNES style games?

~~~
jacobush
I hope so or Lumberjack is frighteningly skilled. :)

------
phkahler
This made me smile. Not because I care at all about TP3 or even TP6 which I
did a lot with. No, it's because the effect it had on the author. For him it
was a project that made programming fun again for personal reasons. In
practical terms it's worthless, in personal terms it was priceless ;-)

Love that.

------
equalarrow
One day, when I was still in high school, my dad brought home a DEC mini
(dunno which one). It had 2 8" floppy drives and an actualy terminal that
would sit on top. When you would turn it on, it had these 2 huge fans in the
back that sounded like an airliner taking off. It was still in its 8u rack
chassis.

When I turned it on for the first time, it booted off of what must have been
some kind of rom and dropped straight into UCSD Pascal. I was programming at
home at the time via Basic & 6502 assembly, and when I saw the Pascal prompt,
I was like, awesome! (I had a class at school using Turob Pascal)

I spent a lot of weekends in our cold garage (over the winter) hacking on that
machine. I wish I would have saved some pictures. I made a star trek type game
and (my fav at the time) a database ala dBase.

Good times..

(Mobile typo edits)

------
lobster_johnson
Back in 1997 I was a developer on a commercial Windows game, written in Turbo
Pascal (or technically, Borland Pascal). Not sure how many games have been
developed with Turbo; can't be that many.

We had to write our own bindings for DirectDraw and DirectSound, since there
were no C header files we could use directly. (This was before 3D
acceleration, so no Direct3D, which wouldn't really have been feasible.) We
were all Pascal programmers at the time, and didn't even consider using C or
C++.

Turbo Pascal was really ideal for writing games in. Short develop-compile-
debug cycle, great native performance, support for inline assembly (our image
code had lots of this), and easy calling into C libs.

I was using Borland's Pascal tools as late as 1999-2000, the last iteration
being Delphi 4.0. While I did plenty of GUI stuff, my biggest project was a
non-GUI teleconferencing solution that consisted of a web application that
orchestrated calls using several distributed backends (or microservices as we
would call them today), with RPC using Microsoft DCOM; Delphi had very good
COM support. As part of this app, I had to talk to several low-level telecomms
boards by Dialogic, which of course only had C headers. I wrote an AST-based
C-to-Pascal translator so I didn't have to do all the headers manually, and I
was able to use it to translate things like Microsoft's MAPI headers, which
were COM.

Still... It's amazing to think today that I was so fond of/productive in
Pascal that I shoehorned everything into it, even those headless server apps,
when obviously C or C++ would have provided much less friction.

The answer is of course that TP/BP/Delphi all provided an amazingly productive
experience. These days I use Go a lot, which of course is heavily influenced
by the Wirth family of languages. Go today feels a lot like Borland Pascal
with garbage collection.

</nostalgia>

~~~
pacaro
Why no c header files? I was writing against DirectDraw and DirectSound in
that time frame using C, so I'm assuming that there were headers. Or did you
just not have access to the windows SDK?

~~~
lobster_johnson
We had the C header files, but Turbo/Borland Pascal could not read them, it
being a different language and all. You had to translate them into Pascal and
declare each imported function as something like:

    
    
        function DirectDrawCreate(...): HRESULT; stdcall; external 'ddraw.dll';

~~~
clouddrover
Rudy Velthuis has a great article on the problems commonly encountered when
converting C headers to Pascal (or more specifically Delphi):

[http://rvelthuis.de/articles/articles-
convert.html](http://rvelthuis.de/articles/articles-convert.html)

~~~
lobster_johnson
Yep. As I said in a previous comment, I actually released a tool, called
htrans, to do this, which worked very well for a lot of people.

It was a hand-coded C parser with support for a minimal subset of C++
concepts, needed to successfully translate COM interfaces. It had a bunch of
kludges specifically to recognize COM. Handling macros was without doubt the
most painful part of it, because I couldn't just run the .h file through a
preprocessor; I had to also preserve the macros and try to convert them into
declarations, so that "#define FOO 1" would result in "const FOO: Integer =
1;" or whatever. Not too bad with simple things, but sometimes people will
abuse macros to declare functions...

htrans worked well enough that I could run it on a bunch of stuff and not need
to edit the resulting .pas files at all. Unfortunately, I suspect I've lost
the source code.

------
open-source-ux
I really miss fast, compiled programming languages like Turbo Pascal in the
web space.

How many languages can you identify for web development that match the
following features:

\- Fast

\- Compiled

\- Small, single file executables

\- Low-memory consumption

\- Readable syntax that isn't afraid of being a bit verbose

\- A small language vocabulary you can actually learn rather than the
labyrinthine language definitions of today

I always liked Niklaus Wirth's philosophy on programming language design. I
wish more programming language designers would follow it.

~~~
marianov
What I miss are 4GL. 90% of bussiness systems are some form of CRUD, or record
keeping software. With Clipper/DBase III, etc you had systems up in no time,
fast and with little non-functional bugs. And on the UI side you had keyboard
shortcuts and forms that worked 100% of the time. Maybe some kind of browser
based shell for running Harbour[1] apps.

[1] [https://harbour.github.io/](https://harbour.github.io/)

~~~
pjc50
This was kind of destroyed by Microsoft Access, wasn't it?

~~~
teh_klev
I wouldn't say Microsoft/Access was the sole cause. Nantucket (who were
eventually bought out by CA) and Ashton-Tate really missed the boat when it
came to developing Windows versions of their flagship apps/tools.

You should have a read of "In Search of Stupidity"[0] and revel in the eye-
watering commercial mistakes and foot shooting these companies indulged in
during the late 80's to mid 90's.

From the mid 80's until around 1995-96 I used many of the tools written about
in that book - WordStar, dBase, Clipper, then one day they were gone, largely
because of incompetence and entrenched complacency.

[0]: [http://amzn.eu/3Bqm2xR](http://amzn.eu/3Bqm2xR)

------
johnhattan
Having done TRS-80 BASIC for a couple of years in high school, Turbo Pascal
was a game-changer. I had a TinyPascal compiler for TRS-80, but Turbo Pascal
converted me the moment I saw someone switch from editing to compiling without
actually leaving the program.

I spent the summer saving up for my own 286 machine just so I could use it.

------
Shivetya
Turbo Pascal sparked my true interest in programming. Prior to that I
experimented with BASIC but never found it appealing though I did get to play
with it around with some people who could truly work magic with the language.

Dabbled in Modula-2 (stonybrook) and Turbo C. However I never really got into
Delphi as I wasn't that interested in OOP or Windows. Worse Borland did their
best to break my interest with the near constant upgrades that required buying
the product all over again and worse in bundles that exaggerated the price.

Turbo Pascal or similar would be a cool way to write web pages if it could be
extended that way without getting silly complex

~~~
brynlewis
You sort of can -
[http://www.elevatesoft.com/products?category=ewb](http://www.elevatesoft.com/products?category=ewb)

------
clouddrover
I think the nicest way to achieve "Pascal on the web" will be for Free Pascal
to implement WebAssembly support. Free Pascal can compile to the JVM
([http://wiki.freepascal.org/FPC_JVM](http://wiki.freepascal.org/FPC_JVM)),
not sure what their WebAssembly plans are.

~~~
dualogy
> for Free Pascal to implement WebAssembly support

I'd be content if the major _browsers_ could move wasm out of Preview (or
worse) Status for starters.. ;)

------
GregBuchholz
Can't pass up the opportunity to post a link to:

"Things That Turbo Pascal is Smaller Than"

[http://prog21.dadgum.com/116.html](http://prog21.dadgum.com/116.html)

------
pilif
I didn't start with Turbo Pascal as when that was in wide use my parents still
didn't allow me to go near a computer.

That didn't however stop Pascal from starting my career though as I started
programming for real a few years later with Delphi 2 which was running a
slightly improved version of Pascal with object oriented additions.

How I loved that programming environment: As quick and easy to use as VB, but
able to produce real native binaries that run without any (external) runtime
environment.

Plus you got all the windows SDK C headers pre-translated to Pascal so the
whole windows API was ready at your fingertips (what could possibly go wrong
when a self-thought teenager gets to write native code with complete
unprotected access to memory and threading?).

Delphi is what I've used for my first commercial project too and Delphi is
what I still use these days when I have to do some very, very rare Windows
work).

The language is phantastic. Even after years of not looking at my code, it is
very readable to me and I get back into productive mode very quickly.

Of course this might all just be nostalgia talking.

~~~
PeCaN
Definitely check out [http://www.lazarus-ide.org/](http://www.lazarus-
ide.org/) for a modern open-source Delphi reimplementation. It's great.

I agree that Delphi is quite nice. I use both Delphi and (much more)
C++Builder for work, but I wish more of it was Delphi.

------
bootload
source:
[https://github.com/lkesteloot/turbopascal](https://github.com/lkesteloot/turbopascal)

~~~
mp3geek
Last update from 11 months ago, doesn't bode well

~~~
JustSomeNobody
Maybe the project is done. Software can be done at some point.

~~~
boznz
A concept lost on a lot of people IMHO

------
Philipp__
What strikes me about (Turbo) Pascal is how good it is for introductory
programming! Just think about it, I find it to be like mixture of BASIC-like
structure with Pyhton-esque syntax.

Language in itself is very clean, and the way how static it is and how precise
you need to be with declaring of variables is great for preparing you for C
down the road. Then again you can do many things with it.

I remember writing my first serious apps in Pascal, (few hundreds LOC), it was
basically CRUD app, but it talked to .txt and .bin files. I learned a lot
about memory management, and it made me implement and really understand deeply
many concepts like linked lists, sorting algorithms and work with strings
(writing small parsers). I am very grateful for Pascal, and I think it changed
me forever, in a way where I got in love with it and I got hang of lower level
programming pretty early. After that when I went to C, I had to learn a lot
but it felt so natural. It's funny that I find myself struggling with Python
and JS (with JS I got better, Lisp and functional programming came in handy
there), cause I just can't get used to the language giving you pretty much
everything just by calling one simple method/function. Numbers of times I
found myself writing function for something trivial that already exists in
language by itself. Anyway, it felt great to think about old times and Pascal.
I think it is very underrated as a learning language.

~~~
pvg
In what way is the structure 'BASIC-like'? The later more structured BASICs
got that way influenced by languages like Pascal.

~~~
Philipp__
What I meant by that is that you had to do everything by yourself. Also it is
very clean. For example removing element from the array is not as trivial as
in Python.

~~~
pvg
Yeah that's not really BASIC-like at all, to me. It seems such an odd thing to
say since Pascal was pretty much designed to be the anti-BASIC - a language
for education but done 'right' through 'structured programming'.

------
alyandon
Turbo Pascal was my first experience in structured programming languages (and
a slick IDE to boot!).

The affordability of all the Turbo branded language products (and the
excellent printed documentation that came with them) that were made available
to me as child by my parents are on the primary reasons I have such a love for
technology and why I am in software development today.

It's really a shame that modern programming platforms don't capture some of
that same ease of use for experimentation. :(

------
rbanffy
How is it possible to not find multiple free (beer _or_ speech) Pascal
compilers that can deal with Turbo Pascal code after 30 seconds of googling?

~~~
rpeden
I could see myself not Googling very thoroughly if I were trying to find an
excuse to write a Turbo Pascal compiler. :)

Maybe the author was in a similar situation, whether conscious or not.

------
ilaksh
If you like Pascal check out [http://nim-lang.org](http://nim-lang.org)

------
BugsJustFindMe
My favorite Pascal compiler story is about the development of G-Pascal for the
Apple II and then C64 at
[http://www.supercoders.com.au/blog/nickgammongpascal.shtml](http://www.supercoders.com.au/blog/nickgammongpascal.shtml)

------
NuSkooler
There are a lot of stories here about starting out and/or really starting to
flourish as developer with Turbo Pascal. I'm in the same boat. I started out
with BASIC, then to Borland C of all things. One day as a kid I downloaded the
source to some DOS viruses from a "l33t" HPAVC BBS -- they were in Pascal. I
fell in love. This started a long line of developing programs in TP, then to
Delphi in the Windows world.

While I don't really use TP much anymore albeit the occasional pet project
using FPC's cross build ability to produce DOS binaries, Pascal has a special
place in my heart :)

------
k-mcgrady
Turbo Pascal was the first language I properly learnt after dabbling in VB a
little. This was about 12 years ago. I was in school at the time and did a
short work placement at Borland (developers of TP) where people found it
hilarious that I was learning TP. It's still one of the most enjoyable
languages I've written in but maybe that was just because of the challenge of
everything being new to me.

------
davb
> This compiler is the only project I've ever worked on, in my life, which I
> enjoyed every bit of.

I wish I could find a project that made me feel like that.

------
pjmlp
Turbo Pascal was great, I was already doing systems programming with 5.5,
learning about OOP, modular programming, using powerful frameworks like Turbo
Vision.

It was also my first compiler when I started doing Windows 3.1 development.
TPW with OWL was quite ahead of how MFC ended up.

------
antirez
Make sure to check the other projects from the same guy. Lovely things.

------
32wattle_park
omg, remind me of uni days... I liked turbo pascal.

------
mzs
D to list files

W to load file

R to run

~~~
cyberferret
I was kind of intrigued to note that 'C' for Compile didn't work. It was one
of those things I used to love doing when writing code, just to check for
syntax errors etc. after writing a procedure when I didn't want to commit to
running the app yet.

It was also a vanity thing - from memory it showed you how long it took to
compile, and I used to love seeing a several thousand line project compiling
in < 1 second.

------
JackFr
That looks nothing like a rose.

