The key finding here is that Java is mostly garbage. JavaScript while not as succinct as Clojure would have produced a similar saving.
The key finding here is that Java is mostly garbage. JavaScript while not as succinct as Clojure would have produced a similar saving.
As would Python. But the particular task, manipulating JSON, is one that Java is poor at compared to dynamic languages. Java doesn’t have native dicts and lists, so you have to work with a DOM type of representation rather than native structures; thus, complexity explosion.
LikeLike
Also, I believe you can write succinct java, but it’s non-idiomatic. You won’t be allowed in the secret java council meetings any more. Basically, it’s got a broken programming culture.
LikeLike
Emlyn O’Regan I have found that the best way to write succinct Java is to put everything into private functions, with shared state as private variables, and then create a few public contructors to use as entry points and a few getters to retrieve the state variables.
Avoid using classes to define data types or wrappers around data types, and rely on type casting as much as possible. Only define new classes or interfaces if there is no way to avoid it, and if you must, make it a public sub-class of the class where it is used.
Think of the constructor as performing the same function as invoking a shell script, where your shell script is the set of all of the private functions. A constructor should only accept input parameters and invoke the “script” (private function entry point).
I once did a pre-job-interview programming test this way. The program was a single file and did exactly what it was supposed to do on the test inputs. But I never got a call back from them for an in-person interview.
LikeLike