490 karma · joined March 4, 2010
Cliched argument; but every time I see such a misuse, I get a little sadder.
Otherwise it is a lot like saying Java is bad because it is hard to write a good VM.
Most of the bitching is about language features which exist. If you don't like auto_ptr then DON'T use auto_ptr! C++ at least allows you to ignore features without paying a penalty. Which is why it has a virtual keyword; and does not make every method virtual like Java.
The at() versus operator[] is also an example of the above: bounds checking can get expensive in a tight loop.
It seems that the author has never seen a large, well-written C++ project. In fact, that is the case with many such C++ bashers (I used to be one too). Once one sees how C++ makes it easy to manage a 500000 line project, they will probably think again.
I have a counter example (assuming I've understood you):
/* C /
int foo () { FILE x = fopen("bar"); return 0; }
/* C++ */ int foo () { ifstream in("bar"); return 0; }
Google does, for one thing.
Without discipline both C and C++ will blow you up completely. With some discipline both the languages are manageable, and C++ more so; which is what the OP points out.
Comparing C or C++ to Ruby or LISP is stupid.
The bitching about bad compile time errors has been mostly fixed in clang.
Then only _inconsistency_ (in the correct sense of the term) in C++ I am aware of is the unordered initialization of static objects. So if you have "class A { ... A () { } };" and have a "A foo;" declared somewhere with static linkage, it can be hard to pin down exactly _when_ that constructor will be called. It will be called before control is transferred to main, but you may want even finer control.
If you have noticed other inconsistencies I'd love to know.
For someone who does not know programming at all, I'd recommend SICP first. The text is dense, no doubt there; but, IMHO, not dense enough to deter reading.
Of course, I'm more of a "learn-it-the-hard-way" person; mileage may differ for more easygoing people.
A call-by-name untyped lambda calculus evaluator. I have no clue what to do with it.
I sleep 5 hours when I'm not working out and around 8 hours when I am; which means my sleeping hours are either [12 AM, 5 AM] or [10 AM, 6 AM].
That is exactly what I meant.
Bad programmers exist. They will write bad code, no matter what language they're made to use.
The purpose of this thread was merely to gauge what kind of paradigm shift people who were used to programming in C or C++ generally experience when they move to Python. Some people seem to find making the jump easier than others - I personally have found it difficult and have made little progress so far. Since I generally consider myself good with computers, I find this a little unnerving.
def foo (self, stream): What is stream here?
void foo (std::ostream &out) { out << "bar" << endl; }
Hope you get the point.
"Secondly I don't mean to criticize Java. By calling it a toy language, I was simply referring to the fact that Java tends to make writing bad code difficult, and in doing this takes away some of the flexibility and power that you tend to associate with other languages."
Judging from the general reaction it seems I should not have used the term "toy language". My apologies if I ended up implying that Java has little practical use.
Just an opinion, though.
for (i = 0; i < 1000; i++)
printf ("%d %d %d\n", i / 100, (i % 100) / 10, i % 10);
IMHO, such patterns (multiple nesting with empty outer loops), in most cases, are really an indication of just one real loop. Using multiple counters might also be an option.In case the loops are doing something different, they should be indented separately. For instance, the following makes little sense:
for (i = 0; i < 10; i++) {
foo (i);
for (j = 0; j < 10; j++) {
foo (i + j);
for (k = 0; k < 10; k++) {foo (i + j + k);
}
}
}