Compile Photoshop Pascal Code lazarus / 62-General ---------------------------------------------------------------------- x2nie · 2018-04-24 09:22 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 ---------------------------------------------------------------------- Handoko · 2018-04-24 10:04 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. ---------------------------------------------------------------------- RayoGlauco · 2018-04-24 10:39 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/Entrie s/2013/3/30_Building_Photoshop.html ---------------------------------------------------------------------- Thaddy · 2018-04-24 10:43 Quote from: RayoGlauco on April 24, 2018, 12:39:11 pmI 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/Entrie s/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. ---------------------------------------------------------------------- tr_escape · 2018-04-24 11:42 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 ---------------------------------------------------------------------- marcov · 2018-04-24 12:19 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 · 2018-04-24 14:29 Quote from: x2nie on April 24, 2018, 11:22:24 am1. 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. Quote from: x2nie on April 24, 2018, 11:22:24 am2. 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. Quote from: x2nie on April 24, 2018, 11:22:24 am3. 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. Quote from: x2nie on April 24, 2018, 11:22:24 am3.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 Quote from: x2nie on April 24, 2018, 11:22:24 am4. How can we compile the source code (using cross-compile or whatever) ? Answered above, in short: it's hard to find the dependencies. Quote from: x2nie on April 24, 2018, 11:22:24 am5. What the compiler they use to build/compile ? MacPas compiler of that day for sure. Quote from: x2nie on April 24, 2018, 11:22:24 am6. 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 · 2018-04-25 05:40 Thanks you every body. Your answers enlighten me so much. Quote from: Handoko on April 24, 2018, 12:04:01 pmRead more: http://wiki.freepascal.org/TObject then this too: http://wiki.freepascal.org/Object Quote from: Leledumbo on April 24, 2018, 04:29:51 pmQuote from: x2nie on April 24, 2018, 11:22:24 am1. 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. Quote from: x2nie on April 24, 2018, 11:22:24 am5. 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 ---------------------------------------------------------------------- Thaddy · 2018-04-25 10:03 AFAIk macpas mode ==~ Think pascal. Not the other ones. ---------------------------------------------------------------------- VTwin · 2018-06-24 17:47 Quote from: x2nie on April 24, 2018, 11:22:24 am1. 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type   TAnObject = object (TAnAncestorObject)    AName: string    function AFunction: integer;  end;  From Delphi docs: QuoteObject 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 ---------------------------------------------------------------------- ASerge · 2018-06-24 18:03 Quote from: VTwin on June 24, 2018, 07:47:35 pmObjects 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 · 2018-06-24 18:10 Quote from: VTwin on June 24, 2018, 07:47:35 pmFrom 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  {$mode macpas} type TSomething = object                    l1,l2,l3: integer;                        end; var x : TSomething; begin writeln(sizeof(x));   // In mode macpas prints 4 on 32-bits systems, a reference!  Change to mode Delphi and see the value change to 12end. ---------------------------------------------------------------------- VTwin · 2018-06-24 18:17 Quote from: ASerge on June 24, 2018, 08:03:44 pmQuote from: VTwin on June 24, 2018, 07:47:35 pmObjects 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? ---------------------------------------------------------------------- VTwin · 2018-06-24 18:23 Quote from: marcov on June 24, 2018, 08:10:32 pmUseless 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? ---------------------------------------------------------------------- VTwin · 2018-06-24 18:52 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type   TMyRecord = record    MaxAllowed: integer;    MinAllowed: integer;    procedure Init;  end; procedure TMyRecord.Init;begin  MaxAllowed := 100;  MinAllowed := 0;end var   r : TMyRecord;begin  r.Init;end.   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. ---------------------------------------------------------------------- ASerge · 2018-06-24 19:30 Compare advanced records and objects: 1. Advanced records support type helper (static polymorphism). 2. Objects support virtual function (dynamic polymorphism) and inheritance (static polymorphism). All other properties are the same. ---------------------------------------------------------------------- Nitorami · 2018-06-24 19:51 Why would you need a constructor ? It is only required to build the VMT which is necessary for inheritance & virtual methods which advanced records don't support. Objects are really like Classes, except they are static and need not be allocated, hence it is not necessary to "create" them. Only if you are using inheritance, then you need a constructor. That is my understanding. I don't know about type helpers. I had started my own program based on objects, but came to a point where things went wrong. I don't know whether "Delphi broke objects", but have the feeling the developers neglected them, once Classes had been implemented. So I changed to Classes, but still use simple objects to capsule simple data and methods. But I don't use constructors / inheritance on objects anymore, neither properties... I remember they seemed to be buggy. The advantage of objects is that access to their fields may be a little bit faster than for Classes, although that only matters in tight loops. ---------------------------------------------------------------------- VTwin · 2018-06-24 21:34 Thanks guys, I appreciate the responses. A few years ago I started writing a vector library using TVector and TMatrix objects (I write scientific software at a university). At some point I encountered some unexpected behavior. I inquired here, and learned that objects were deprecated, or at least not maintained. It sounds like you (Nitorami)  may have encountered the same issue. Despite the error in my earlier post, I was using object constructors, which I forgot. (I have long since rewritten the library using dynamic arrays and operator overloading). I do use advanced records extensively, often to set and get options for a complex procedure which are logically grouped together. These are typically set in a dialog box, and then saved to a preferences dictionary in memory, which can be written to a file and reloaded when the program is restarted. Each such record must have default values, which I set in an Init method. It is not such a big deal, but it would be nice to have a constructor to do that automatically.  So at least one other person has had issues, at least with object constructors or inheritance. I suppose I could use objects and not use constructors or inheritance, but advanced records seem to work well.