5 ms·
While I personally agree with teaching something other than Java, there is one big advantage of Java you have overlooked-- as the core language is so simple, bu
by CJefferson 13y ago
While I personally agree with teaching something other than Java, there is one big advantage of Java you have overlooked-- as the core language is so simple, bugs caused by incorrect use of the language tend to be "shallow" (bugs caused by algorithmic mistakes can still be very complex of course).
An easy example of this is compile-time errors -- the most complex compile time error you can get of Java tends to be nothing more than "mismatched bracket" or "incorrect function call", whereas even fairly simple Haskell code can produce very complex error messages, and ghci (for example) tends to make things worse rather than better.
Java isn't perfect and has been getting more complicated, boxing & generics for example, but still is not close to the pain one can create in a handfu of characters in Haskell (of course, C++ has the same problem, for different reasons).
Personally, I see Haskell as the C++ of functional language, and therefore would prefer not to teach either Haskell or C++ as a first language.
- Typhon 13y agoIf Haskell is the C++ of functional languages, what, in your opinion, is the C of functional languages ?
- scott_s 13y agoScheme.
- raverbashing 13y agoI want the Python of functional languages
- danieldk 13y agoExcept that Scala already is ;). Haskell pretty much sticks to functional programming and resisted adopting other paradigms (e.g. OO via O'Haskell). Scala, on the other hand seems to adopt as many paradigms as C++.
- michaelochurch 13y agoThe C of statically typed functional languages is OCaml.
- asdasf 13y agoWhich is more complicated and less expressive than haskell? That seems like a pretty bizarre choice.
- michaelochurch 13y agoWhen I used OCaml, I almost never used the object system. I didn't need it. The "full" OCaml is pretty complicated, but most of the libraries don't force the "O" on you. (That said, if you're going to use OCaml, you should use the Jane Street libraries, which are far better than the standard library.)
- asdasf 13y ago>When I used OCaml, I almost never used the object system. I didn't need it. Me neither, but it is still part of the language and adds a ton of complexity. Which makes the analogy of ocaml to C vs haskell to C++ quite poor. >The "full" OCaml is pretty complicated Precisely the point. The full C++ is pretty complicated too. The full haskell is far simpler than either. >That said, if you're going to use OCaml, you should use the Jane Street libraries They didn't exist when I used ocaml, and I would never go back to ocaml now.
- infruset 13y agoWhat do you mean, less expressive?
- lelf 13y ago> the most complex compile time error you can get of Java tends to be nothing more than "mismatched bracket" or "incorrect function call" … following with the NullPointerException in runtime
- RyanZAG 13y agoYou generally don't get these if you use @Nullable etc
- the_af 13y agoThat requires support external to the language, right? I haven't seen it widely used in the codebases I've worked on, and it adds additional verbosity to an already verbose language. It's yet another argument against Java as a first language. I've seen plenty of NullPointerExceptions in enterprisey Java to know you generally do get them. The horror... the horror...
- mattfenwick 13y agoI agree with the point, but the argument -- that by arbitrarily ignoring features you come up with a simple core language -- can be applied to Haskell (and pretty much any other language) as well. If you exclude typeclasses, extensions, and IO from Haskell, you get a very simple language. (I personally find the error messages easy to understand when avoiding those) Related: how GHC compiles Haskell code, including the "Core" language and lots of desugaring.
- asdasf 13y ago>Personally, I see Haskell as the C++ of functional language You should try it some day, it is absolutely nothing like your misconceptions.
- dded 13y agoHaskell is a relatively difficult language to try. Introductions and books almost seem to expect you to understand the syntax when you begin. And I/O is introduced late, which makes it hard to play around with.
- nbouscal 13y agoLearn You a Haskell is an excellent introductory text and I see no way in which it "expect[s] you to understand the syntax when you begin." It walks you through things very explicitly. Yes, IO is introduced late, but it is not necessary for playing around with the language. IO is only necessary for play in languages that don't have a REPL.
- asdasf 13y agoI think you are forgetting that everyone who uses haskell has obviously gone through the trying it stage. It is not that hard, I did it. I just had a couple of PHP programmers do it without any problems. LYAH assumes you know very little, and explains things very simply. It gets to IO plenty quick enough, and before that it is showing you how to play around in ghci where you don't need to care about IO.
- CJefferson 13y agoI have written quite a bit of Haskell, I'm not sure what you think is wrong with my belief. Also, I like C++ :) Both are fairly big complex languages with horrible error messages, horrible compile times (if you use template haskell in particular), with a whole bunch of gotchas you have to learn to get good performance (the haskell gotchas are very different, and often based around lazy evaluation / memory bloat). Both have sharp edges that come from being old languages which have evolved over time. However, both languages are good in practice for actually getting things done.
- tene 13y ago> An easy example of this is compile-time errors -- the most complex compile time error you can get of Java tends to be nothing more than "mismatched bracket" or "incorrect function call" So, you're saying it's a benefit that the Java compiler doesn't help you out with anything very meaningful? The "complex error messages" are one of the most significant benefits of using Haskell, for me, because it means that the compiler it helping me out with more than just trivial syntax matters.
- codygman 13y agoA substantial amount of the bad error messages are (were?) mostly from type classes. Helium[1] fixes that problem but not letting you use typeclasses: http://en.wikipedia.org/wiki/File:HintScreenshot.png http://en.wikipedia.org/wiki/File:HintScreenshot.png 1. http://en.wikipedia.org/wiki/Helium_%28Haskell%29 http://en.wikipedia.org/wiki/Helium_%28Haskell%29 (still alive?)