Learning C


netbsd said:
realyst said:
Thanks again for all the feedback:)

I'm actually now looking at how pointers work and am loving the possibilities! (does that make me a sick man?)
Well, you are already familiar with pointers in Perl, although they are called references there (perldoc perlref). A straightforward (naive) translation from a hash reference in Perl

my %h = (a=>1, b=>2);
my $p = \%h;
printf "%d\n", $p->{a};

to a struct pointer in C would be:

struct {int a; int b;} h = {1, 2}, *p = &h;
printf("%d\n", p->a);

The dereference operator (->) is even the same.

Unless of course you mean with possibilities (potentially unsafe) type casts and dangling pointers :lol:


So nice to see another Perl fan.
 
Last edited by a moderator:
Well, anything goes, really. Corollary: everything sucks.

I can't really be bothered with saying which syntactic sugar is the best. Perl, Javascript, Ruby, Python, even Java, are all thin layers over C or C++, their libraries and decades old Unix system calls. I also can't be bothered with saying a procedure, method, relation, function, constraint or process is better than one of the others (although some suck less if you're bored with the others). A fixed preference is a fashion statement or food for historians.

It seems we are stuck in the same old Turing tar pit and are unable to jump to the next level. We get more complexity and more bloat with diminishing returns.

To have some fun, we might as well try to cut out some of the fat, assume the world is stable and specialize for what Pandora's hardware offers.
 
netbsd said:
...

It seems we are stuck in the same old Turing tar pit and are unable to jump to the next level. We get more complexity and more bloat with diminishing returns.

To have some fun, we might as well try to cut out some of the fat, assume the world is stable and specialize for what Pandora's hardware offers.
Now how far are you willing to actually go with that one? :rolleyes:
 
Last edited by a moderator:
It depends on a number of external factors beyond my control that I mentioned in some of my posts.
 
netbsd said:
Perl, Javascript, Ruby, Python, even Java, are all thin layers over C or C++
Uhm...Excuse me... Other languages are NOT syntactic sugar. You try running Perl, Javascript, Ruby, Python, or Java code in a C compiler with some fancy #defines... its not gonna happen.
 
Last edited by a moderator:
Blah said:
netbsd said:
Perl, Javascript, Ruby, Python, even Java, are all thin layers over C or C++
Uhm...Excuse me... Other languages are NOT syntactic sugar. You try running Perl, Javascript, Ruby, Python, or Java code in a C compiler with some fancy #defines... its not gonna happen.



Very little changes syntax wise between Perl and PHP. Sure, some functions are named a little different(split -> explode, for example) and you have to call a special function in PHP should you want to do some regex, but variable declarations, syntax, hashes, etc... are pretty much the same. It would just take a quick one-over to port PHP apps to Perl(I've done it a few times already, which was the original reason I even picked up some Perl...and probably why I showed much ignorance with the Perl References...I had picked up Perl as a PHP guy, the very idea of 'pointers' wasn't in my mind since PHP doesn't really have any...or an analog[PHP pointers are very different from {apparently}Perl Refs or C Pointers, being closer to an alias]).

As for PHP, Perl and C....I'm still new at this but I may have to agree with you there if strings, for example, are dealt with in any capacity :D
 
Last edited by a moderator:
I'm a very poor programmer, but I have some experience in Visual Basic 6.0, Java and Python. I used to dislike Java, but I started a CS class recently, and I hate C++ even more. I LOVE Java now. It seems like I spend forever just debugging even small and simple programs, because small errors are harder to find than in any of the above languages. I think the real problem is that I just suck at "problem solving skills" though...
 
hey

Sphinxter said:
Avoid the stream functions many books preach like fopen and fread, stick with the lower level open, read and write routines.
Sorry to go off topic, but why avoid <stdio.h> fopen() and fread() and such?

Personally I say stick with C, and eventually move onto C/C++ or whatever you prefer. I find my code much more elegant using classes and such :). Although there was a time when I prefered doing in more of a C style or whatever without the use of classes and such, but the advantages or whatever I find in C++ are really cool.

Hmm, well I guess it depends on what ya doing also, as I like how SDL and OpenGL use C rather than C++, hehe. So certainly both have their places :), and I recommend you learn both and code however ya prefer.

But yea, there are lots and lots of C/C++ programming tutorials online, so I guess ya just gotta find the one that is most to your likings. BTW, I find http://www.cplusplus.com/ref very handy.

cyas
 
Last edited by a moderator:
Back
Top