
Adobe Photoshop 1.0.1 Source Code (2013) - dvfjsdhgfv
http://www.computerhistory.org/atchm/adobe-photoshop-source-code/
======
todd8
While at Texas Instruments, around 1976, I was in the group trying to move the
company to use a more modern programming language. I had learned Pascal while
in grad school by studying Wirth’s compiler source so I was happy to be in
this department. We had built a commercial, extended, Pascal that ran on the
company’s own hardware, microprocessors though minicomputers.

The goal was to move the COBOL, Fortran, JOVIAL, and assembly language
programmers in the company to Pascal. My department built the compiler and
because I had taught programming in grad school I ended up being one of the
evangelists that taught innumerable one week crash courses to the company’s
engineers, business programmers, and software people. It was actually a really
fun job and I met a large number of people that worked in the company’s
various branches.

I discovered that there is no better way to learn every facet of something
than to teach it, more than once, to grumpy students sceptical of the new
fangled concepts.

A couple years later I was back in grad school again, still programming in
Pascal. It was interesting to realize that most fellow PhD students that go
straight through aren’t really good programmers and don’t understand software
engineering. (This was a long time ago so it’s probably very different now. CS
students own their own computers and are able to program much more than we
could.)

I remember Pascal fondly like some friends remember their first car. Like cars
though, the new languages are really much better (safer, faster, more
reliable, etc).

~~~
0xffff2
>This was a long time ago so it’s probably very different now.

As a recent CS undergrad and current software engineer in a research
organization, I don't think it is. Most of the people I worked with on group
assignments in my undergrad had, at best, a limited understanding of their
prior coursework, much less any knowledge acquired on their own time.
Furthermore, CS PhDs in my org don't know anything about software engineering
and mostly don't care. They are really here to do math. They don't need to
write good code because I can transform their mediocre (from an SE
perspective) code that handles the base case of a complex algorithm into
better code that is maintainable, handles error cases and integrates with the
rest of our codebase.

------
sdrothrock
> His brother John, working at the movie visual effects company Industrial
> Light & Magic, found it useful for editing photos, but it wasn’t intended to
> be a product.

John Knoll is a name that may be familiar to people who stick around after the
credits; he was ILM's supervisor on Generations and First Contact, all the
Star Wars prequels, some Harry Potter movies, as well as some of the Pirates
of the Caribbean movies. His name comes up a lot in behind-the-scenes
interviews etc. with directors about effects.

~~~
thomasfl
John Knoll also came up with the plot for the Star Wars Rouge One film
released in 2016. Versatile fellow.

~~~
prewett
Have him write more Star Wars plots! I thought "Rogue One" was the best of all
of them.

------
dvfjsdhgfv
The original title "Adobe Photoshop was written in Pascal" has been changed,
and it's a pity - what is important in this story is the fact that the first
commercial versions of one of the most popular pieces of software were written
in a language frowned upon by many programmers today. Moreover, it shows that
you can successfully write the app in one language, then rewrite it in
something else while maintaining a smooth continuity between versions.

