Learning to write programs

Joined
Jan 29, 2005
Messages
790
Reaction score
13
Points
18
Location
Legoland
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:
 
Joined
Aug 25, 2006
Messages
1,395
Reaction score
30
Points
48
Location
Central Florida
Your Mac's Specs
MacBook Pro Unibody
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
 
Joined
Jan 8, 2005
Messages
6,188
Reaction score
254
Points
83
Location
New Jersey
Your Mac's Specs
Mac Pro 8x3.0ghz 12gb ram 8800GT , MBP 2.16 2GB Ram 17 inch.
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.
 
L

Logan

Guest
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.

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
 
Joined
Jul 22, 2003
Messages
6,999
Reaction score
187
Points
63
Location
Hamilton College
Your Mac's Specs
20" iMac C2D 2.16ghz, 13" MacBook 2.0ghz, 60gb iPod vid, 1gb nano
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
 
L

Logan

Guest
trpnmonkey41 said:
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...
 
OP
Mr Bobbins
Joined
Jan 29, 2005
Messages
790
Reaction score
13
Points
18
Location
Legoland
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
 
Joined
Apr 29, 2006
Messages
4,576
Reaction score
378
Points
83
Location
St. Somewhere
Your Mac's Specs
Mac Studio, M1 Max, 32 GB RAM, 2 TB SSD
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:

www.campbellware.com/curses/ve-3.5g.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.
 
L

Logan

Guest
it's weird that your initials are mac :)
Checking out as you said, thanks very much.. will PM from now on.
 
Joined
Apr 29, 2006
Messages
4,576
Reaction score
378
Points
83
Location
St. Somewhere
Your Mac's Specs
Mac Studio, M1 Max, 32 GB RAM, 2 TB SSD
Great, have fun Logan. BTW, you can also just email me at:

[email protected]

if that is more convenient.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top