
Things That Turbo Pascal is Smaller Than - johndcook
http://prog21.dadgum.com/116.html
======
kabdib
TP is about the same size as Leor Zolman's C compiler for the 8080.

Fast-forward about seven years, and my company was looking at an interpreted
BASIC implementation that took about 120K. Since this was supposed to live in
ROM, you could think about it as Real Money. We dug into it and found all
kinds of fat -- the usual 13 fear-based reimplementations of strlen and
strcpy, about a zillion porting layers, endless amounts of cut-and-paste
nonsense.

Somewhere between 1978 and 1985, the software industry's drive to be lean and
mean on PCs died. I found myself writing 'sed' scripts to do peephole
optimization on the intermediate assembly language of one of the C compilers
we were using. It was pathetic.

Now, of course, I light my cigars with gigabytes. But in terms of actual cost,
I'm still a cheap bastard and I probably don't spend any more money per year
on CPUs, memory or storage than I did 30 years ago.

Had a chance last year to write a mission-critical hunk of code that /had/ to
fit into 1920 bytes. I can't tell you how much fun that was.

~~~
archgoon
>Had a chance last year to write a mission-critical hunk of code that /had/ to
fit into 1920 bytes.

Awesome. What was that for? Please don't leave us hanging :)

~~~
xarien
I'm guessing DoD if he used the word mission.

~~~
perokreco
Mission-critical is actually a pretty common term and not really connected to
the military.

~~~
xarien
I don't disagree that it's used outside of defense. It's just used very very
commonly in defense. Just harmless speculation ;).

~~~
skrebbel
Big bucketloads of business terms and concepts were stolen from the military.

Tactical advantages, strategic initiatives, anyone? And what about the ranking
system in your average BigCo? They guys aren't called Sergeant or General but
in effect it's the same.

------
phil
Cool post, but I _really_ like this paragraph from his "recovering programmer"
page (linked in the sidebar):

"Somewhere along the lines, I realized I was looking at everything backward,
from an implementation point of view, not from the perspective of a finished
application, not considering the user first. And I realized that the inherent
bitterness and negativity of programming arguments and technical defensiveness
on the web were making me bitter and negative. I've consciously tried to
rewind, to go back to when programming was a tool for implementing my visions,
not its own end."

~~~
angrycoder
80% of what is on his blog is worth a read. The entries are terse, insightful,
and nostalgic without being sappy.

~~~
karterk
Dang, I wish it had a RSS feed! I now have a bunch of really good plain HTML
sites which I have to check manually for post updates.

~~~
Sukotto
No feed? No problem.

My go-to tool for sites without rss is <http://feed43.com> which I find easy
to set up. Also important to point out that it plays nice with the sites it
scrapes.

Example... Problem: I love lurking in ask.metafilter but only want to see
threads that have a "best answer" marked. No official feed for that.

Solution: <http://feed43.com/2602451534003772.xml>

Problem: I really like the PS238 comic but there's no direct feed

Solution: <http://feed43.com/ps238-link-only.xml>

Another tool that looks promising but I haven't really dug into yet is
<http://scraperwiki.com> (pardon the pun)

~~~
lordgilman
I'm also a huge fan of feed43 but I've managed to hit my head more than a few
times on its limitations. Coincidentally just this weekend I wrote a teeny
program as a replacement for feed43. I've got all my scrapers working with
XPath (which I prefer for this situation) but it's very straightforward to add
a new site. <https://github.com/dgilman/atom_maker>

------
davepeck
...and the original VisiCalc executable [1], at 27520 bytes, is smaller than
the _app icons_ in a modern iOS app bundle!

VisiCalc was, essentially, _the_ killer app of the early PC era.

The march of progress. ;-)

[1] <http://www.danbricklin.com/history/vcexecutable.htm>

~~~
watmough
The 60 Minutes interview passed over the Apple II very briefly, but it was
tremendously significant, for being one of the first computers popularized
with a killer app.

Obviously, this wasn't the be-all and end-all, but VisiCalc did for sure sell
many Apple II computers.

------
SageRaven
My first encounter with TP was as a high school senior in 89/90 in an AP
programming course. What a blast.

Anyway, for those who miss it, the binaries for Borland TP/TC were released
some time ago. Probably linked off the Wikipedia page.

The entire Borland Turbo series was cool. I had Turbo C, Pascal, and BASIC.
Though Quick BASIC was the gold standard (and almost as fun), my heart will
always have a soft spot for the original Borland DOS text-based IDEs.

In terms of utility value per byte of executable, that was such an interesting
time. There were so many cool boot sector viruses and utils during that era.
Anyone else remember that full-featured DOS-based .COM text editor that fit in
a single floppy disk sector (512B)? The original text-based DESQView? So many,
many neat programs given the limited hardware.

