Learning to code in C

Status
Not open for further replies.
Five bucks says none of you C++ yokels has heard of restrict pointers, or variable-length arrays. (You don't get to look it up without forfeiting. :D ).
--
Stephan T. Lavavej
]http://stl.caltech.edu<HR></BLOCKQUOTE>
You lose. Let's see those 5 bucks.

Here is a surprise for you: you aren't the only one who's heard of C99, and reading about new features in a programming language doesn't make you the coolest thing on the block. Of course I am sure you have a quote from some two-bit armchair philosopher to prove me wrong.
 

Richard Berg

Ars Legatus Legionis
43,037
Subscriptor
Here is a surprise for you: you aren't the only one who's heard of C99, and reading about new features in a programming language doesn't make you the coolest thing on the block.
No, but antagonizing C++ advocates while always linking to his "STL" subdomain sure provides a lot of irony :p

ha, ha, hah, hah, hah... sorry, all the computer science guys are laughing at you PeterB. it just shows you don't know what you are talking about at a deep level, nor do you understand "at a low level" what's going on.
Um, yeah. I'm much more of a CS guy than a coder, but I'm not about to argue that the computational models you learn in your algorithms class prove that one method is superior to another in every possible situation despite being given empirical evidence to the contrary.
 
Originally posted by bugbum1:
ha, ha, hah, hah, hah... sorry, all the computer science guys are laughing at you PeterB. it just shows you don't know what you are talking about at a deep level, nor do you understand "at a low level" what's going on.
:rolleyes:

jemfinch said he'd never seen a merge sort slower than a heap sort. I'm saying I have. Notice the discussion wasn't about what the performance ought to be, but about what it was.

You CompSci guys can laugh all you like, but it doesn't change that there are poor implementations out there.

And it doesn't matter a fuck about how the algorithm ought to perform if it's been implemented in such a way as to perform badly -- last I checked, you couldn't write a program that only used theoretical code.
 

mebeSajid

Ars Praefectus
4,022
Subscriptor
Originally posted by PsychoOne:
Quote: "
Five bucks says none of you C++ yokels has heard of restrict pointers, or variable-length arrays. (You don't get to look it up without forfeiting. :D ).
--
Stephan T. Lavavej
http://stl.caltech.edu"
You lose. Let's see those 5 bucks.

Here is a _surprise_ for you: you aren't the only one who's heard of C99, and reading about new features in a programming language doesn't make you the coolest thing on the block. Of course I am sure you have a quote from some two-bit armchair philosopher to prove me wrong.

Is there a compiler that actually fully implements C99?

Sajid
 
jemfinch flamed:
> That still doesn't stop Java programmers from writing complete,
> useful programs while you're still piddling around with memory
> management libraries.

Hey. I don't attack YOU, so don't you go ridiculing me. I happen to be playing around with memory abstraction functions because I think it's fun. Generally this gets me somewhere. Ridicule my arguments, not me.

"Java is here to stay as a Web-applet language....
In Java's favor, we can say that the language is cleverly designed to capture the huge benefit of automatic memory management and the lesser but not insignificant benefit of OO design, while retaining a broadly C-like syntax that most programmers will find comfortable. We can note that it includes support for callouts to dynamically-loaded C and calling Java as an embedded language from C. And we can fairly judge it superior to C++ (which is both more complex and does less to attack the memory-management problem) for all but systems programming and the most speed-critical applications.

Against Java, we can say that (compared to, say, Python) some parts of it appear over-complex and others deficient. Java's class-visibility and implicit-scoping rules are baroque. The interface facility avoids complex problems with multiple inheritance at the cost of being only slightly less difficult to understand and use in itself. The lack of a type-safe dynamic container object for mixed-type elements (analogous to Perl or Python arrays) is a problem. The lack of a first-class associative-array object (analogous to Perl hashes or Python dictionaries) is another one. And the absence of any facility for conditioning code at compile time (like C's #ifdef/#endif) can be a significant irritant on large, real-world projects." - Eric S. Raymond, The Art of Unix Programming

I don't agree with everything ESR says there (namely, Java being superior to C++), but he knows more than you or I, Mr. Jemfinch.

Were we talking about C? I think we were.

mebeSajid said:
> Is there a compiler that actually fully implements C99?

Not yet. :-/ Maybe soon.
--
Stephan T. Lavavej
http://stl.caltech.edu
 

bugbum1

Ars Scholae Palatinae
893
jemfinch said he'd never seen a merge sort slower than a heap sort. I'm saying I have. Notice the discussion wasn't about what the performance ought to be, but about what it was.

:D keep digging peter, or have you dragged out the book yet to determine why the distinction you've drawn above makes this even funnier and supports my assertion (it has nothing to do with the implementation, but the theory, which you don't know).
 
