Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Dranix

macrumors 65816
Original poster
Feb 26, 2011
1,063
543
left the forum
I'm wondering a little, ok much, why we have so many Applescript threads here. After all the section is titled "Mac programming" not "mac scripting" or "automatisation".
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
Because there's not a separate scripting forum. I think it's been floated to break it out before. Honestly, Mac programming questions are getting fairly rare. iOS is way more popular, and that does have its own forum.

-Lee
 

superscape

macrumors 6502a
Feb 12, 2008
937
223
East Riding of Yorkshire, UK
I guess what constitutes 'scripting' and what constitutes 'programming' varies according to who you talk to and I expect we could discuss it all day and never quite agree.

I think the distinction is especially blurry with AppleScript, especially with the advent of AppleScriptObjC which means you *can* create full blown Mac OS X apps using all the Cocoa frameworks available to Objective-C programmers. And, of course, its possible to include AppleScript in your Objective-C if you so wish. I appreciate that AppleScript does some things that make seasoned programmers gasp with horror, but the fact remains.

I guess you could argue about whether 'vanilla' AppleScript is programming or scripting (personally, I don't see much need for the distinction) but I think AppleScriptObjC most certainly constitutes programming.

Personally, I'd suggest that if you're writing code to create an executable program then you're programming, irrespective of the language you're using.
 

Ainze

macrumors regular
Feb 28, 2010
121
8
I've prototyped entire applications and games in Applescript before. No scripting or automation, just self-contained fully functional apps. Definitely counts as programming. And I also agree that there's not much distinction. Where exactly would you draw the line? Especially as some of the most worthwhile scripts I've ever written or used have had complex logic to rival any standalone program.

I think that superscape hit it on the head - the language doesn't matter. You can write a script in C and an app in Shell Script. Programming is about the mindset; problem solving through logic, where language is just a tool we use.
 

Dranix

macrumors 65816
Original poster
Feb 26, 2011
1,063
543
left the forum
Hmm so people really like AppleScript? My wondering comes because I despise AppleScript - It has a so hideously bad designed syntax it makes me sick by only looking at it.
 

superscape

macrumors 6502a
Feb 12, 2008
937
223
East Riding of Yorkshire, UK
Hah hah! ;-) Yes, I know what you mean. AppleScript's 'quirky' to say the least. But in its defence it's easy to learn and very English-like which again often helps (although occasionally hinders) the learning process.

Personally, I started coding in AppleScript many years ago and graduated on to things like PHP, Objective-C, shell scripting, JavaScript etc later. AppleScript's readability made learning it less daunting and got my confidence up to go on to learn the other languages. Without AppleScript I'd probably have concluded that programming is impenetrable and incomprehensible and given up.

Sure, AppleScript has many faults and we could spend a long time detailing and discussing them, but it certainly has its place and can be very useful in certain situations.
 

Dranix

macrumors 65816
Original poster
Feb 26, 2011
1,063
543
left the forum
So would you say it'S bad style to NOT support AppleScript in own applications? I plan to provide scripting but in Python, Javascript or Lua (whatever gets easier to embed).
 

superscape

macrumors 6502a
Feb 12, 2008
937
223
East Riding of Yorkshire, UK
So would you say it'S bad style to NOT support AppleScript in own applications? I plan to provide scripting but in Python, Javascript or Lua (whatever gets easier to embed).

It depends.

I work in the design/graphics industry and whether or not an application is AppleScriptable is a one of the factors in deciding whether or not to purchase a particular software. Most design studios seem to have *someone* who is reasonable at AppleScript (less likely Python, Lua etc) and a lot of our work is time consuming and repetitive so automation is important. I can't comment on other industries.

I guess that if you're developing an app and considering adding scripting support then you need to a bit of research amongst your potential user base and see what they're most comfortable with.
 

Dweez

macrumors 65816
Jun 13, 2011
1,248
10
Down by the river
Of course it's programming, simply a different language. I know this is simplistic, but it makes the point.

Code:
mini:~\> cat foo.c

#include "stdio.h"
int main() {
        int counter = 0;
        while ( counter <= 9 ) {
                printf( "Hello world - %i\n", counter );
                counter++;
        }

}

mini:~\> cat foo.sh

#! /bin/sh
counter=0
while [ $counter -le 9 ]
do
        echo "Hello world - $counter"
        counter=`expr $counter + 1`
done

mini:~\> cc foo.c -o foo

mini:~\> ./foo
Hello world - 0
Hello world - 1
Hello world - 2
Hello world - 3
Hello world - 4
Hello world - 5
Hello world - 6
Hello world - 7
Hello world - 8
Hello world - 9

mini:~\> chmod 700 foo.sh

mini:~\> ./foo.sh
Hello world - 0
Hello world - 1
Hello world - 2
Hello world - 3
Hello world - 4
Hello world - 5
Hello world - 6
Hello world - 7
Hello world - 8
Hello world - 9
 

