PDA

View Full Version : Languages to program on mac, and applescript?




vim-espresso
Jul 14, 2012, 05:25 PM
I am new to mac. I can code in a lot of languages for windows and linux, but personally I feel rather young again using mac, naive. It has made computing fun again. I am making a list of things I want to learn for fun, first I want to get a list of programming languages to choose from so that I can have a selection of tools for my fun.

Now to the questions:

Is AppleScript still widely used and do your experiences teach that it is a good tool to learn, or is bash scripting better?
What programming languages for mac are commonly used other than objective-c? (Objective-C already top of list to work towards competence in).


I thank you for reading, and am grateful for any replies.



chown33
Jul 15, 2012, 01:52 PM
What do you want to do with the language?

Woodworkers use many tools: saw, hammer, chisel, etc. No one tool is better than the other, except at a certain task. You could cut boards in half with a hammer and chisel, but that would be tedious and silly.

A language is a tool. Pick a language to match the task. If you don't have a task in mind, it's hard to pick a language, so any will do. Just don't be surprised if some tasks are difficult.

Yes, AppleScript is used. So is bash scripting. And each one can run scripts written in the other. The command to run AppleScripts is 'osascript'. The AppleScript command is "do shell script".

For processing text, the awk language is a good choice. Often neglected and underused, it takes some getting used to. But after you've struggled with the turgid prolixity of AppleScript for what ought to be simple text processing tasks, awk's concision is refreshing.

All the shell commands have man pages, even the shell itself. Read them. An easy way to do that is Bwana (http://www.bruji.com/bwana/), which opens man pages in your browser.

GorillaPaws
Jul 15, 2012, 09:08 PM
Another interesting language/tool is the Cappuccino Framework (http://cappuccino.org/) which uses the Objective-J language (a mashup of Objective-C and Java Script) to write web apps that have a very OS X-like feel to them. I would wait until after learning Objective-C and the Cocoa frameworks before messing with it, but it's a neat technology.

There's also F-Script (http://www.fscript.org/) which is a neat tool for introspecting objects at runtime.

Then there are hybrid languages like MacRuby (http://macruby.org) which let's you use Ruby to create Cocoa Apps, and PyObjC (https://developer.apple.com/cocoa/pyobjc.html) which is a bridge that allows you to develop Cocoa apps in Python. As I understand it, both of these require solid understanding of Cocoa and Objective-C in order to be useful, and can be a bit tricky to debug, but if you're looking for interesting languages, these might be ones to check out as well.

elvisofdallas
Jul 28, 2012, 09:32 AM
Hey - thanks for the info. I'm an old school programmer (primarily using SQL for my RL job), but I've been slowly relearning traditional programming skills and weaving in the Mac-specific stuff.

AppleScript turns out to be insanely powerful (seems so simple, like the old Logo language that was popularly discussed in the early 80s), but I'm now ankle deep in python, as it seems to be a great tool for automation tasks, especially those that would pull data from the internet.

Thanks again for the great post - I forget how helpful the people on MacRumors are!!

E:)

---> edit: question, of those of you with experience in the popular scripting languages (perl, python, even PHP), do you have a preference for rapid coding of things like screen scrapers or data aggregators?

Thanks in advance - E

Cromulent
Jul 30, 2012, 04:32 AM
but I'm now ankle deep in python, as it seems to be a great tool for automation tasks, especially those that would pull data from the internet.

Python is indeed a great tool. I use it instead of shell scripting, for web sites, database management and general system tasks.

---> edit: question, of those of you with experience in the popular scripting languages (perl, python, even PHP), do you have a preference for rapid coding of things like screen scrapers or data aggregators?

Thanks in advance - E

My scripting language experience is mainly Python but I have used PHP in the past. The one thing I will say is stay as far away as possible from PHP as you can. It is an awful language.

Python is an excellent choice for screen scraping and data aggregators. Especially scraping websites as you can use html5lib to parse the page and then just treat it like a DOM. If you want to aggregate some data you can use the built in SQLite database API (it is in the standard library) to store your data in an in memory SQL database (or you can save the database to disk if you want the data to be persistent). This allows you all the flexibility of being able to use SQL to query your data. Of course if you want to use a "proper" SQL database you can also use PostgreSQL, MySQL or one of the other commercial databases with Python just fine as well.

You might find SQLAlchemy useful if you are planning on working with databases alot. Here is the link:

http://www.sqlalchemy.org/