* * *

Author Topic: Compile Photoshop Pascal Code  (Read 2783 times)

x2nie

  • Sr. Member
  • ****
  • Posts: 478
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
Compile Photoshop Pascal Code
« on: April 24, 2018, 11:22:24 am »

Hi guys, you know Adobe Photoshop source code is available to download and was written in Pascal programming language.
http://forum.lazarus.freepascal.org/index.php/topic,19922.0.html


It said that it is released to public for learning purpose.


Sadly I didn't understand it because it is not written in OOP (which I expected to be).
Perhaps the dialect is too old, and I assumed that nowadays Pascal Language is very different.
--------


So, for learning purpose I have few questions:


1. What is advantage of using "Object" rather than "Class"
2. What is difference between "Object" and "TObject" ?
3. Was there OOP implementation in the day Photoshop 1.0 being written ?
3.b) if it was, why they were using Object instead of Class ?
4. How can we compile the source code (using cross-compile or whatever) ?
5. What the compiler they use to build/compile ?
6. Am I right: I think the fpc is not available yet in that day?


I am very curios because all information/comment in internet of Photoshop 1.xx source code is about general programming, I didn't found yet in specific Pascal Programming Languange, which is it was written in.


thanks you :-*
When you were logged in, you can see attachments.
Lazarus Trunk @ Windows7 64bit, XP 32bit, Debian under VirtualMachine

Handoko

  • Hero Member
  • *****
  • Posts: 2581
  • My goal: build my own game engine using Lazarus
Re: Compile Photoshop Pascal Code
« Reply #1 on: April 24, 2018, 12:04:01 pm »
I ever heard that using object is faster than class because object allocate memory on the stack while class is on the heap.

TObject is the base class of all classes. Read more: http://wiki.freepascal.org/TObject

Free Pascal first released on 1997, Adobe Photoshop in 1990. Not sure what compiler they used. I guess Delphi/TP/TPWIn, because those were very famous in the old time.
« Last Edit: April 24, 2018, 12:09:16 pm by Handoko »

RayoGlauco

  • Jr. Member
  • **
  • Posts: 78
  • Beers: 1567
Re: Compile Photoshop Pascal Code
« Reply #2 on: April 24, 2018, 12:39:11 pm »
I found a web page that explains how to compile the old version of Photoshop. It says:
Quote
If you are going to build Photoshop from the distributed files, you need a Macintosh Object Pascal compiler, its associated libraries, and the appropriate version of the MacApp class library.

http://basalgangster.macgui.com/RetroMacComputing/The_Long_View/Entries/2013/3/30_Building_Photoshop.html
« Last Edit: April 24, 2018, 12:43:10 pm by RayoGlauco »
To err is human, but to really mess things up, you need a computer.

Thaddy

  • Hero Member
  • *****
  • Posts: 6756
Re: Compile Photoshop Pascal Code
« Reply #3 on: April 24, 2018, 12:43:59 pm »
I found a web page that explains how to compile the old Photoshop version. It says:
Quote
If you are going to build Photoshop from the distributed files, you need a Macintosh Object Pascal compiler, its associated libraries, and the appropriate version of the MacApp class library.

http://basalgangster.macgui.com/RetroMacComputing/The_Long_View/Entries/2013/3/30_Building_Photoshop.html
Indeed. Note FPC supports -Mmacpas but it may be that not all dependencies can be resolved against anything other than a Macintosh OS. As I understand the first Windows version was written in mspascal/quickpascal which is TP compatible (including bugs!). That would be 16 bit Windows.....
I blew up my Macintosh more than 10 years ago..... Can't test.
« Last Edit: April 24, 2018, 12:46:49 pm by Thaddy »
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

tr_escape

  • Sr. Member
  • ****
  • Posts: 340
  • sector name toys | respect to spectre
    • Github:
Re: Compile Photoshop Pascal Code
« Reply #4 on: April 24, 2018, 01:42:38 pm »
I looked up some files of project it has got assembly parts (example: USeparation.a).

It is not easy to convert...


Ok they only compiled parts :) but it isn't easy to convert
« Last Edit: April 24, 2018, 01:44:59 pm by tr_escape »

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6510
Re: Compile Photoshop Pascal Code
« Reply #5 on: April 24, 2018, 02:19:13 pm »
Note also that in old Apple Object Pascal (and mode macpas), the object()  syntax is reference based like Delphi class, and thus NOT equal to Turbo Pascal static object() syntax.

