I think we are experiencing slight differences in definitions. DJ Bazzie Wazzie, wants to directly extend AppleScripts string object so he can make it do something the original engineers did not create. Since this is not possible, DJ Bazzie Wazzie asserts AppleScript does not support subtype polymorphism and therefore is not an OOP language.
Of course, that is not entirely correct. AS does have subtype polymorphism – as McUsr and myself have demonstrated. However, AppleScript does not allow subtype polymorphism for it’s own objects. That much is true. DJ Bazzi Wazzie leaves the conversation implying we are stuck.
However, we’re not stuck. We have the freedom of creating our own object which inherits from string and creating whatever methods we desire. In fact, I created RJArray which adds methods I wished were present in AppleScripts list object.
But all of this talk about what OOP is (or isn’t) and what features we are missing (or not) has obscured the original point - practically erasing it from memory.
Why OOP? Why does this type of language exist in the first place? What are the advantages?
Code reusability. That’s it. It’s all it does.
It’s fair to say www.robotjackalope.com - Pirates v Ninjas has a target audience in mind for AppleScripters who do not use (or do not understand) OOP concepts and to encourage that audience to look into it – for the sole purpose of code reusability.
If you are an AppleScripter working on large projects, frequently digging into old projects where you solved problem X and copying and pasting into new projects, then AppleScript OOP is made for you. If that doesn’t describe you, don’t OOP. You have no need for OOP. In fact, you probably shouldn’t be looking at this post at all! Leave now and look at pictures of cute kittens! The internet is filled with pictures of cute kittens! However, if you’re still here and not looking at pictures of cute kittens, I happen to think OOP with AppleScript is pretty aweseome.
In the Princess Bride (1987), Wesley answers Prince Humperdincks challenge of a duel to the death with a classic line. “No. To the pain!”. Wesley goes on to describe exactly what he means by this which convinces Prince Humperdinck to drop his sword and surrender.
This line neatly summarizes the battle between procedural and object-oriented programming. When the pain of procedural outweighs the pain of writing OOP, procedural drops it’s sword and surrenders. Despite all the hemming and hawing on AppleScript OOP we’ve had, the OOP features AppleScript does have is more than good enough for the vast majority of AppleScript projects. If they’re not, AppleScript probably isn’t the right language for the task - and that brings us to the real reason for the www.robotjackalope.com - Pirates v Ninjas post.
I wrote this post because if somebody else had written it 15/20 years ago, I believe I could have moved into Java much quicker. I could have written Objective-C much sooner. I could have been a contender!!
My first and longest experience with programming is AppleScript, a language I love to this day. I believe the AppleScript engineers were building the programming language equivalent of Marijuana - The starter drug that will lead you down the road of shooting up the heroin of Objective-C, or Java, or Ruby or whatever…
In some ways, this post is a farewell love letter to AppleScript. It’s my way of sending a message to myself through time, hoping a younger version of me will receive this message in a bottle. I do this because AppleScript is the greatest programming language ever created that nobody was ever willing to pay for.
So, there you have it. AppleScript as OOP. And, you even have a classy class-loader and a dozen or so examples, all there at www.robotjackalope.com. If the ideas take off, I’ll happily help and manage the project on github. Let’s see where it goes!
Great thread everybody. Thanks for weighing in. Your comments were greatly valued!