Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread Display Modes
Old Aug 7, 2007, 02:13 PM   #1
macrumors 68000
Soulstorm's Avatar
Join Date: Feb 2005
Learning Python on OS X

Learning programming, I stumbled upon some problems I have.

I am fairly proficient with C++, and Objective C with Cocoa, and I have developed programs that many people use with Cocoa. But lately, I had the idea of writing my own parser in C++ (I think that for this task I should avoid Objective C).

However, I found that C++ can be very frustrating when writing a parser, even a recursive descent one. So, I decided to learn another language.

So, what I want is a language that can be used in conduction with C++. I want to be able to write parsers in it, and then use the results with C++. And I want to write it on OS X.

I was thinking of learning Python, but I thought I should ask someone first. Your ideas?
Soulstorm is offline   0 Reply With Quote
Old Aug 7, 2007, 03:54 PM   #2
macrumors regular
Join Date: Jul 2004
Depending on the complexity of the file you want to parse you should pick your language to use. I'll say Perl can help a lot and it's easy to understand since you know C++ and should be easy to integrate with your code. But if you wish to look at something more challenging than Perl take a look at Lex and Yacc.

This last opinion could be a more elegant way to do it, but more complex at the same time. At least what little I remember of using this a couple of years ago. Here is a link to a tutorial, first that showed up after doing a google search. (lex + yacc + c++) You'll probably able to do some wonderful thing with Lex and Yacc, but the learning curve would be higher than using Perl.

Hope someone can do a comparison of this with Python, never used Python before.
--MBP 2.4 GHz 4GB 500GB 7200 RPM Snow Leopard
iBert is offline   0 Reply With Quote
Old Aug 7, 2007, 05:39 PM   #3
macrumors 6502a
Join Date: Dec 2006
Location: Katy, Texas
Send a message via AIM to toddburch Send a message via MSN to toddburch
I seem to remember YACC, and may be LEX too, being geared towards writing compilers, therefore they would be certainly be appropriate from the standpoint of writing a parser.

toddburch is offline   0 Reply With Quote
Old Aug 7, 2007, 06:11 PM   #4
macrumors 601
HiRez's Avatar
Join Date: Jan 2004
Location: Western US
Python is a pretty good choice, as it has very good text/string handling built in, including regular expressions, and it's relatively fast for an interpreted language (most Python modules are available in native Python or written in C for increased speed). It's a great language although it takes a little while to get used to the indented syntax and lack of braces. TextWrangler makes a pretty decent editor for Python because it has syntax highlighting available for it and one of the options is to have it draw lines behind the text at tab stops. This makes it easier to identify your indenting in extended blocks. I picked up a few books on it including a Visual Quickstart one and the O'Reilly Python in a Nutshell. It's a pretty easy language to learn and actually you can learn quite a lot from the documentation. I would recommend getting the Nutshell book as a reference.

EDIT: I said compiled instead of interpreted.
Go outside, the graphics are amazing!

Last edited by HiRez; Aug 7, 2007 at 06:54 PM.
HiRez is offline   0 Reply With Quote
Old Aug 7, 2007, 08:11 PM   #5
macrumors 68000
Join Date: Oct 2003
I wrote a program to parse tcl/tk database in python. Python is great for that stuff, and really easy to understand while being powerful.

I had to laugh at the above comment about perl being "easy to understand", maybe my brain is wrong but I tried to learn perl for months before giving up because its just so odd. Python I picked up in a day and it made me a better programmer.
Me: 1Ghz 12" PB and Mac mini Intel Core Solo 1.5Ghz, The Wife: 1.86Ghz CD MacBook, Me@Work: 2.66Ghz Mac Pro and a 2.33Ghz C2D 15" Mac Book Pro
dr_lha is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Warcraft 3 on OS X Lion? [Help] hackdroid Mac OS X 10.7 Lion 1 Nov 18, 2011 05:59 PM
How do I control my iPod Touch on OS X through USB? (VNC) CamCracker OS X 7 Sep 1, 2011 10:42 PM
Learning Python on a Mac Doju Mac Programming 4 Jul 17, 2010 09:14 AM
Is learning programming on OS X a good idea? Not Available Mac Programming 43 Oct 9, 2009 12:46 PM
Learning Javascript on OS X pjkelnhofer Buying Tips, Advice and Discussion (archive) 14 Jan 30, 2004 10:37 PM

All times are GMT -5. The time now is 02:12 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013,, LLC