~~~
Luyt
I really liked Turbo C... It was so nicely integrated: the editor, compiler,
linker, visual debugger and excellent help system. It also had a nice paned
IDE which actually looked good and made it very usable on those old DOS
systems. [I had been using Alcyon C on the Atari ST and Lattice C on PC before
I discovered Turbo C].

I always have been (and still am) a fan of the Borland series of developer
tools - still using C++Builder today and still liking it.

<http://en.wikipedia.org/wiki/Philippe_Kahn>

 _"Philippe Kahn is a technology innovator and entrepreneur, who is credited
with creating the first camera phone solution sharing pictures instantly on
public networks. [...]

Kahn has founded four successful technology companies: His current company,
Fullpower Technologies, of which he is CEO, Starfish Software, LightSurf
Technologies, Borland. Fullpower provides solutions converging life sciences,
wireless technology, sensing such as accelerometrics, nanotechnology and
MotionX solutions. MotionX is the core technology that powers the Jawbone UP
Band and the Nike+ GPS solutions."_

------
joezydeco
We used to joke that a JPEG screenshot of an old Atari 2600 game was always
larger than the object code that ran the actual game.

~~~
mmahemoff
Leads to an interesting compression algo.

~~~
wlievens
Somewhat like <http://en.wikipedia.org/wiki/Fractal_compression>

------
cleaver
Turbo Pascal wasn't my introduction to programming, but it was where I started
to find my way. The edit, compile, test was factors of magnitude faster than
any other compilers.

Like the post says, it was very small, even for the time. The editor +
compiler was smaller than most text editors and many non-programmers would use
it as a word processor. At a time when a lot of systems only had 160KB floppy
drives (and no hard-drive), the size made a difference.

One great feature I remember was you could add inline assembler for things
that needed to be faster (my IBM clone processor was only 4.77MHz). I spent
hours shaving cycles off my Conway's Life program that was half Pascal and
half assembler.

~~~
deadcyclo
I have much the same history as you. Started out in basic, but turbo pascal
was what really got me going. I must admit that sometimes I really miss those
days. But then I remember the horrible feeling when the diskette and the
backup diskette with my hard work died, and suddenly I don't miss it that much
after all.

------
huhtenberg
While Turbo Pascal 3 was good, any true connoisseur would tell you that the
pinnacle of Turbo Pascal evolution was the version 5.5 (with an exception of
one annoying item in the editor †).

† The Find box was overlapping the highlighted search item when latter
happened to be in the top visible line.

~~~
vl
5.5 was the best - yellow font on blue background will always bring fond
memories, may be I should set Eclipse to that :)

And then came 6.0 and Turbo Vision - out of a sudden it was so easy to write
programs with windows. I still remember how I was reading printed out Turbo
Vision manual.

------
husted
Ahh the warm feelings of memories. My first job involved Modula2 and the Brief
editor. As I recalled Modula2 was supposed to be the successor of Pascal but I
guess it never really took off. At least I've never met anyone who did any
programming in Modula2.

This reminds me of .kkrieger[1], a game made by German demo group. It's a 3D
game where the executable at 96k is smaller than most readme.txt files for
other games. If we cut down all the abstractions layers we're using every day
we could create amazingly small program than ran at blistering pace. Of cause
development time would explode :-)

[1] <http://en.wikipedia.org/wiki/.kkrieger>

------
marcins
I don't see why he compared Turbo Pascal to the Wikipedia page on C++ - Turbo
Pascal is also much smaller than the Wikipedia page on Turbo Pascal :)

------
miked
That wasn't the only thing that was small about TP. The entire documentation
for version 2 was a single book about 8 inches high, 5 1/2 inches wide and
about an inch think. You could learn the entire language, IDE, library, and
debugger in a weekend.

Only six months before I met TP I had been using punch cards on the
University's mainframe. TP2 was pure shock and awe.

~~~
wanorris
A whole inch thick? The first edition of _The C Programming Language_ couldn't
have been half that!

~~~
ramchip
According to the OP, "You could learn the entire language, IDE, library, and
debugger in a weekend." This implies that the manual covers a lot more ground
than _The C Programming Language_ , which (AFAIK) doesn't say anything about
Emacs, GDB, GCC, sockets...

------
lloeki

        $ file /usr/bin/touch
        /usr/bin/touch: Mach-O universal binary with 2 architectures
        /usr/bin/touch (for architecture x86_64):	Mach-O 64-bit executable x86_64
        /usr/bin/touch (for architecture i386):	Mach-O executable i386
    

So actually _touch_ on Lion is ~half of 44016. But that's being nitpicky ;)

~~~
4ad
You are assuming i386 and amd64 have the same code density, which is not true,
also you are neglecting the Mach-O headers and how sections are zero-padded
for alignment.

