5 ms·
I love Haskell and Java. From a high level they are my favorite languages for their respective paradigms, so I think most programmers should at least try to wr
by habosa 13y ago
I love Haskell and Java. From a high level they are my favorite languages for their respective paradigms, so I think most programmers should at least try to write a simple program in both.
That said, I think people are overreacting to Java as a CS 100-level language because of enterprise experiences.
I have written enterprise Java and I hate it, but I still love Java. Java EE is all beans and POJOs and XML and Swing and cruft and I want to burn it in a fire. But that's not Java, those are libraries.
Java is an excellent language to introduce someone to programming, because there is very little magic. Everything is explicit, due to the static typing and imperative nature. The computer (or JVM in this case) doesn't do anything that you don't tell it to do. That's easy for someone to grasp.
Additionally, Java makes it very easy to write readable, organized, and extensible programs even if they are verbose. Using classes, objects, methods, types, and all of that OOP stuff makes it easy to write modular programs where each piece of code does exactly one thing. In functional programming the intricacies of passing state and higher-level functions lead to a lot more spaghetti code for someone who has never programmed before.
Do I think that we should only teach Java? No, of course not. Do I think that it's still a great first language? Absolutely.
If I had control of a curriculum, I'd teach Java for half a semester and then Haskell for half of the semester. I think it's important to not introduce "more productive" dynamic languages like Ruby or Python until students have had to deal with concepts like types so that they can appreciate what Python and other dynamic languages are leaving out.
At Penn, where I go to school, the intro to CS class teaches OCaml in the first half and Java in the second. Unfortunately I think that so many people are struggling with writing code as a concept that they're too frustrated to appreciate the beauty of OCaml at first. Teaching it after something a little easier would make the advantages clearer.
- discreteevent 13y agoWe did half C/C++ and half Mathematica in parallel. For the project you needed to build a prototype in Mathematica and then implement it fully in C++ using a cross platform gui toolkit (Glockenspiel - this was quite some time ago). It seemed to work - for a functional language Mathematica was also fairly practical.
- dllthomas 13y agoIt's just my experience, but the people I know for whom Java was a genuinely first language seem to have a harder time than anyone else grokking pointers.
- habosa 13y agoThat's definitely true, but no functional language is going to help with that. Those are only farther from the metal. The only thing I think Java handicapped me with was understanding pass-by-reference or pass-by-value, but I figured it out when someone told me that Java is "pass by reference by value" meaning that in the method meth(Object obj) { ... } if you do obj.something() you are editing the original object, but obj = newObject won't change the original reference.
- dllthomas 13y agoI kind of think it's a problem (pedagogically) with Java's model specifically, not purely distance from the metal. I wouldn't be surprised if there were other high-level languages that caused similar trouble, but I also wouldn't be surprised if some did not.