superscape

macrumors 6502a
Feb 12, 2008
937
223
East Riding of Yorkshire, UK
Well I consider scripting is to programming what doodling is to drawing. Mostly it's bad throw away code.

Well, I guess the quality of code depends on the programmer just as the quality of the doodle depends on the doodler*. It's rarely the language's fault.

There are well-crafted AppleScripts and badly-crafted AppleScripts just as there are good and bad apps written in Objective-C, Python, C++ or whatever language you choose. Don't blame the language for bad code, blame the programmer! ;-)
 

Ainze

macrumors regular
Feb 28, 2010
121
8
Well I consider scripting is to programming what doodling is to drawing. Mostly it's bad throw away code.

Then your scripts are badly written or not serving a useful purpose. But I agree with your analogy to a degree. How does one compare a haiku to Shakespearean play? Or a Dilbert strip to the Mona Lisa? Or a Pixar short to the Extended Cut of The Lord of the Rings? Quantitatively there's a massive difference, no doubt. But qualitatively? It's harder to analyse, and each works in a different way and for different purposes. Scripts may be akin to doodles in terms of size and depth, but that doesn't mean that they lack elegance or thought. And I think we can all recall times when some scripts (or doodles) were far superior to some programs (or drawings).

And back to topic, it still doesn't affect what language one might use. Applescript, like any language worth your time, can be used to write either, just as your pencil or paintbrush can be used for both doodles and drawings. The trick is to use the tool that best suits your current need.

EDIT: So, what superscape said - got in there just before me!
 

Dranix

macrumors 65816
Original poster
Feb 26, 2011
1,063
543
left the forum
That's not what I meant. Scripting code normally is just a solution for a simple task. Error handling, general usability and good design of the code is seldom.
 

Dweez

macrumors 65816
Jun 13, 2011
1,248
10
Down by the river
That's not what I meant. Scripting code normally is just a solution for a simple task. Error handling, general usability and good design of the code is seldom.

IMNSHO, that again is dependant upon the programmer, not the language.

My coding career started with bourne and c shells, then c, c++, perl and ended up back in shell.

Throw in some assembler, fortran and cobol somewhere in the above as well.
 

Dranix

macrumors 65816
Original poster
Feb 26, 2011
1,063
543
left the forum
So you write scripts really with full error handling and general usability instead of simple throwing together the code barely needed for the automation wanted?
 

Ainze

macrumors regular
Feb 28, 2010
121
8
That's not what I meant. Scripting code normally is just a solution for a simple task. Error handling, general usability and good design of the code is seldom.

Coder's choice. It's not inherent. A good programmer will employ all of those features (if appropriate to the task at hand).
 

subsonix

macrumors 68040
Feb 2, 2008
3,551
79
I consider scripting (especially shell) mostly a glue for other applications. Of course there are exceptions and it's true to a varying degree, but there's some truth to it. Applescript is another example of what I consider mostly a "glue" language. An application can provide a scripting interface with the scripting bridge, this enables automation and cooperation with this application with scripts. Although it may be possible to create a useful application in Applescript with a purpose that is not automation from scratch, it would be a bit of an odd choice in my opinion.
 

Dranix

macrumors 65816
Original poster
Feb 26, 2011
1,063
543
left the forum
Coder's choice. It's not inherent. A good programmer will employ all of those features (if appropriate to the task at hand).

For scripts? I still have to see a single script in my life that would at least contain useful error handling.
 
Last edited:

Ainze

macrumors regular
Feb 28, 2010
121
8
For scripts? I still have to see a single script in my life that would at least contain useful error handling.

Mine do. Would be stupid not to. You're right - a script often handles a simple sequence of repetitive tasks, so when I use one, I'm often executing it quickly and with very little attention to what I'm really doing. Mistakes are frequent. Very frequent. And don't get me started on people using my scripts who aren't me! If I take enough care when writing the script, it will save me much more time later in damage control. And yes, that usually makes them 2, 3, 4, or however-many times larger by the end than when they started. But then they do the job, and well.

Which is kind of the point to begin with…
 

Weaselboy

Moderator
Staff member
Jan 23, 2005
34,137
15,602
California
I'm wondering a little, ok much, why we have so many Applescript threads here. After all the section is titled "Mac programming" not "mac scripting" or "automatisation".

I guess I could see your point if this was a high traffic forum and the AS questions were cluttering things up, but just looking over the last couple days posts it appears if it were not for the AS questions it would not be much of a forum at all.
 
Last edited:

Red Menace

macrumors 6502a
May 29, 2011
578
226
Colorado, USA
Well I consider scripting is to programming what doodling is to drawing.
AppleScript tends to make you jump through all kinds of hoops and perform all manner of gyrations to get much of anything done, so some of those doodles wind up turning into genuine works of art. And then there is that infinite number of monkeys thing...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.