New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Learning to write programs


Post Reply New Thread Subscribe

 
Thread Tools
Mr Bobbins

 
Mr Bobbins's Avatar
 
Member Since: Jan 29, 2005
Location: Legoland
Posts: 790
Mr Bobbins has a spectacular aura about

Mr Bobbins is offline
I'd like to have a go at writing a program, I'm not sure what yet, but my question is if any of you have any advice for website information, books, tutorials !!!. :dummy:
QUOTE Thanks
lifeafter2am

 
lifeafter2am's Avatar
 
Member Since: Aug 25, 2006
Location: Central Florida
Posts: 1,395
lifeafter2am is a jewel in the roughlifeafter2am is a jewel in the rough
Mac Specs: MacBook Pro Unibody

lifeafter2am is offline
Well, the type of program you want to write depends greatly on what language you would want to learn. I do mostly shell scripting, python, perl, and a tiny bit of C. But I work exclusively in Unix and Linux environments, and dont write or use GUI's. I would recommend anything by O'Reilly as my bookshelf is filled with their books. First step though is to find out what you want to do, and then pick a language, not the other way around. Some languages do things better (faster, and with less lines of code) than others.

--lifeafter2am

masakatsu agatsu

@lifeafter2am
QUOTE Thanks
PowerBookG4

 
PowerBookG4's Avatar
 
Member Since: Jan 08, 2005
Location: New Jersey
Posts: 6,190
PowerBookG4 has much to be proud ofPowerBookG4 has much to be proud ofPowerBookG4 has much to be proud ofPowerBookG4 has much to be proud ofPowerBookG4 has much to be proud ofPowerBookG4 has much to be proud ofPowerBookG4 has much to be proud ofPowerBookG4 has much to be proud ofPowerBookG4 has much to be proud ofPowerBookG4 has much to be proud of
Mac Specs: Mac Pro 8x3.0ghz 12gb ram 8800GT , MBP 2.16 2GB Ram 17 inch.

PowerBookG4 is offline
I have also always wanted to try programming, but never found the right book.

What launguage are you looking at taking up?

I would recomend learning apple script first because what people say its the easiest and way to get some experience, and you can do alot of useful things with it.

My Website
Blog
I love my hosting company!
I was on the M-F honor roll for Febuary:2006
QUOTE Thanks
Logan
Guest
 
Posts: n/a

I wrote a post about this topic at this link. I suggest reading over the entire link, but if nothing else read my post quoted here: (Note: This was in regards to someone learning to program at an early age)

Also note I'm comparing programming books for compiling binaries, not so much "Shell scripting", (even though VB's simplicity may be called shell scripting). Do a wikipedia on just about any language out there to get a decent idea on what makes it unique. This link shows how to write "Hello World" on a lot of different languages, I may give you an idea how the language looks.

Quote:
I started programming at 12. I stumbled upon this "Welcome to Visual C++" book that really was designed for someone who was already programming in C and was learning C++.

Just with that book I figured out the structure, essentials... it was a major headache and I thought C++ was too hard for me.

I stumbled upon VB [Visual Basic] around your age. Really, at your age, if you have the motivation, you can at least get familiar with any language. The key thing is to decide now what seems like the best solution to what you think you'd like to do a long time, then just stick to it. Have fun. And enjoy the benefits of being young and knowing a programming language (Everyone calls you a genius, hah). If you do it as a hobby and have time, you'll pick it up extremely fast and constantly be learning all the junk you'll need to just get certified in it.. once you can afford it.

This is how I relate a lot of the software languages: Let's say programming is like cars. You're trying to get from point A to point B.

Assembly: You design the car, the wheels, the fuel system, the smallest details and create the perfect machine. Some times WAAY too much work to get anything done, but it's a piece of art whatever is written in it properly.

C++: You create the most efficient machine available. You tweak it to perfectly fit your personal desires, and it runs flawlessly. It takes you a little while to design the car but it's well worth the investment once everything is said and done.

VB (and real basic): You take someone else's chassis and engine and create a simple frame. You customize the apolostry, paint job.. and throw in a couple tweaks here or there. You get it done fast, and it may be a little crude. But it'll get the job done.

Java: You make a economy car. The car is built to where it runs on different fuels, is highly compatible and can get around in various situations. The problem is you tend to not be as efficient as an asm/c++ car, but especially with how java has been improved lately this may (or may not) be a great investment to the future. (I keep hearing lately that benchmark tests on java are competing with C++ written for the OS!!)

In my personal life, I have found VB the great choice. Sure my code isn't as flawless as C++, nor am I as compatible as Java, but when someone wants a program I can whip it up in surprisingly fast timing. Other programmers dislike me usually for writing in VB, plus I can only write Microsoft Windows apps (Which is annoying when you like to run OS X and other OS's), but man it's so freaking easy to learn.

If you want I suggest... I say C++. It's bottom line the biggest of all languages. You can take what you know of C++, go to any operating system, learn the API (darwin in OS X), and adapt to the tweaks of almost any OS.

