Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mwpeters8182

macrumors 6502
Apr 16, 2003
411
0
Boston, MA
The first step in learning how to write code is to learn proper programming practice. I think you can do this with C, C++, C#, or Java really.

I'd read up on all of them, and get the O'Reilly book that corresponds to that language. I'd also maybe look into taking class at a community college or something, if you've never had a formal introduction to programming (though I can't vouch for how useful that'd be - I've taken worthwhile programming classes and ones that were a complete waste of time.)
 

darkwing

macrumors 65816
Jan 6, 2004
1,210
0
demallien said:
If you want to write cool hardware drivers, that make wonderful devices such as the iPod tick, go C!!!! Yay C, I love C :D (well, ok, the iPod was probably done in Objective-C, because Apple, god bless their cotton socks, gives us an OO driver development environment. But your mobile phone's embedded code was probably written in C)

Apple doesn't use Obj-C for drivers. It uses a stripped version of C++ suitable for a kernel environment, as was mentioned earlier in this thread. (No RTTI, no STL, etc.) I had to write a couple kexts for an OS class. I already had so much Linux experience I talked the teacher into letting me do OSX drivers so I could learn something new.
 

therevolution

macrumors 6502
May 12, 2003
468
0
HiRez said:
Dude, I love the animated blog! Not quite sure what it was trying to say, but the format is great, seeing live code entry and illustrations. I'd like to see you do some actual (semi-serious) tutorials in this format.
Oh, I can't take credit. I wish I knew how to do that. :eek: I just thought it was funny, and it happened to be relevant to the discussion.
 

cube

Suspended
May 10, 2004
17,011
4,973
mwpeters8182 said:
The first step in learning how to write code is to learn proper programming practice. I think you can do this with C, C++, C#, or Java really.

But you cannot learn all programming concepts with those languages. That's why you need Scheme.

It's no problem that plain standard scheme does not have OO capabilities, as that can be added portably with something like tinyclos, which will also teach you about metaobject protocols. This is better than using the nonportable OO extensions of some Scheme implementations.
Also, the OO one gets with tinyclos is really object-oriented, dispatching on multiple arguments, not "subject-oriented" like those other languages.
 

zimv20

macrumors 601
Jul 18, 2002
4,402
11
toronto
cube said:
But you cannot learn all programming concepts with those languages. That's why you need Scheme.
what's lacking? i never learned scheme, but certainly can program pointers, recursion, OO, data structures and a whole bunch of other stuff, better than most from my experiences. what am i missing (personally, i mean, not what am i missing from my short list)?
 

mwpeters8182

macrumors 6502
Apr 16, 2003
411
0
Boston, MA
Why can't you learn basic programming concepts with the above languages?

I'ts best to outline everything is pseudocode anyway. The implementation is really the only thing that's language-specific.
 

darkwing

macrumors 65816
Jan 6, 2004
1,210
0
mwpeters8182 said:
Why can't you learn basic programming concepts with the above languages?

I'ts best to outline everything is pseudocode anyway. The implementation is really the only thing that's language-specific.

I disagree. Suppose you had pseudocode for some form of self modifying code. This would have to be done differently if you were going to use LISP than say, C. Don't you think?
 

zimv20

macrumors 601
Jul 18, 2002
4,402
11
toronto
mwpeters8182 said:
I'ts best to outline everything is pseudocode anyway. The implementation is really the only thing that's language-specific.
that's one of those "if it works for you" things. i tried it when i was learning, but it didn't do much for me, at least a part of my brain is always thinking implementation.

though i have found pseudocode to be useful in communicating a concept to those who can't context switch between implementation and design.
 

cube

Suspended
May 10, 2004
17,011
4,973
zimv20 said:
what's lacking? i never learned scheme, but certainly can program pointers, recursion, OO, data structures and a whole bunch of other stuff, better than most from my experiences. what am i missing (personally, i mean, not what am i missing from my short list)?

The most obvious points are closures, and continuations. You also don't have anything resembling the power of Lisp macros. Those languages also lack a metaobject protocol (to extend the language with member daemons, integrated constraints, new inheritance rules, etc.).

With continuations and Lisp macros you can extend the language with new sophisticated control structures like coroutines and backtracking.

Scheme, regardless of its tiny size, is the most powerful high level language because of this (Common Lisp doesn't have first-class continuations). You can basically extend it to whatever you want.
 

zimv20

macrumors 601
Jul 18, 2002
4,402
11
toronto
cube said:
The most obvious points are closures, and continuations. You also don't have anything resembling the power of Lisp macros.

With continuations and Lisp macros you can extend the language with new sophisticated control structures like coroutines and backtracking.
good call, i have no idea what you're talking about :)

can you explain a bit more? i dabbled in Lisp, about 20 years ago, but could use a refresher on some language features.
 

cube

Suspended
May 10, 2004
17,011
4,973
zimv20 said:
good call, i have no idea what you're talking about :)

can you explain a bit more? i dabbled in Lisp, about 20 years ago, but could use a refresher on some language features.

From this page:

"In Scheme, continuations are first-class objects, just like functions. You can ask Scheme for the current continuation, and it will make you a function of one argument representing the future of the computation. You can save this object for as long as you like, and when you call it, it will restart the computation that was taking place when it was created.

Continuations can be understood as a generalization of closures. A closure is a function plus pointers to the lexical variables visible at the time it was created. A continuation is a function plus a pointer to the whole stack pending at the time it was created. When a continuation is evaluated, it returns a value using its own copy of the stack, ignoring the current one. If a continuation is created at t1 and evaluated at t2 , it will be evaluated with the stack that was pending at t1 ."

The programming concepts bible (using Scheme): SICP (but doesn't talk about reified continuations)

The most beautiful book on Lisp macros (you need to know Common Lisp):
On Lisp

The wonders of the Meta Object Protocol (you need to know Common Lisp): AMOP

Not sure what's the best introduction to Common Lisp, as there are several newer books I haven't read. Better ask in comp.lang.lisp
 
cube said:
From this page:

"In Scheme, continuations are first-class objects, just like functions. You can ask Scheme for the current continuation, and it will make you a function of one argument representing the future of the computation. You can save this object for as long as you like, and when you call it, it will restart the computation that was taking place when it was created.

Continuations can be understood as a generalization of closures. A closure is a function plus pointers to the lexical variables visible at the time it was created. A continuation is a function plus a pointer to the whole stack pending at the time it was created. When a continuation is evaluated, it returns a value using its own copy of the stack, ignoring the current one. If a continuation is created at t1 and evaluated at t2 , it will be evaluated with the stack that was pending at t1 ."

Hmm, I am not really clear how these significantly differ from exceptions and functors in C++ (just for example).

Any chance of some further clarification, highlighting the differences?
 

cube

Suspended
May 10, 2004
17,011
4,973
AlmostThere said:
Hmm, I am not really clear how these significantly differ from exceptions and functors in C++ (just for example).

Any chance of some further clarification, highlighting the differences?

A try/catch block is an escaping continuation. A full continuation like in Scheme is a function that you can call over and over again and jumps the program to the point where it was created with the stack values at creation time.

A function object is a simulation of a closure. Variables from their environment are not captured.
 

cube

Suspended
May 10, 2004
17,011
4,973
cube said:
Not sure what's the best introduction to Common Lisp, as there are several newer books I haven't read. Better ask in comp.lang.lisp

Here you can download for free one of the newwest introductory books that has many good reviews (although some constructs are used in examples before being explained). I haven't read it yet, so I cannot give you my opinion. As it's geared toward developing practical examples, maybe it's not so comprehensive in showing you the most advanced features:
Practical Common Lisp

BTW, If you are going to try Lisp, please get an editor with a Lisp mode. For (X)Emacs, there is ilisp, which allows you to interact with the Lisp runtime from the editor. For Eclipse, there's the SchemeWay plugins (but I haven't tried them. Although geared towards Scheme, apparently some people used them successfully with CL; but I don't know if just for editing, not interacting).

But the best environment to learn Scheme on must be DrScheme. That's what it was created for. It supports restricting the language to different levels.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.