2 ms·
(defun gcd (a b) (if (= a b) a (gcd (abs (- a b)) (min a b)))) Declaring types makes it longer. There is not much an advantage for that type of code. Unless yo
by lispm 16y ago
(defun gcd (a b) (if (= a b) a (gcd (abs (- a b)) (min a b))))
Declaring types makes it longer. There is not much an advantage for that type of code. Unless you go to specific languages like J, where even the math code gets quite a bit shorter. But my personal goal is not to write the small stuff even smaller. My goal is to get rid of the larger structures and hide them.
The big win comes when one uses higher-order functions and macros in any non-trivial piece of software.
Imagine all the boilerplate code that one writes for class definitions can be hidden behind some macros. If one creates the code from domain data, you can get very dense code. Then all kinds of combinations of control structures can be hidden behind macros.
In large software systems Java developers were/are doing the same using XML files to describe the code and generate code from there.
- nadam 16y agoI definitely don't want to code in Java all my life. I am in the middle of a project, and I don't want to change language until it is finished. Fortunatelly there are languages which compile to the JVM, and I can use existing Java libraries from them. The only thing I want to figure out is performance. I need a language which is almost as fast as Java. I am planning to learn Scala, Clojure or something like that. If the performance will also be ok, I will probably change.