Also C++ is the basis of all other programming languages usually. So you can take C++, and pick up Java.. PHP, anything really.. and you'll figure it out in no time just with the knowledge you have of C++.

But it's also one of the harder languages to learn. Assembly I don't suggest, it is getting outdated and is very situational when you want to use it.

Java I like and dislike.. mixed feelings really.. in the long run, I DISLIKE IT because of silly things like java beans... JUST THE NAME ALONE ugh. lol.

As far as web programming goes, if you learn software you will think web programming is a joke in difficulty.

Anyways, play around with all and see which language makes the most sense to you.

And when you find it, do this:

1) Go to the library, find a "introduction to X language" type book, or a beginner book. Find an author that makes sense to you. Don't fret if some books don't make sense, some people just can't teach you well. Finding a teacher you can relate to is some times the biggest key to learning what he has to teach.

2) Find a forum. Once you start reading and learning the book, use the forum for those nasty questions that arise. Most programming forums are pretty nice to beginners, as long as you're giving a real effort to learn it.

3) Have fun.

"Hello World!" Scripts for languages above:
C++
Code:
#include <iostream>
 
int main()
{
    std::cout << "Hello, world!" << std::endl;
    return 0;
}
VB .NET
Code:
Module HelloWorldApp
  Sub Main()
     System.Console.WriteLine("Hello, world!")
  End Sub