D

Deleted member 5324

Guest
Originally posted by Stephan T. Lavavej:
_Hey._ I don't attack YOU, so don't you go ridiculing me.

You ridiculed Java programmers.

First,
I don't agree with everything ESR says there (namely, Java being superior to C++), but he knows more than you or I, Mr. Jemfinch.

ESR makes up words like "noosphere."

ESR is also against gun control. Does that mean I should change my stance on the issue because he's supposedly smarter than me?

This isn't meant as an attack, just an observation: you seem to be very fond of quoting others. I always here about "this or that book" or some quote of someone else -- it's nice that you're giving attribution, but I think you rely a bit too much on other people's opinions at the expense of developing your own (which, ironically, doesn't stop you from holding strong opinions, it just stops you from claiming them as your own.)

The lack of a type-safe dynamic container object for mixed-type elements (analogous to Perl or Python arrays) is a problem.

This is a feature, not a bug :) It supports greater type-safety. I also thought that the lack of such a dynamic container would be problematic, but after working with O'Caml for some time, it's really not problematic at all (at least in O'Caml.)

The lack of a first-class associative-array object (analogous to Perl hashes or Python dictionaries) is another one.

Am I missing something about java.util.Dictionary?

And the absence of any facility for conditioning code at compile time (like C's #ifdef/#endif) can be a significant irritant on large, real-world projects."

Last I checked, I can just as easily run cpp on Java files as I can on C/C++ files.

Jeremy
 

mebeSajid

Ars Praefectus
4,022
Subscriptor
Originally posted by bugbum1:
Quote: "
jemfinch said he'd never seen a merge sort slower than a heap sort. I'm saying I have. Notice the discussion wasn't about what the performance ought to be, but about what it was. "

:D keep digging peter, or have you dragged out the book yet to determine why the distinction you've drawn above makes this even funnier and supports my assertion (it has nothing to do with the implementation, but the theory, which you don't know).


Aren't the two defined as library calls? Why not define a structure, write a function to compare structures, and pass an array of those structs, the size of the array, the size of each element, and teh function pointer to the comparison pointer into the library call, and see which works faster? That's the simplest solution to teh argument.

Sajid
 
Originally posted by bugbum1:
keep digging peter, or have you dragged out the book yet to determine why the distinction you've drawn above makes this even funnier and supports my assertion (it has nothing to do with the implementation, but the theory, which you don't know).
:rolleyes:

No amount of theory will make a poorly implemented algorithm go faster. It'll remain O(n logn) (assuming the implementation is accurate) but the constant factor and lesser terms are variable and implementation-dependent. If my merge-sort implementation were to sleep for an hour after each operation, it'd still be O(n logn), but for any dataset I can give it, a plain heap-sort will be faster. Oh, sure, in theory, if I gave it as many elements as there are atoms in the universe or something, it might catch up with or surpass the heap-sort -- but my computer ran out of memory long ago.

Theoretical superiority alone doesn't mean that merge-sort will win in practical tests.
 
Aren't the two defined as library calls? Why not define a structure, write a function to compare structures, and pass an array of those structs, the size of the array, the size of each element, and teh function pointer to the comparison pointer into the library call, and see which works faster? That's the simplest solution to teh argument.
That's what I'm about to do! I think both sorts are implemented in the STL so it shouldn't be too long to do. I'll get back here if I get something interesting :)
 
Originally posted by jemfinch:
Um, both merge sort and heapsort are O(n log n) algorithms.
Yes but they have different characteristics. Merge sort always involves about O(n log n) moves, but heap sort seems to involve a little less (although it must have O(n log n) compares). The tests I've done show that merge sort wins with small objects, but looses as objects get bigger (~150-200 bytes). Of course with objects that size you'd probably want to sort pointers instead... but this shows that heap sort can easily be faster if one isn't careful.
 
Status
Not open for further replies.