KINDLY REPLY HOW YOU LIKE IT

Programming Tutorials on different platforms

Any general and specialized interesting programming language training and exploration . Fun with knowledge .

Search This Blog

Friday, June 18, 2010

Java Is Too Academic

Occasionally you'll hear people praising Java because it's incredibly readable; there's only one way to do things; and other languages are too academic. But I have proof that they're wrong. After you view the code below I think you'll agree with me that with Java:
1. It's far too easy to write code that's illegible to most programmers.
2. There are far too many ways to do things.
3. It's far too academic.
I have reason to believe other popular languages like Ruby and Python allow this sort of thing, too. When will we finally stop inventing such academic languages and let real world working programmers get some real world work done?
The proof that Java is too academic and obscure? Right here: factorial using a fixed point operation in an applicative order lambda calculus. "Obscure" and "academic" don't even begin to describe this code*.
view plaincopy to clipboardprint?
1. public interface Lambda {
2. public Object apply(Object x);
3. }
4.
5. public class Factorial {
6. public static void main(String[] args) {
7. final int x = new Integer(args[0]);
8.
9. System.out.println(x + "! = " +
10. ((Lambda)(new Lambda() {
11. public Object apply(final Object f) {
12. return new Lambda() {
13. public Object apply(final Object x) {
14. return ((Lambda)f).apply(new Lambda(){
15. public Object apply(final Object y) {
16. return ((Lambda)((Lambda)x).apply(x)).apply(y);
17. }
18. });
19. }
20. }.apply(new Lambda() {
21. public Object apply(final Object x) {
22. return ((Lambda)f).apply(new Lambda(){
23. public Object apply(final Object y) {
24. return ((Lambda)((Lambda)x).apply(x)).apply(y);
25. }
26. });
27. }
28. });
29. }
30. }.apply(new Lambda(){
31. public Object apply(final Object f) {
32. return new Lambda() {
33. public Object apply(final Object x1) {
34. final int x = (Integer)x1;
35. return x == 0 ? 1 : x * (Integer)((Lambda)f).apply(x -1);
36. }
37. };
38. }
39. }))).apply(x));
40. }
41. }
* "Obscure" and "academic" may not begin to describe it, but "perverse" starts getting close

No comments:

Post a Comment