~~~
rasz
One of the biggest industry standard PCB design packages, Altium Designer, is
written in Delphi (wiki is wrong claiming C#)
[https://community.embarcadero.com/blogs/entry/altium-
designe...](https://community.embarcadero.com/blogs/entry/altium-
designer-15-000-000-codelines-1600)

~~~
vintagedave
There are many big and well-known software packages written in Delphi. Yet
Delphi the language is not well known.

I recently read an article on Flutter comparing to native Android layouts, and
thought to myself: Delphi has had a x-plat framework that does all that, and
more, in less lines of code, for six years.

(*) Disclaimer: I work for the company that makes Delphi. I do that because I
think it and its sister C++Builder are great products and want to see it
better-known.

~~~
StavrosK
There's a big obstacle to Delphi adoption that people below have mentioned:
Cost. Even the starter pack has a limit of $1000 in revenue, and Delphi costs
$3000 or so. I'm never going to use Delphi if it means that five years later,
my app that costs $3 and makes a sale a week will need me to spend $3000
licensing it or open me up to lawsuits.

I like Autodesk's license for Fusion, it's free to use (the full version)
until you're making $100,000 in yearly revenues, after which it costs some
amount of money. If I were making $100k in revenues (and probably well before
that), I would happily pay for the tool that's making me money, but paying 3x
my revenue for the IDE/language is hilariously prohibitive. There's also no
way in hell I'm going to spend $3000 for a hobby project that may or may not
make $100 during its lifetime.

It's too bad, too, because I remember how easy and quick developing in VB4/VB5
was, so Delphi sounds great on paper, and I would definitely use it to develop
at least some applications if it weren't so expensive.

~~~
ksec
>It's too bad, too, because I remember how easy and quick developing in
VB4/VB5 was, so Delphi sounds great on paper, and I would definitely use it to
develop at least some applications if it weren't so expensive.

I have been having these thoughts for the past few weeks. After the watching
DHH's RailsConf Keynote and thinking about Conceptual Compression, and current
technology. Why have we made everything 10x more complicated over years. It is
not just Web Sites, Apps as well. VB may be ugly, but it lower the entry
barrier. ( VB.Net is an entirely different thing ). Delphi literally have
everything done right for well over a decade and it's idea and philosophy
aren't being copied anywhere.

Instead of making software easier for everybody to learn, easier to maintain
and less prone to bug, making debugging easier, higher performant and less
recourse hungry. We have managed to bloat the framework, the languages, the
CPU and memory resources, trillion times more abstracted. Everything is a hack
over another hack.

~~~
StavrosK
Exactly. The problem with Delphi is that it tries to be too many things, for
example we don't need another language ecosystem, but we do need great cross-
platform UI toolkits/development workflows. Delphi excels at that, but if the
library I want to use isn't available for the language, I'm out of luck.

If we could keep the great dev tooling and UI toolkit, but use a language with
a larger ecosystem, that would be much more impactful. Maybe Python + Qt can
be the answer to that.

------
buserror
_everything_ was written in pascal back then, not just Photoshop. I spent
years writing pascal as a professional mac developer before Lightspeed C
(which became THINK, then Symantec C later on) appeared... Then I never looked
back.

MPW (Macintosh Programmer's workshop) was pretty awesome, if slow as hell --
Turbo Pascal was a lot better to work with -- the only issue is that it
'tokenized' your source code, so it wasn't plaint text anymore...

I still miss these 'one pass' compilers; I think it peaked with MetroWerks
toolchain (which kept a Pascal plugin for a long time!) that was IMO the best
compiler/linker/debugger toolset ever made.

~~~
bpizzi
At work we're maintaining a rather big software written in C (not that much,
<1M loc).

It's a bit odd: there's no brackets at all (only BEGIN and END), and the
majority of names (functions and variables) are 6 characters long.

Guess what, it's was ported from Pascal. There's a '#define BEGIN {' in a
header.

~~~
olavk
Didn't editors have search-replace back then? Although I can understand this
if the developers hated C and was forced to port against their will.

~~~
bpizzi
They were not forced, it was their choice, and the choosen editor (vs6) do
have search/replace. My personal guess is that keeping those BEGIN/END was
seen as a smart move.

~~~
solarkraft
I guess they just liked the way it looked & felt? Really doesn't seem to make
a difference to the development other than it feeling more familiar to Pascal
devs.

~~~
bpizzi
It doesn't harm the development, indeed. However it does harm the developer's
freedom in choosing his tools, for example Vim will try to fold regions
delimited by brackets in C files. Nothing unbearable in the end.

------
doomlaser
The core underpinnings of the Mac, including QuickDraw, were written in
Pascal, with some 68k assembly in critical speed sections.

QuickDraw began life in 1979 written by Bill Atkinson in Pascal and still
ships in MacOS High Sierra. Photoshop originally lifted its main design
metaphors and toolbar icons from Atkinson's (and Susan Kare's) MacPaint.

MacPaint and QuickDraw source code:
[http://www.computerhistory.org/atchm/macpaint-and-
quickdraw-...](http://www.computerhistory.org/atchm/macpaint-and-quickdraw-
source-code/)