~~~
lloeki

        cp /usr/bin/touch ./; for arch in i386 x86_64; do lipo -thin $arch touch -o touch.$arch; done; ls -l touch*
        -r-xr-xr-x  1 lloeki  staff  44016 31 Oct 11:37 touch
        -r-xr-xr-x  1 lloeki  staff  19440 31 Oct 11:37 touch.i386
        -r-xr-xr-x  1 lloeki  staff  19440 31 Oct 11:37 touch.x86_64

~~~
4ad
The object code is significantly less then the size of the binaries, Mach-O
files (and ELF files and PE-COFF files) zero pad sections, allign them and
generally have extraneous sections.

The boxes are the same, the content is different.

~~~
lloeki

        > cat touch.x86_64 | perl -p -e 's/\0//' | wc -c
        19407
        > cat touch.i386 | perl -p -e 's/\0//' | wc -c
        19408
    
        > otool -tV touch.x86_64 | wc -l
        742
        > otool -tV touch.i386 | wc -l
        808
    

Hmmm.

So, now what? The article mentioned Lion's touch(1) size, and I wanted to
point out that it actually covers two arches. We know there is padding,
alignment, headers and density whatnot. The end result is that makes a
negligible difference between the two arches, hence _"~half"_.

------
Tloewald
It might be fun to compare think/lightspeed pascal/c since they included a
full GUI IDE (and inline assembler) as well as full support for the Mac
toolbox. (These products were to the Mac what borland's products were for DOS
and Windows.)

I know you could fit early versions of lightspeed pascal or c on a single
floppy disk with a copy of System 3.2.

------
ChuckMcM
Turbo Pascal totally rocked. I remember thinking "I can totally dump MASM and
Visual C now!"

~~~
pjmlp
Really?! Pity that Visual C did not exist at the time.

~~~
ChuckMcM
What I meant was Microsoft's bloated and unwieldy C compiler, I don't recall
if it had achieved the moniker 'visual' by DOS 4 or if that waited until Win95
release. It came in a green box on at least 4 floppies and was a PITA to use.
Turbo Pascal, compared to that, made me wonder why Microsoft didn't adopt it
as their 'main' implementation tool.

~~~
DanBC
Wikipedia has some rumour:

> _Bill Gates saw the success of Turbo Pascal "in very personal terms, and
> 'couldn't understand why [Microsoft's] stuff was so slow. He would bring in
> poor Greg Whitten [programming director of Microsoft languages] and yell at
> him for half an hour.' He couldn't understand why Kahn had been able to beat
> an established competitor like Microsoft."_

It's certainly possible that someone was using TurboPascal (discontinued mid
90s) at same time as VisualC or the early version of MS C.

------
hippich
Could someone explain why _touch_ program is 47 Kbytes size? Just checked my
Ubuntu machine to confirm this.

~~~
mkopinsky
Probably because it's statically linked with some standard libraries. If you
write a hello world app in C++ and compile/link with all the defaults, you'll
see similar results.

~~~
beza1e1
It is not. It even dynamically links to libpthread ...

------
hrabago
I learned programming with Turbo Pascal. I remember appreciating how it used a
"Smart Linker" could produce really small executables because it stripped out
any unreferenced code. I can't remember now how small the Hello World .exe
files were, but they were small.

------
bardamu
I'm surprised that nobody mentioned Wirth and Oberon yet. His '95 paper "A
Plea for Lean Software" mentions Wirth's law: "Software is getting slower more
rapidly than hardware becomes faster."

------
malbs
The old computer joke...

\- Cheap \- Fast \- Good

Choose any two

With TP, you got all three!

~~~
whacker
fast is about development speed, not performance.

~~~
malbs
actually the original joke was about buying a new computer, I mutated it to
apply it to TP

------
icey
Turbo Pascal was my first programming language. I thought it was the coolest
thing ever that I could write a game, put it on a floppy disk and share it
with all my friends.

I wish there was something like Github back then; I lost all my early source
code years ago. It would be fun to see how terrible it looked :)

------
sehugg
Already posted, but relevant (and fairly technical) details about Turbo Pascal
3: <http://pcengines.ch/tp3.htm>

------
Hitchhiker
Anybody here loved <http://en.wikipedia.org/wiki/Turbo_Vision> back in the day
? ;-)

~~~
tluyben2
Yes, I was. I still open it up to compile and play around with some old things
I made.

~~~
Hitchhiker
Nostalgia :-)

~~~
tluyben2
Yeah! Slight small headache when I see my code from then. It's not great now,
but luckily I progressed somewhat.

------
RexRollman
I still think it is appalling that recent commercial operating systems take
gigabytes of disk space to install.