End Module
(RealBasic's example could be used in VB .NET too)
REALbasic
Code:
MsgBox "Hello, world!"
Java
Code:
public class HelloWorld {
     public static void main(String[] args) {
          System.out.println("Hello, world!");
     }
}
Assembly is just crazy (x86 DOS based app)
Code:
MODEL   SMALL
IDEAL
STACK   100H

DATASEG
        MSG DB 'Hello, world!', 13, '$'

CODESEG
Start:
        MOV AX, @data
        MOV DS, AX
        MOV DX, OFFSET MSG
        MOV AH, 09H      ; DOS: output ASCII$ string
        INT 21H
        MOV AX, 4C00H
        INT 21H
END Start
Code:
; Example of making 32-bit PE program as raw code and data

format PE GUI
entry start

section '.code' code readable executable

  start:

        push    0
        push    _caption
        push    _message
        push    0
        call    [MessageBox]

        push    0
        call    [ExitProcess]

section '.data' data readable writeable

  _caption db 'Win32 assembly program',0
  _message db 'Hello, world!',0

section '.idata' import data readable writeable

  dd 0,0,0,RVA kernel_name,RVA kernel_table
  dd 0,0,0,RVA user_name,RVA user_table
  dd 0,0,0,0,0

  kernel_table:
    ExitProcess dd RVA _ExitProcess
    dd 0
  user_table:
    MessageBox dd RVA _MessageBoxA
    dd 0

  kernel_name db 'KERNEL32.DLL',0
  user_name db 'USER32.DLL',0

  _ExitProcess dw 0
    db 'ExitProcess',0
  _MessageBoxA dw 0
    db 'MessageBoxA',0

section '.reloc' fixups data readable discardable
QUOTE Thanks
trpnmonkey41

 
Member Since: Jul 22, 2003
Location: Hamilton College
Posts: 7,003
trpnmonkey41 is a splendid one to beholdtrpnmonkey41 is a splendid one to beholdtrpnmonkey41 is a splendid one to beholdtrpnmonkey41 is a splendid one to beholdtrpnmonkey41 is a splendid one to beholdtrpnmonkey41 is a splendid one to beholdtrpnmonkey41 is a splendid one to beholdtrpnmonkey41 is a splendid one to behold
Mac Specs: 20" iMac C2D 2.16ghz, 13" MacBook 2.0ghz, 60gb iPod vid, 1gb nano

trpnmonkey41 is offline
just plain old command line java is a pretty intuitive language. I have been programming for 3 years now and still don't do anything with a GUI.

O'Reilly books are definitely a must
The order I learned languages in was
HTML, Java, C++, Objective C, MySQL, Smalltalk 80, ML, Scheme, Python, Prolog, ADA

Don't forget to use the new User Reputation System
QUOTE Thanks
Logan
Guest
 
Posts: n/a

Quote:
Originally Posted by trpnmonkey41
just plain old command line java is a pretty intuitive language. I have been programming for 3 years now and still don't do anything with a GUI.

O'Reilly books are definitely a must
The order I learned languages in was
HTML, Java, C++, Objective C, MySQL, Smalltalk 80, ML, Scheme, Python, Prolog, ADA
I *REALLY* want to learn how to uses curses... Maybe with Python just because I know Python is easy yet powerful.. but I love ncurses! console graphics all the way...
QUOTE Thanks
Mr Bobbins

 
Mr Bobbins's Avatar
 
Member Since: Jan 29, 2005
Location: Legoland
Posts: 790
Mr Bobbins has a spectacular aura about

Mr Bobbins is offline
Thanks for all the replies.

After reading them all I've come to the conclusion that Objective C interests me the most. I guess a trip to the book shop is the next step. :p
QUOTE Thanks
mac57

 
mac57's Avatar
 
Member Since: Apr 29, 2006
Location: St. Somewhere
Posts: 4,560
mac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant future
Mac Specs: iMac 27" 3.4 GHz, 256 GB SSD, 2 TB HDD, 8 GB RAM

mac57 is offline
Logan, curses *is* pretty easy to use, and with the tools on your Mac, plus good 'ol Terminal, you can be a whiz in no time flat. I taught myself curses through trial and error and looking at other people's programs.

I am the author of the VE text editor which you may have tripped over here and there if you have been poking around the world of Linux. VE is a feature rich terminal based text editor that does *all* of its I/O in (you guessed it) curses.

Of course like most good Linux software, it is open source. If you would like to have a look at the source code, I have uploaded it to my web site - you can retrieve it from there. Point your browser at:

http://www.campbellware.com/curses/v...macosx.tar.bz2

and save the file somewhere. Of course when I moved to a Mac, the first thing I did was get VE running on the Mac, so what you get here is a fully functioning program that you can compile, build and play with.

To unpack it, open Terminal, and issue the following mumbo jumbo:

tar -xjf ve-3.5g.macosx.tar.bz2

This will create a folder hierarchy called v3.5g-MacOSX. cd into the "prog" subdirectory and you should see all the source files (plus all the compiled object files). VE employs a clean modular design (I used to be a software engineer before I was sucked into the dark side - now I am a product manager) and hence ALL of the curses interactions are contained in two modules.

Check out modules "termif.c" and kbdif.c". These are respectively the output and input modules for VE. ALL of its terminal output goes through termif.c and all keyboard input comes in through kbdif.c. These should give you an excellent idea of how to use curses to do almost anything.

By the way, the references you see all over to ncurses is to the Linux implementation of curses, called ncurses (for "new curses"). Don't worry, this builds and runs just fine on the Mac's curses.

The folder hierarchy you created a few paragraphs above includes a very complete users guide, so may be of some help. It is presented in both PDF and OpenOffice format. Finally, VE uses the F9-F12 keys and so I have remapped expose and Dashboard to CMD-F9 - CMD-F12. If you want to play with VE, you may wish to do the same.

By the way, to compile the editor, just issue the following:

make clean
make

Thats it! The file "ve" will result and you can execute it via:

./ve filename

Enjoy, and if you have any questions, just let me know via a private message.

My Macs: iMac 27" 3.4 GHz, Mac Pro 3.2 GHz, PowerMac G5 Quad 2.5 GHz, G4 Cube with 1.2 GHz Upgrade
My iStuff: 64GB iPhone 5, 64GB iPad4, 30GB iPod Video, 16GB iPod Touch
My OS': Mac OS X Lion, Mac OS X Snow Leopard, Mac OS X Tiger, Mac OS 9.2.2, openSUSE 10.3
I was on the Mac-Forums honor roll for September 2007
QUOTE Thanks
Logan
Guest
 
Posts: n/a

it's weird that your initials are mac
Checking out as you said, thanks very much.. will PM from now on.
QUOTE Thanks
mac57

 
mac57's Avatar
 
Member Since: Apr 29, 2006
Location: St. Somewhere
Posts: 4,560
mac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant future
Mac Specs: iMac 27" 3.4 GHz, 256 GB SSD, 2 TB HDD, 8 GB RAM

mac57 is offline
Great, have fun Logan. BTW, you can also just email me at:

support@campbellware.com

if that is more convenient.

My Macs: iMac 27" 3.4 GHz, Mac Pro 3.2 GHz, PowerMac G5 Quad 2.5 GHz, G4 Cube with 1.2 GHz Upgrade
My iStuff: 64GB iPhone 5, 64GB iPad4, 30GB iPod Video, 16GB iPod Touch
My OS': Mac OS X Lion, Mac OS X Snow Leopard, Mac OS X Tiger, Mac OS 9.2.2, openSUSE 10.3
I was on the Mac-Forums honor roll for September 2007
QUOTE Thanks

Post Reply New Thread Subscribe


« Shell scripting | mounting network drives at startup »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Uninstalling Programs Sloopy Switcher Hangout 13 02-09-2009 11:21 PM
Big programs not running. DCraver Apple Desktops 3 01-27-2006 09:22 PM
How to turn off sounds in classic 9 adobe programs?? nmr1279 Running Windows (or anything else) on your Mac 1 06-02-2005 10:47 AM
what's with the fuss about stealing mac programs through the ipod? emoglitterati iPod Hardware and Accessories 1 09-24-2004 04:26 PM
Question on windows programs on Macs MUMacUser Switcher Hangout 4 09-19-2004 08:25 PM

All times are GMT -4. The time now is 01:44 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?