Why C++ …
I'm not saying it's the be all and end all, I'm just saying it seems to fit my coding style very well. Right now I'm kind of curious to see what these "power tools" are.
Well, here's something cool:
If you then call (tree-map square tree) it will return a copy of tree with all the data in the tree squared.
You'll notice that functions are just data, so you can pass them around without any messy function pointers.
The way this tree structure is laid out is with three functions: (make-tree datum children) which takes a datum, and a list of child trees. (datum tree) returns the datum, and (children tree) returns the list of children.
Map is a function that takes a function and a list, and returns a list whose elements are that function applied to each element of the list.
Also, function calls always precede the arguments (even for arithmetic) so (* x x) is like x * x in C.
Code:
(define (square x) (* x x))
(define (tree-map func tree)
(make-tree (func (datum tree)) (map (lambda (x) (tree-map func x)) (children tree))))You'll notice that functions are just data, so you can pass them around without any messy function pointers.
The way this tree structure is laid out is with three functions: (make-tree datum children) which takes a datum, and a list of child trees. (datum tree) returns the datum, and (children tree) returns the list of children.
Map is a function that takes a function and a list, and returns a list whose elements are that function applied to each element of the list.
Also, function calls always precede the arguments (even for arithmetic) so (* x x) is like x * x in C.
Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
That's kind of cool. So it's basically a simpler/quicker way to do function pointers? It does seem to broach on the issue of readability, though.
I thought functional code was really hard to read too before I took a programming languages class. Probably one of the best classes I've taken. Now I still think it's fairly hard to read, but definitely allows some very elegant and simple solutions to a lot of problems.
I also liked OCaml better than Scheme as far as functional languages go. Scheme has a very simple straightforward syntax, but is fairly hard to read. OCaml has a much more natural syntax. (Without millions of ()'s) Of course, Scheme's syntax allows code to be manipulated as a tree, OCaml cannot do this as far as I know.
I also liked OCaml better than Scheme as far as functional languages go. Scheme has a very simple straightforward syntax, but is fairly hard to read. OCaml has a much more natural syntax. (Without millions of ()'s) Of course, Scheme's syntax allows code to be manipulated as a tree, OCaml cannot do this as far as I know.
Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
akb825 Wrote:I'm not saying it's the be all and end all, I'm just saying it seems to fit my coding style very well...
Does C/C++ fit your coding style, or does your coding style fit C/C++?
The readability isn't so bad if you have both proper indentation/linebreaks and proper syntax coloring, neither of which are possible here 
And yes it's kinda like function pointers, except it's more flexible - no types, no pointers, and you don't have to give everything a name. You could just as easily pass (lambda (x) (* x x)) instead of the square procedure and it would be just as happy.

And yes it's kinda like function pointers, except it's more flexible - no types, no pointers, and you don't have to give everything a name. You could just as easily pass (lambda (x) (* x x)) instead of the square procedure and it would be just as happy.
Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
DoG Wrote:Does C/C++ fit your coding style, or does your coding style fit C/C++?Well, I learned first in Java (for school), but as soon as I taught myself C/C++ shortly after, I have been using it exclusively for my own projects. Since it was pretty much part of my learning process, I'm sure it helped shape my coding style. But I'll put it this way: whenever I'm using C/C++, I never feel "trapped" or that there's something that I need that's missing. I suppose that could partially be because I haven't experienced some of the features of other languages. However, from what I've seen here, I haven't seen anything that I really want to use.
akb825 Wrote:Well, I learned first in Java (for school), but as soon as I taught myself C/C++ shortly after, I have been using it exclusively for my own projects. Since it was pretty much part of my learning process, I'm sure it helped shape my coding style. But I'll put it this way: whenever I'm using C/C++, I never feel "trapped" or that there's something that I need that's missing. I suppose that could partially be because I haven't experienced some of the features of other languages. However, from what I've seen here, I haven't seen anything that I really want to use.Ruby has spoiled me.
Josh Wrote:Ruby has spoiled me.
Yeah, I think Ruby is the only language I use where I don't constantly go "well, if I had *that* language feature, this would be easy..."
After using cocoa a bit I kind of "got" the idea behind objective-c and am quite impressed (you kind of do everything by overriding existing methods
). Indeed it allows for quick and clean use of the huge API.
But for a game, hmmm, I dont think you need as much "generality"... a "bare bones" object oriented framework is fine, such as Blitzmax's or the more simple C++ stuff.
Since you are not using "ultra general" code provided by others but your own, likely much more "to the point".
). Indeed it allows for quick and clean use of the huge API.But for a game, hmmm, I dont think you need as much "generality"... a "bare bones" object oriented framework is fine, such as Blitzmax's or the more simple C++ stuff.
Since you are not using "ultra general" code provided by others but your own, likely much more "to the point".
©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
Najdorf Wrote:After using cocoa a bit I kind of "got" the idea behind objective-c and am quite impressed (you kind of do everything by overriding existing methods). Indeed it allows for quick and clean use of the huge API.
But for a game, hmmm, I dont think you need as much "generality"... a "bare bones" object oriented framework is fine, such as Blitzmax's or the more simple C++ stuff.
Since you are not using "ultra general" code provided by others but your own, likely much more "to the point".
"What's with all the "quotes"?"

Anyway, if you have a more powerful language to your disposal, you can write very general code that works very quickly, but still have the choice to speed things up by creating specialized code, or even dropping to C, most of the time.
For projects consisting roughly of more than a few thousand lines of code, probably even smaller ones, the overall complexity of a program written with high level scripting + C/C++ will worst case rival that of a pure C/C++ program with the same task.
The only potential downside of using a scripting language is performance, and that can be helped.
Also, working with a language that is less restrictive allows encourages to explore new ways of doing things, imho.
One language I really liked from my programming languages course was Gopher, a simplified version of Haskell which has since been supplanted by HUGS. I liked Haskell's syntax more than LISP's, primarily for its brevity. Here's some further reading if you're interested.
akb825 Wrote:[...] whenever I'm using C/C++, I never feel "trapped" or that there's something that I need that's missing. I suppose that could partially be because I haven't experienced some of the features of other languages. However, from what I've seen here, I haven't seen anything that I really want to use.
Ed (a.k.a. fax) linked me to an article recently which covers that point very well. You can find it here:
http://weblog.raganwald.com/2006/10/are-...mmers.html
I'm sure you could talk to any programmer who has used something more high-level than C++ and you'd get the same response. When C++ was all they knew, it felt perfectly natural. Not so now that they've used lisp or python or any other language which ranks more highly on the blub scale.
And like Keith says, if you haven't used any of those languages, you owe yourself an education :-p
C++ still has it's place, of course. It's just not a good tool for every job - indeed, I'd say it's a bad tool for most jobs. Knowing the alternatives will make your life vastly less stressful when you encounter a job which C++ doesn't solve easily.
I'm in the last week of my programming languages class. We've gone through OCaml, Python, and we just finished Prolog. Of all of those, I think Python was my favorite, excluding some superficial problems. (namely using whitespace to determine scope and implicit variable declaration) However, while trying to keep an open mind, I still prefer to code in C++, due to keeping enough low-level control to try and make sure that I do things as efficiently as possible along with still keeping at least some high-level concepts intact. Sure, there's some corner cases that can sometimes cause some problems and/or ugliness with things such as templates, but there's also plenty of headaches that can be caused due to Python's dynamic types or with any other language. Bottom line is, I think C++ still fits what I do the best.
You'll know you've become a good programmer when you change your mind ^_^