Leledumbo

  • Hero Member
  • *****
  • Posts: 7953
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Compile Photoshop Pascal Code
« Reply #6 on: April 24, 2018, 04:29:51 pm »
1. What is advantage of using "Object" rather than "Class"
I'm answering from TP/FPC POV, not MacPas. Object is allocated on the stack, class is always on the heap. Object will be freed automatically when the function goes out of scope, class requires either garbage collection or explicit deallocation.
2. What is difference between "Object" and "TObject" ?
Object is a reserved word, it's mean to signify that a type is... well... an object. TObject is the root class (or object) of all other defined classes / objects.
3. Was there OOP implementation in the day Photoshop 1.0 being written ?
No idea, but the first Object Pascal proposal is from 1982, while Photoshop 1.0 was born in 1990. Note that the proposal was never finalized, so it's unknown whether there's a compiler implemeting it that day.
3.b) if it was, why they were using Object instead of Class ?
No idea again, you might want to just read the proposal: http://www.pascal-central.com/OOE-stds.html
4. How can we compile the source code (using cross-compile or whatever) ?
Answered above, in short: it's hard to find the dependencies.
5. What the compiler they use to build/compile ?
MacPas compiler of that day for sure.
6. Am I right: I think the fpc is not available yet in that day?
No, FPC was first started in 1992, when Borland said there will be no TP 8. First public release I believe it was around 1998. Florian should be able to confirm, my first encounter with FPC was at version 1.0.2 around 2000.

x2nie

  • Sr. Member
  • ****
  • Posts: 478
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
Re: Compile Photoshop Pascal Code
« Reply #7 on: April 25, 2018, 07:40:18 am »

Thanks you every body. Your answers enlighten me so much.

Read more: http://wiki.freepascal.org/TObject
then this too: http://wiki.freepascal.org/Object


1. What is advantage of using "Object" rather than "Class"
I'm answering from TP/FPC POV, not MacPas. Object is allocated on the stack, class is always on the heap. Object will be freed automatically when the function goes out of scope, class requires either garbage collection or explicit deallocation.
5. What the compiler they use to build/compile ?
MacPas compiler of that day for sure.
MacPas, I found nothing about it except that in fpc there is compiler-compatible-mod {$mode macpas}.
http://wiki.freepascal.org/Mode_MacPas
There is said: "Mode MacPas tries to be compatible with the Pascal dialects commonly used on Macintosh, that is THINK Pascal, Metrowerks Pascal and MPW Pascal. For tips on porting from traditional Mac Pascal compiler to Free Pascal, see Porting from Mac Pascal"
So, I think youre talking about any of compiler for mac. Never mind.


Thanks you every body, its enough and is satisfied my curiosity. In fact, the answers are beyond it  :o 8-)
When you were logged in, you can see attachments.
Lazarus Trunk @ Windows7 64bit, XP 32bit, Debian under VirtualMachine

Thaddy

  • Hero Member
  • *****
  • Posts: 6756
Re: Compile Photoshop Pascal Code
« Reply #8 on: April 25, 2018, 12:03:45 pm »
AFAIk macpas mode ==~ Think pascal. Not the other ones.
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

VTwin

  • Sr. Member
  • ****
  • Posts: 448
  • Former Turbo Pascal 3 user
Re: Compile Photoshop Pascal Code
« Reply #9 on: June 24, 2018, 07:47:35 pm »
1. What is advantage of using "Object" rather than "Class"
3.b) if it was, why they were using Object instead of Class ?

I believe the use of Object instead of Class reflects the style of that time. Objects can be declared with fields and methods, similar to Classes, but have no constructors or destructors, and are not allocated. They were phased out (deprecated).

Code: Pascal  [Select]
  1. type
  2.   TAnObject = object (TAnAncestorObject)
  3.     AName: string
  4.     function AFunction: integer;
  5.   end;
  6.  

From Delphi docs:

Quote
Object types are supported for backward compatibility only. Their use is not recommended.

http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Classes_and_Objects_(Delphi)
[Link is not working, copy and Google if interested.]

Interestingly we now have "advanced" records, which are very much like objects, but without inheritance.

https://forum.lazarus.freepascal.org/index.php?topic=30686.0

