On Tue, Jul 13, 2010 at 06:29, Oscar Hsieh <zen...@gmail.com> wrote: > Well, someone need to balance the force ... so let me take on the other > side.
Thanks, I already somehow got the impression being quite the only person here that sees some of the currently hyped (real programming) languages and paradigms from a more critical point of view. > 1. function language syntax look too much like mathematical equations, and > most people dont like math. Comparing the following code > erlang: [X + 1 || X <- L]. > java: for(X : List1) List2.add(X+1); > You can argue but I think most people will find the 2nd code fragment > easier to understand. Of course. I remember school time where one of my collegues' sport when we did C++ was to write things as one-liners, that others wrote in ten lines. He was very smart but the problem is: The code should be readable by as many people as possible. If just the 5 smartest people of the world are understanding it, then you have to pay those smart people to maintain the code which is expensive. > 2. Pure function language such as Erlang does not have loop (for, while > ...). Instead, you have to use recursion. For average > Joe, recursion is hard. Recursion is often a smart - often even the easier method to solve a programming problem, but it also creates a huge stack. I had cases where I ran out of memory because the recursive solution was consuming up the memory. The non-recursional solutions can be harder to code but less resource hungry at runtime. > 3. Yes function language code tend to be concise, but sometimes people tend > to be tooooo concise. I have seem lots Erlang code > with single character function name and parameter f(X, Y) #...@%$@#%. Oh man, yes, you make me remember things that were deeply burried in the last corners of my brain... To find the shortest meaningful name was a challenge. But I think that helped me when trying - before exams - to put as most information as possible into my TI-74 with it's 8KB RAM only. ;-) > Yes you can also write bad code in Java, but thanks to its > chattiness, people tend not to write short class/function/parameter name. In practice IDE's are doing autocompletion and NetBeans either does (quite good) parameter guessing so even very long variable names are not really an issue these days. Reading a long functional expression on the other hand with longer function and variable names (still) is. BTW: I met people arguing e.g. the much of code to write for example for "MyCoolClass myCoolClass = new MyCoolClass();" NetBeans offers the code templates feature where you just write "newo" and type tab. While typing "MyCoolClass" it automagically writes that also in parallel after the new keyword. So the amount of writing can be really reduced which means: You do not really need to write so much code and still get the readability - thanks to modern IDEs. And the same people then still argue why the hack writing this two times, but hey, there are cases where you write "MyCoolClass myCoolClass = new MyMoreSpecificCoolClass();" - so makes sense not rationalize, isn't it? > 4. Function language are stateless and immutable. Although that is very > good thing but can be challenging for new developer. Immutability (in the meaning of the word) etc is also a topic to learn in Java and can be done with plane Java also, if you just want immutable objects. Of course there is an implementation difference and for the functional approach it's by design immutable. And: There are plenty of use cases where mutability makes much sense - and of course then it can be challenging - for the new developer and either for the experienced one. > 5. Tooling. One thing I hate about coding Erlang is error message that does > not tell you anything, and the lousy debugger. After using java and eclipse > for so many years it is like going back to stone age. I feel that for designing web applications - the NetBeans already had the visual designer for JSF and dropped the support for it in 3.8 - I hope it will be back (even if it had flaws it is better than nothing). Although the Java debugger is already very good, I still miss the feature from the VB debugger that I could completely change the code and set the execution point to whereever I wanted during run of the program. I miss in particular the option to set the execution point e.g. back to the beginning of a loop or so. > Recently I have a new job. Although interview was all about Java, I was > asked to work on Erlang and MongoDB. > (It is partially my fault since I mention I was learning Scala :), but I > think they also have problem finding people know or > willing to learn function language. I guess they don't expect anyone have experience with those so they even don't ask to avoid fear. > Personally I think everyone should at least take a look at > functional language since it allows you to see programming > from a totally different perspective. Yes, of course. However, some people want to talk me into trying some new stuff to learn the new perspective although I already have - even if it is very old nearly forgotten experience. Anyway there were reasons (basically those you mentioned) why I decided not to remain with those languages. > However, I think it is silly to > choose language mainly based on how functional it is or > how much less boiler plate you have to write. Yes, focus should be considerations like (in no particular order): - Interoperability with other stuff - ease of use and learn (it is needed that it is easy for new developers to get on board) - stability and continuity of the language - bug resistance (yes, with some languages it is easier to write buggy code) - tools (of course) - ... > As far as I see functional > languages are still too nerdy for most people and > probably remain mostly in telecoms and those of googles and amazons. Scala, > being the hybrid and seems to get the best of > both worlds, might finally bring both worlds together, at least we can hope Having both options in Scala maybe increases the options on how you could write bad code. ;-) However, I learned here in this group that the functional approach makes sense for parallel programming in the way that it avoids thread overlapping issues by the constraint of immutability for example. And Scala for sure is good stuff - I read performance tests where it ranged closely behind C++ being even faster than Java. Anyway, although there is a lot of good new stuff, I do see people expecting those stuff to be the overall solution for all problems - even for the hunger in the 3rd world... -- Martin Wildam -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to javapo...@googlegroups.com. To unsubscribe from this group, send email to javaposse+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.