Why so much Applescript?

Discussion in 'Mac Programming' started by Dranix, Apr 23, 2014.

  1. Dranix macrumors 6502a

    Dranix

    Joined:
    Feb 26, 2011
    Location:
    Gelnhausen, Germany
    #1
    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".
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    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
     
  3. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #3
    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.
     
  4. Ainze macrumors regular

    Ainze

    Joined:
    Feb 28, 2010
    #4
    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.
     
  5. Dranix thread starter macrumors 6502a

    Dranix

    Joined:
    Feb 26, 2011
    Location:
    Gelnhausen, Germany
    #5
    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.
     
  6. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #6
    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.
     
  7. Dranix thread starter macrumors 6502a

    Dranix

    Joined:
    Feb 26, 2011
    Location:
    Gelnhausen, Germany
    #7
    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).
     
  8. Dweez macrumors 65816

    Dweez

    Joined:
    Jun 13, 2011
    Location:
    Down by the river
  9. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #9
    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.
     
  10. hiddenmarkov macrumors 6502a

    Joined:
    Mar 12, 2014
    Location:
    Japan
    #10
    Basically.


    A logical series of instructions designed to accomplish tasks.


    Can argue syntax and features all day long but as we all know this is a highly subjective area.
     
  11. Dranix thread starter macrumors 6502a

    Dranix

    Joined:
    Feb 26, 2011
    Location:
    Gelnhausen, Germany
    #11
    Well I consider scripting is to programming what doodling is to drawing. Mostly it's bad throw away code.
     
  12. Dweez macrumors 65816

    Dweez

    Joined:
    Jun 13, 2011
    Location:
    Down by the river
    #12
    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
    
    
     
  13. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #13
    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! ;-)
     
  14. Ainze macrumors regular

    Ainze

    Joined:
    Feb 28, 2010
    #14
    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!
     
  15. Dranix thread starter macrumors 6502a

    Dranix

    Joined:
    Feb 26, 2011
    Location:
    Gelnhausen, Germany
    #15
    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.
     
  16. Dweez macrumors 65816

    Dweez

    Joined:
    Jun 13, 2011
    Location:
    Down by the river
    #16
    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.
     
  17. Dranix thread starter macrumors 6502a

    Dranix

    Joined:
    Feb 26, 2011
    Location:
    Gelnhausen, Germany
    #17
    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?
     
  18. Ainze macrumors regular

    Ainze

    Joined:
    Feb 28, 2010
    #18
    Coder's choice. It's not inherent. A good programmer will employ all of those features (if appropriate to the task at hand).
     
  19. subsonix macrumors 68040

    Joined:
    Feb 2, 2008
    #19
    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.
     
  20. Dranix, Apr 24, 2014
    Last edited: Apr 24, 2014

    Dranix thread starter macrumors 6502a

    Dranix

    Joined:
    Feb 26, 2011
    Location:
    Gelnhausen, Germany
    #20
    For scripts? I still have to see a single script in my life that would at least contain useful error handling.
     
  21. Dweez macrumors 65816

    Dweez

    Joined:
    Jun 13, 2011
    Location:
    Down by the river
    #21
    Yes, that was my job.
     
  22. Ainze macrumors regular

    Ainze

    Joined:
    Feb 28, 2010
    #22
    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…
     
  23. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #23
    Quite agree, although it is possible.
     
  24. Weaselboy, Apr 24, 2014
    Last edited: Apr 25, 2014

    Weaselboy Moderator

    Weaselboy

    Staff Member

    Joined:
    Jan 23, 2005
    Location:
    California
    #24
    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.
     
  25. Red Menace macrumors 6502

    Joined:
    May 29, 2011
    Location:
    Littleton, Colorado, USA
    #25
    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...
     

Share This Page