Recent long-form interview with Bill Atkinson:
[https://www.youtube.com/watch?v=6tUWoy1tJkE](https://www.youtube.com/watch?v=6tUWoy1tJkE)

~~~
pjmlp
The switch to C and C++ only came when Apple decided to cater to the
increasing UNIX market pressure.

Which was actually C++, given that they tried to port MacApp to C++.

While at the same time Metrowerks, which was the major compiler vendor on the
Mac, introduced PowerPlant.

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

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

[https://archive.org/stream/ApplePascalHistoryDTC92/ApplePasc...](https://archive.org/stream/ApplePascalHistoryDTC92/ApplePascalHistoryDTC92_djvu.txt)

Comments at [http://blog.fogus.me/2017/07/20/pascal-at-
apple/](http://blog.fogus.me/2017/07/20/pascal-at-apple/)

So plain C always had very little place at Apple, even at NeXT it was all
about Objective-C and Objective-C++, including the driver framework.

Both A/UX and NeXTSTEP used UNIX compatibility as a means to bring software
into the platform, but the goodies were in the platform specific frameworks.

~~~
buserror
I remember these years well, and there were _years_ where C (not C++) was
prevalent on the mac dev market.

Metrowerks only appears quite late, with the PowerPC macs -- I remember having
both a prototype of the PowerPC 601 66Mhz pizza box _and_ the fancy new
compiler on the block delivered from apple (I remember the excitement -- that
sort of excitement new tech delivered that I never really found again after
that decade!). I stayed on the 'permanent beta list' of metrowerks until they
vanished.

Before that, THINK C/Symantec C/C++ existed and were in use extensively
_including inside of apple_ , but most of the software was plain C, or "base
C++" (it was before the time of templates and stuff like that) at best...

Apple _never_ used C++ for system interfaces. Even 'Carbon' on OSX still used
Pascal Strings for the historycal toolbox calls. Over the years they added
extra helpers and extra glue code to cater for C, but they stuck more or less
to their API design until OSX arrived.

The funny bit is that even _afterward_ they continued with some of their
paradigms, the 'component' one for example, was still in used for years
afterward for quicktime stuff, in OSX. Likewise the AppleEvents (also using
"components") had the same paradigm and structures as it ever had (and migth
still have!)

~~~
jcelerier
> Apple never used C++ for system interfaces.

... eh ?
[https://developer.apple.com/library/content/documentation/De...](https://developer.apple.com/library/content/documentation/DeviceDrivers/Conceptual/WritingDeviceDriver/CPluPlusRuntime/CPlusPlusRuntime.html)

~~~
buserror
That's an OSX kernel interface, not at all related to what they called
'classic' afterward...

Beside, despite the syntax sugar, it is NOWHERE near C++ at all. No
constructors/destructor (if I remember correctly), no stack based objects, no
exceptions, no virtual functions, no library, and you had to provision your
classes with the right number of member function 'dummy' pointers to allow for
expansion. I've written enough OSX drivers back then to know that, quite
frankly, C would have been a lot better.

~~~
jcelerier
> No constructors/destructor (if I remember correctly), no stack based
> objects, no exceptions, no virtual functions, no library, and you had to
> provision your classes with the right number of member function 'dummy'
> pointers to allow for expansion.

I think that you are fairly mistaken. IOKit drivers are written by inheriting
from a base class and overloading virtual functions.

Here's how it looks :
[https://developer.apple.com/library/content/documentation/Da...](https://developer.apple.com/library/content/documentation/Darwin/Conceptual/KEXTConcept/KEXTConceptIOKit/iokit_tutorial.html#//apple_ref/doc/uid/20002366-100120)
; it may be not 2018 template-metaprogramming bliss, but it's fairly standard
C++.

------
AriaMinaei
When I was making some Photoshop extensions [0], I slowly formed a general
idea for how it works under the hood.

Initially I was really excited to write some code and give Photoshop some
super powers. Especially I wanted to make a panel for automatic layout, and
another for generative art.

But in the end I realised that Photoshop is just not designed to be extensible
other than in some very specific ways (filters mostly).

I was also convinced that even Adobe probably has trouble putting in new
features. This was surprising knowing that most of Photoshop's features don't
interact with other features in any way (unlike a word processor or a 3D
design suit like Maya). They can even develop the features in silos if they
want to. But still, the extension APIs give some strong hints that the whole
thing is tangled and unwieldy [1].

I did try to tame the thing [2] but the whole process was so unstable that
after a few months of part time work, I just gave up. My conclusion was that
if you want to have a design tool with super powers, you can't build it on top
of Photoshop (or any of its competitors for that matter).

Anyway, this is where I shamelessly self-plug and say that I decided to start
a company to build such a tool myself. Write to me [3] if you would like to
learn more ;)

\---

[0] This was one popular extension I wrote:
[http://gelobi.org/griddify](http://gelobi.org/griddify)

[1] I didn't care enough to document this, but I'm sure there are other
extension developers who agree.

[2] [https://github.com/AriaMinaei/photoshopjs-
com/blob/25c320f83...](https://github.com/AriaMinaei/photoshopjs-
com/blob/25c320f8304a29ddddacd9b571c921354b15caf7/src/comInterface/Desc.coffee)

[3] aria [at] theaterjs.com

~~~
dvfjsdhgfv
Good luck! I had some limited success in extending InDesign, but only in the
documented way. The debugging process is a PITA for more complex things
though.

~~~
AriaMinaei
Hm, does ID also provide this COM interface?

    
    
      var idMk = charIDToTypeID( "Mk  " );
        var desc7 = new ActionDescriptor();
        var idNw = charIDToTypeID( "Nw  " );
        ...

------
mistrial9
Photoshop is a MacApp framework project. Apple Inc. designed and built MacApp
and was promoting it to the developers with stage time at the Developer's
Conference, and by never mentioning or acknowledging other frameworks.

Meanwhile, the Think Class Library (C) was designed and written by an
individual .. a name given after the group behind Think-C / Lightspeed C got
behind it.. The lone designer of the original Think Class Library is named
Gregory H Dow.

It is a subjective statement, but I believe that more than four times the
number of big name Macintosh apps were written in Think Class Library, in C,
than Pascal MacApp from Apple.. There was a big interest in C for the
Macintosh, while Apple repeatedly pushed their own Pascal, until Apple could
control their own C compiler in the Macintosh Programmers Workshop (MPW).
(edit- MPW C existed internally at Apple for a long while, but there was some
disconnect between that and the developer tools marketing)

Gregory H Dow then designed and built a second generation framework using C++,
called PowerPlant for Metrowerks CodeWarrior. PowerPlant was used for many,
many more commercial applications after that. Pascal faded away on the
Macintosh OS, even with the forceful support of Apple.

------
boznz
"There are only a few comments in the version 1.0 source code, most of which
are associated with assembly language snippets. That said, the lack of
comments is simply not an issue. This code is so literate, so easy to read,
that comments might even have gotten in the way."

I also find comments do get in the way when they state the obvious, unless
they add to the understanding of the code in some way it is best to leave them
out IMHO.

~~~
tzahola

        if (status != 0) return -1; // return on error
    

I always get angry when I find comments like this in our codebase.

~~~
ak39
_Why_ would a comment like that make you angry?

~~~
sudhirj
Because it re-states what the code is saying, which makes it two things you
wind up reading to absorb one fact. It also create two update points if that
code needs be changed.

I prefer that authors spend time to make sure the code is clear about _what_
is happening, and use the comments to tell me _why_ it's happening, and that
too only when it's not obvious, or counterintuitive, or there for a special
requirement.

Just wanted to point out that comments are not to be confused with
documentation as comments, like Javadoc, Godoc strings. These need to be
complete and verbose, especially if they code is a library or public.

~~~
zeth___
It doesn't.

-1 could mean you're returning a success. I mean that would literally be true in Forth.

~~~
icebraining
You're showing another problem with these comments: they're often ambiguous.

Specifically, the message says "return _on_ error", which to me doesn't mean
it returns _an_ error, but to you it did.

------
omegote
It would be great if someone did a high level diagram of the source code to
have a taste of the overall architecture without having to dig into the code,
specially for those who, like me, don't speak Pascal.

~~~
krylon
FWIW, Pascal, at least when it is reasonably well-written, is super easy to
read, even if you have no or little prior experience with the language.

------
wallflower
This is a great interview with Thomas Knoll from DDJ about making Photoshop.

[http://www.drdobbs.com/a-conversation-with-john-
knoll/184410...](http://www.drdobbs.com/a-conversation-with-john-
knoll/184410606)

------
zengid
Really cool bit of history! I keep coming back to the idea that studying
Photoshop is a great way for learning about how to engineer desktop
applications and GUIs. Discovering Sean Parent's _Better Code_ lecture series
has been a dream come true!

------
wila
What is weird is that it has the exact same acknowledgements as the Eudora
article.

Including:

> Thanks to Steve Dorner, Jeff Beckley, and John Noerenberg for their
> encouragement and participation in this multiyear odyssey to release the
> code, and for creating Eudora in the first place. You should be very proud
> of what you did.

edit: I mean it is weird because this was released in 2013 and it has
acknowledgements of a another current release. Seems like a template change or
something similar.

~~~
m0dest
Copy pasta.

------
bshanks
Strangely, i find the UI screenshots in the article to be clearer than some
modern UIs (eg Gimp).

Why? I'm not sure, but maybe: (1) there is less functionality, so less stuff
on the screen. (2) Black and white means that the icons are all high contrast.
(3) the icon shapes are simpler (compared to Gimp's toolbar icons). (4) the
borders on the forms are higher contrast; in Gimp's color picker form, for
example, the boxes surrounding places where you can type stuff in appear to be
gray, whereas they are black in these early Photoshop pictures.

------
cyberferret
My very first commercial app, (A pharmacy point of sale system in 1986), was
written in Turbo Pascal 1.x. Nice to hear I share some similarities to the
early days with a software system that is essentially a household name today.

NB: I recently downloaded a copy of Turbo Pascal 1.x and been messing around
with it in a DOS box on the Win7 laptop again. No idea where that source code
I wrote 40 odd years ago is now, and no way of getting it off any sort of
medium it might have been on either!

~~~
xvilka
Why not to try FreePascal and Lazarus then?

~~~
mhd
If someone's going for TP 1.0 instead of even newer TP versions, I guess
nostalgia plays a big role. Up until TP 4 or 5, it didn't have things we take
granted now (or heck, in the 90s). Like Units.

------
PeterStuer
The THINK/Lightspeed Pascal IDE was awesome, way ahead of its time. Coupled
with the Apple A4 portrait display it was heaven.

------
therealmarv
would be cool to know the percentage of different codebase nowadays.

~~~
dvfjsdhgfv
I bet there are some Adobe programmers reading HN; I don't think some rough
estimates would be a violation of their NDA and I'd be curious to hear them,
too.

------
guylepage3
As a long time fan of Photoshop and the Knoll brothers, this is amazing..
Going to figure out a way to pay homage to this code base. Any recommendations
are welcome.

~~~
welly
Print it out and make a suit from the listing

------
patrickg_zill
Does Pascal allow a programmer to shoot themselves in the foot the way that C
does? Does it have safer memory handling?

~~~
narag
What some younger programmers don't get is that allowing to do things is good,
the real question is what style a language _encourages_.

~~~
seba_dos1
Younger programmers usually believe that the best thing is the one that allows
you to effortlessly do anything you want. Only later they start to see that
some limitations and hurdles might actually be beneficial.

~~~
narag
I was careful to qualify "some" programmers and avoid generalization. Some
younger programmers like this, some others like that. The difference is in
ancient times I don't remember so many people liking discipline languages.

Funny thing is Pascal was seen as the constraints language at that time, while
C was more _liberal_. Different times.

In Pascal evolution (Delphi and Lazarus), a lot of automatic memory
management, including proper gc but most often simple referemce count, has
been incorporated over the years. Also the memory for a lot of standard
library resources is managed hierarchically.

In short: You still need to know how to deal with memory manually, but most of
the time you don't.

------
neelkadia
#Help How to run this into latest Mac?

------
xaedes
Mnnn... Light gray text on white background, so hard to read

~~~
fredsted
There's something called "Reader Mode" in most browsers now, if you click it,
the text becomes readable.

~~~
wierd0
I know, isn't the future great? To read a web page, just enter an url in
chrome, once it has loaded go ahead and click "yes you may track me" then
finally "reader mode" and the world is yours.

------
gumballcough
Good that someone found a use for it. I studied it at Uni and then never used
it again.

~~~
askvictor
Seems you never had the pleasure of using Delphi then. It was by far the most
pleasurable experience I've ever had writing code - in generations to come it
will be remembered as the peak of coding ease and efficiency.

~~~
JdeBP
It's over a grand and a half a pop just for the cheapest flavour, nowadays.
C++ Builder is the same.

* [https://embarcadero.com/app-development-tools-store/delphi](https://embarcadero.com/app-development-tools-store/delphi)

* [https://embarcadero.com/app-development-tools-store/cbuilder](https://embarcadero.com/app-development-tools-store/cbuilder)

There _are_ lower-cost "starter" editions, that however have restrictions on
use.

* [https://embarcadero.com/products/delphi/starter/info](https://embarcadero.com/products/delphi/starter/info)

The feature matrix is 37 pages long. There's all sorts of stuff in there. For
examples: UML is Delphi-only. Some tools for debugging multi-threaded programs
aren't in the "starter" flavours. Nor is the ability to debug any process; nor
to run until function return; nor for targetting Win64.

* [https://embarcadero.com/features/feature-matrix](https://embarcadero.com/features/feature-matrix)

~~~
askvictor
Don't know what it's like nowadays; I suspect it's fallen from it's former
glory.

Nevertheless, if you consider that $1500 is less than a week's salary for a
programmer, you just need to work out whether a $1500 tool is going to save
you a week of programming time. Back in the day I was using the heavily
discounted education edition as I was a poor student; many products still have
something like this (for example JetBrains' suite is free for students and OSS
projects). But the price itself isn't really that much in the scheme of
things.

There's also Lazarus - an OSS delphi clone

~~~
JdeBP
> _$1500 is less than a week 's salary for a programmer_

It is pounds, not dollars. And no it isn't.