~~~
Tloewald
What truly appalls me is 900mb patches.

~~~
untog
What truly appalls me is _not using_ patches. Why do I have to download the
entire firmware each time, Apple? Why? Why?!

~~~
RexRollman
Are you talking about iOS updates? If so, I believe this has changed with iOS
5, at least with over the air self-updating.

~~~
untog
That's good to hear. I still had to download an 80MB iTunes update recently,
but hopefully the update tech they're using will spread across the company.

------
FreshCode
Comparing executable byte counts with source code or English character counts
is ridiculous.

------
rbanffy
I think the MS-DOS version is not smaller than the CP/M 80 version I learned
Pascal with ;-)

~~~
cleaver
I would be surprised if the CP/M version was any smaller. Turbo Pascal was
smaller and faster than anything else at the time. However, the CP/M version
would not have been a native compiler. Pascal generally compiled to p-code
which was then interpreted (and was therefore slower).

~~~
peteri
The CP/M version was a native compiler. The real limitation with the Z80
version was that recursion required either a compile time switch or annotation
on the functions (It's so long ago I can't remember)

Somewhere I have a copy of just the editor portion of turbo pascal (from
memory it's around 13K) that I snaffled when I worked for Borland in the mid
80s. Sadly no good anymore as 16 bit COM programs won't run on my 64 bit
system.

~~~
yangyang
> 16 bit COM programs won't run on my 64 bit system

Have you tried DOSBox?

~~~
peteri
Yep that would work, just a bit pointless except for nostalgia purposes.

------
cturner
Do older versions of turbo pascal have any edge over freepascal?

------
Tangaroa
Looking around my old DOS files, qbasic.exe is 254,799 bytes, plus a 133,810
help file. 400kb is larger than anything on that list, but we can think of
lots of things larger than 400k. I don't seem to have Turbo C++ on my system
any more, but it came on floppies and was probably no more than 15MB unpacked.

The entire MS-DOS 5.0 distribution is around 2.2MB. Norton Utilities is
2,316,176 bytes. For a complex application that uses graphics and fonts, Print
Shop is 2,716,489 bytes. The average Flash game is larger these days, although
that is largely due to music and bitmaps. Individual files in my /usr/bin that
are larger than all of MS-DOS or Norton include python2.7 (2,375,356) mono
(2,637,288), gdb (3,888,248), doxygen (5,413,488), and smbclient (6,512,344),
and these files are stripped.

Linux kernel modules are still relatively small. Most are under 50k, although
mac80211 is 257,001 and i915 is 451,033. The psmouse module is 73,312, almost
twice the size of Turbo Pascal to drive my mouse.

Most files in /bin are still small. Turbo Pascal is just barely larger than ed
(38,464) and cat (38,484), and is smaller than touch (42,552) on my system as
well.

Turbo Pascal is also smaller than the gzipped man file for rsync (49,400),
/etc/bash_completion (58,739), the Neko compiler (176,073) and DLL (94,203)
for Windows, and GNU cmp for Windows (57,344).

~~~
bryanlarsen
Yes, most files in /bin are small, but that's because they're dynamically
linked to libc, amongst others. I bet you virtually all of them would be
larger than Turbo Pascal if statically linked.

------
skeptical
Not a surprise to anyone familiar with pascal's grammer.

~~~
baddox
A language's grammar wouldn't necessarily be a good indicator of
implementation size, would it?

~~~
groovy2shoes
Not necessarily. Some grammars can be parsed with simpler code than others,
but optimizations can make a compiler larger. Also of note is that Turbo
Pascal was written by hand in assembly language, and the executable wasn't
likely to have been linked with any libraries.

~~~
bhangi
Indeed TP did not have any linking step. I still recall trying to fruitlessly
find "Link" on the menu for quite some time until it hit me -- oh, no linking
needed. But TP did include a run-time with each of the generated executable.
This run-time was part of the compiler and it was approximately 10K (from
memory, so I could be wrong). That makes the compiler about 22Kbytes worth of
code, which is even more impressive.

~~~
groovy2shoes
I wasn't aware that the runtime was included in the executable. Oh, the things
we did in the DOS days!

------
georgieporgie
Turbo Pascal 6.0 was the pinnacle of IDEs. Or the pinnacle of my joy in
programming, which, of course, is difficult to distinguish. :-)

I spent hours upon hours poring over VGA graphics code in Pascal, then
assembly (called by Pascal, since I wasn't sophisticated enough to understand
how to build a stand-alone EXE from ASM) in high school. I would tweak things,
then run against the slick built-in profiler, then refine some more. Some time
later, I came across this vast information pipe called Usenet and found out
that everything I worked on was years out of date, since ModeX provided
dramatically faster access to video memory. Ignorance is bliss...

