Hacker News new | comments | show | ask | jobs | submit login

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.




In 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.


But 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...


There are other methods on Integer and such - it was a contrived example because I was too lazy to read the docs.




Applications are open for YC Winter 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: