"at a impasse. Yep" -- Really?
Brian, like you I find ASOC moderately annoying, for the reasons that you, I, and Shane have already enumerated. Over two years ago I wrote my first and only ASOC app that got info from iTunes for the currently playing track and then went out to several lyrics web sites, parsed out the lyrics content, presented it on the app's UI, and let the user (me) pick the best lyrics and save that to the iTunes lyrics metadata for the track. At that time, I had over 30 years of programming experience spanning from Fortran punch cards through C, C++, Java, .NET, and a twist of Objective-C. I got my app working, lost some hair in the process, and then decided to rewrite it in straight Objective C, and have never regretted the switch.
That said, the two lines of code I provided to you still took considerable research and trial-and-error for me. I basically hit almost every bullet point on Shane's well thought-out suggestion list. Those suggestions are very close to how I approach any programming task, including the one that I consider MOST useful: step away the the complex problem you're trying to solve and write the simplest program possible to explore the (much smaller) problem you're currently trying to solve. In this case, that program contained about 10 lines of code, but provided the playground where I could quickly try out syntax and observe the results in XCode's console area.
I could document the steps I used to convert the two lines of objc code you supplied into the two lines of asoc code I provided, but I think you can see how the syntax works now. It's pretty straight-forward literal translation task, as long as you know these things:
- the containment hierarchy of the UI your code in trundling through
- the class of every view in that hierarchy, including its class methods, instance methods, and properties
- the type of the properties of each class, which can be other objc classes or c-type structs, like NSRect and NSPoint, as in this example
With all that under your belt, you then need to have a grasp of the impedance mismatch between objc, AppleScript, and ASOC, including
- weird syntax for method calling, paren's with apostrophes, etc.
- weird quoting of AS keywords that conflict with objc method or property names
- lack of compiler and debugger support, obtuse output in the console, etc.
I'm sure Shane's book helps in much of this, but I'm too cheap to buy it, so there we are.
Shane, I get the sense that you agree with much of this, and that's why you wrote a book to help people out. I also sense that you subscribe to the philosophy that its better to teach a man to fish than to give him a fish. While I mostly agree, I find that sometimes its best to just give the man the damn fish rather than trying to hint, cajole, and berate the poor guy for not knowing how to put a worm on a hook. Having tasted a nice chunk of smoked salmon, the future fisherman may be more motivated to continue angling on his own. (I could carry this analogy on for hours, but I'll stop here.) I'll finish by saying I think you could move forward (from the impasse) by providing more concrete guidance to people that are having trouble. Snippets that are too short to comprehend and near-caustic remarks add little value to the discussion. Other longer notes by you have been enlightening and valuable to all, in my opinion.
I noted that all three of us are published authors. Let's use our communication skills to help each other out in the most effective, thoughtful, and respectful manner we can. Interactions like this just might be fodder for our next article or book, eh?
OK, break time is over. Back to work, everyone!
• Ron
On 3 Oct 2014, at 3:44 AM, Shane Stanley <email@hidden> wrote:
For the record, I pointed you to concrete examples of dealing with NSRects in AppleScript in my book here over a week ago. I'm not really sure why you ignored them, but that was your choice, not mine.
I think we're at an impasse on this.
Yep.