Happy coding,
VTwin
« Last Edit: June 24, 2018, 08:33:32 pm by VTwin »
“Talk is cheap. Show me the code.” Linus Torvalds

Lazarus 1.8.4, FPC 3.0.4
macOS 10.11.5 (32 bit Carbon, working on Cocoa) 
Windows 7 (64 bit)
Ubuntu 16.04.3 (64 bit)

ASerge

  • Hero Member
  • *****
  • Posts: 907
Re: Compile Photoshop Pascal Code
« Reply #10 on: June 24, 2018, 08:03:44 pm »
Objects can be declared with fields and methods, similar to Classes, but have no constructors or destructors, and are not allocated.
Сarried away by belittling the capabilities of the object type? They can have a constructor and a destructor.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6510
Re: Compile Photoshop Pascal Code
« Reply #11 on: June 24, 2018, 08:10:32 pm »
From Delphi docs:

Useless since Mac Pascal "object" is not necessary to object in other modes (including TP/Delphi), as the following program demonstrates:

Code: Pascal  [Select]
  1.  
  2. {$mode macpas}
  3.  
  4. type TSomething = object
  5.                     l1,l2,l3: integer;
  6.  
  7.                        end;
  8.  
  9. var x : TSomething;
  10.  
  11. begin
  12.  writeln(sizeof(x));   // In mode macpas prints 4 on 32-bits systems, a reference!  Change to mode Delphi and see the value change to 12
  13. end.
  14.  

VTwin

  • Sr. Member
  • ****
  • Posts: 448
  • Former Turbo Pascal 3 user
Re: Compile Photoshop Pascal Code
« Reply #12 on: June 24, 2018, 08:17:51 pm »
Objects can be declared with fields and methods, similar to Classes, but have no constructors or destructors, and are not allocated.
Сarried away by belittling the capabilities of the object type? They can have a constructor and a destructor.

Sorry, I did not mean to belittle them. I was disappointed to learn that Delphi "broke" them. I use advanced records a lot, and would prefer to use objects. I was using objects, but moved to advanced records. Thank you for pointing out my error, perhaps I should start using them again. Do many here folks still use objects?
“Talk is cheap. Show me the code.” Linus Torvalds

Lazarus 1.8.4, FPC 3.0.4
macOS 10.11.5 (32 bit Carbon, working on Cocoa) 
Windows 7 (64 bit)
Ubuntu 16.04.3 (64 bit)

VTwin

  • Sr. Member
  • ****
  • Posts: 448
  • Former Turbo Pascal 3 user
Re: Compile Photoshop Pascal Code
« Reply #13 on: June 24, 2018, 08:23:43 pm »
Useless since Mac Pascal "object" is not necessary to object in other modes (including TP/Delphi), as the following program demonstrates:

Interesting. It seems that what they are depends on the mode. That makes me nervous. Should I not use them then?
« Last Edit: June 24, 2018, 08:25:14 pm by VTwin »
“Talk is cheap. Show me the code.” Linus Torvalds

Lazarus 1.8.4, FPC 3.0.4
macOS 10.11.5 (32 bit Carbon, working on Cocoa) 
Windows 7 (64 bit)
Ubuntu 16.04.3 (64 bit)

VTwin

  • Sr. Member
  • ****
  • Posts: 448
  • Former Turbo Pascal 3 user
Re: Compile Photoshop Pascal Code
« Reply #14 on: June 24, 2018, 08:52:00 pm »
To clarify my question, I do not like the fact that advanced records do not have constructors. This makes me write code like this:

Code: Pascal  [Select]
  1. type
  2.   TMyRecord = record
  3.     MaxAllowed: integer;
  4.     MinAllowed: integer;
  5.     procedure Init;
  6.   end;
  7.  
  8. procedure TMyRecord.Init;
  9. begin
  10.   MaxAllowed := 100;
  11.   MinAllowed := 0;
  12. end
  13.  
  14. var
  15.   r : TMyRecord;
  16. begin
  17.   r.Init;
  18. end.
  19.  
  20.  

I would prefer to use a constructor. Having learned that Delphi "broke" them, I have stayed away from objects. I am curious as to what other folks do.
“Talk is cheap. Show me the code.” Linus Torvalds

Lazarus 1.8.4, FPC 3.0.4
macOS 10.11.5 (32 bit Carbon, working on Cocoa) 
Windows 7 (64 bit)
Ubuntu 16.04.3 (64 bit)

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus