4 ms·
It says: "In my Eiffel days, I was encouraged to write "integer", not "int", "character", not "char", and so on. I believe Java encourages this practice too."
by nadam 16y ago
It says:
"In my Eiffel days, I was encouraged to write "integer", not "int", "character", not "char", and so on. I believe Java encourages this practice too."
1. No Java uses char, int, and so on.
2. No, C is absolutely not concise even compared to Java. At least how I write Java code.
Look at this Java method:
String strangeConcat(String str1, String str2) {
return str1.substring(0, str1.length() - 1) + str2.substring(1, str2.length());
}
Is it really more concise in C? How do you tell the caller to free the memory of the returned string?
And if you compare C to Ruby, Python, Scala, Clojure etc... then it is no question that C is not a concise language for most tasks.
- ElliotH 16y agoIn Java int and char are primitive types. They don't provide methods so: int i = 4; i.toString(); //Exception - int isn't a class, so i isn't an object, so you can't call its methods. Integer j = 4; j.toString(); //Returns "4" as a string, because Integer is a class. Java would 'encourage' the latter practice at times because its useful to be able to call methods off of characters and integers and such, but there is a difference.
- msg 16y agoBut you wouldn't do this in Java (need a random string for an integer). Instead you might see: logger.fatal( String.format("Program crashed on index %d: %s", i, message) ); I think C has a similar construct, not quite as verbose, that would save 7 characters out of the line...
- ElliotH 16y agoThere are other methods on Integer and such - it was a contrived example because I was too lazy to read the docs.