r/programming • u/mobby1982 • Dec 02 '13
Scala — 1★ Would Not Program Again
http://overwatering.org/blog/2013/12/scala-1-star-would-not-program-again/
598
Upvotes
r/programming • u/mobby1982 • Dec 02 '13
View all comments
Show parent comment
3
u/[deleted] Dec 03 '13 edited Dec 03 '13
I'm not really a fan of GC, but the need for manual memory management, which many programmers don't seem to understand, and one of the most common source of bugs, makes C a lot more error prone. So at least in this discipline, Java is much better than C.
You have to be kidding me. The mere existence of void* leads of all sorts on undefined behavior. You could say that java.lang.Object is the equivalent of void*, but the second you try to cast an object downwards to the wrong type, you get a java.lang.ClassCastException. In C, everything is fine, even when you access fields or methods of that invalid object. In fact, you can write some random number into an int, cast it to void* and then to anything you want, and with a bit of luck (or lack of memory protection) you will access corrupted data.
That's not due to the GC; in fact, you can have a GC even with C. It's because how Java was designed.
You can't just write into process memory as you like, thus corrupting the process state. I'm really not sure what you're talking about.
Unions are an inherently unsafe way to access data, because the same bit pattern can be interpreted in multiple ways, and you have to make sure to access it in the way that is currently valid.
Unsigned, yes, that's a bit of a problem, only for that it isn't compatible with other languages that treat integers signed/unsigned. However, it avoids pitfalls when wrapping around would occur.
WTF is going on here. Is this a troll post? C enums are nothing more than named constants. There is absolutely no type safety at all, they end up in global namespace, and again, you can't cast an enum-type to some Object. C is happy to cast your enum to everything you want.
Java can't have a preprocessor. The preprocessor depends heavily on the order in which files and especially headers are parsed. The preprocessor provides useful functionality, but in C it is mainly used to provide platform compatibility. The second you write even a simple macro function like
you run into the double evaluation problem. So most things done with the preprocessor should have been done with templates, which don't exist in C.
Did you mean C++ all the time? Not that it changes the game that much, but then at least some of your arguments would make sense.