Andy, the same Andy mentioned in the article, wrote a blog post in 2014 with his perspective of what it's like to use Haskell in production, if you're interested. https://engineering.imvu.com/2014/03/24/what-its-like-to-use...
Andy, the same Andy mentioned in the article, wrote a blog post in 2014 with his perspective of what it's like to use Haskell in production, if you're interested. https://engineering.imvu.com/2014/03/24/what-its-like-to-use...
Question: what do you think of the thesis of pure4j [1] vis. frege [2]? Namely, are the advantages gained by switching to a haskell-like language far above those attained by simply forcing effects into a small part of the codebase?
I feel like some Java programmers would have almost as much culture shock with something like Haskell as some of the php programmers at IMVU apparently did.
That's all just my opinion, of course, and I hardly have enough industry experience to back up its validity! 'Just sanity checking my reasoning :)
[1]: https://github.com/Frege/frege/graphs/contributors
[2]: https://github.com/xclerc/ocamljava/graphs/contributors
Unlike Frege where I (might? Frege's the only language of the three that I haven't investigated thoroughly) can point learners to essentially any Haskell tutorial and have them vaguely do 'the right thing', there exists a subset of Scala developers who use the language like Java with type inference. With Frege I could, for example, merely enforce the minimal usage of IO or State, but doing so with Scala is more complicated (maybe force the usage of cats/scalaz and their equivalent monads? It's still very easy to not use them, however). If there were an equivalent to F# on the JVM I'd settle on it in a heartbeat, but the dearth of well supported, pure functional languages makes this a tough choice. All in all, I'll probably go with pure4j, but it would be nice to stop writing Java at some point in my career.
Yes, people can write Scala in 'Java style' or 'Haskell style' (not exactly), but I've come to think of that as a strength. Your colleagues can always start out near their comfort zone of imperative Java, and you can start out at yours, and you can slowly refactor your way towards each other. You can give Scala design talks to familiarise the team with best practices. With Haskell/Frege, you don't have that luxury. Everyone jumps in at the deep end.
About enforcing monad use: yes, it's possible to do that in Scala, but you're right that it has to be under the 'honour system'. About F#, it's not a pure functional language either. It's about as pure as OCaml and Scala.
As for pure4j, the reason I don't recommend it is that it makes it very clear that it's all in an experimental stage. So I have no idea which direction it's going.
Best of luck!
You're right, though; pure4j offers an immediate and easily obtainable win, so it'd definitely be an easier pill to swallow. Thanks :)
Also. There is work underway to enable GHC to compile for the JVM.
Immutable types happen to be something that is familiar and comfortable to Java developers. I would therefore expect to meet a lot less resistance to "syntactic sugar and immutable classes" than "functional programming with pure functions" even if the end result is 80 percent the same.
5 months in with Scala and it has been a wonderful experience. Now I just have to convince our front end dev to switch over to Scala.js...
It's much closer to Haskell's capabilities than pretty much any other functional language.
It has better type classes, the compiler just got type inference for partially applied type constructors, it supports programming with dependent types and implicit parameters allow you to let the compiler prove almost arbitrary things.
If your definition of FP means "purity", you pretty much discarded all languages traditionally considered to be functional.
There is nothing wrong with liking Haskell more than Scala, but I think your claims are not very well-founded.
Haskell and Scala win and lose on different criteria but for type classes, I find Haskell's syntax and semantics infinitely more elegant, more terse and more flexible than Scala's. Defining type classes in Scala is a cacophony of syntax boiler plate riddled with implicits and brackets. Haskell is much more elegant in that area.
Haskell's type classes are a mess because Haskell-the-spec (anti-modular, coherent) and Haskell-the-language (incoherent, "modular") work completely different and nobody cares and there us no real fix because both options suck, as soon as your project consists of more than one module.
It's the reason why no language after Haskell does type classes the Haskell way, and all of them do it similar to Scala's approach.
Could Scala have more syntax sugar? Sure! But people are more focused on getting them right first, before adding additional syntax.
That's a yuuuuge amount of languages that follow "Haskell"'s design! (Maybe you should start counting Haskell-to-X compilers separately to pad the number "1" a bit?)
That's just amazingly hypocritical, but I guess the tactic of "blame other people for your own behaviour to make it look like tu-quoque if they respond" hasn't gotten old for you yet?
Well enough, sir.
Idris – implicit arguments
Agda – instance arguments
OCaml – Modular implicits
:-)
I'm unaware of any such difference. Please explain.
While it's a very poor idea as no person except the author of the type class or the author of the data type can define a type class instance, it at least guarantees the global uniqueness and coherence of type class instances. ("There can only ever be a single typeclass instance for typeclass A and data type B.")
GHC (the only implementation that kind of matters today) takes a YOLO approach, allows as many typeclass instances as you want, doesn't bother enforcing the rules laid out in the spec. Additionally, as type class instances are not first-class values of the language a developer doesn't even have the option to make sure he is getting the instance he expects.
There exists a GHC warning for "orphan type class instances"–but as the warning triggers on everything, not only the relevant cases where multiple instances clash and break the program–it's as useful as saying "we made sure that C's goto-fail bug can never happen again by emitting a warning for every suspicions indentation – you only have to sift through 1732 warnings until you find the dangerous one!".
It's true that you can't safely define orphan instances in a library, but that also should involve no "sifting through" warnings for valid uses. It is genuinely bad practice to put orphan instances in a library, even if we had global checking - it would produce cases where you simply cannot use otherwise compatible libraries in the same project.
This might be true for the 90% of Haskell that is created and abandoned by PhDs writing their theses, but if you look at other language communities: People like to use a library from time to time.
Regarding your content:
You are making (or missing) a point I made above, and moving goal posts.
If you are writing a library that defines a new type and would like to provide an instance of some classes, there is no problem, those are not orphans.
If you are writing a library that defines a new class and would like to provide an instance for some types, there is no problem, those are not orphans.
If you are writing an application, the approach I suggested for the context of working on an application is entirely appropriate - you write orphan instances, and have a static check that they are coherent.
There is a bit more trouble if I am a library wanting to provide an instance of a class that I do not define, for a type that I do not define. Allowing orphan instances in this case, with or without a static check for coherence, assumes consumers of my library "have control over all code ever written" - it will either be dangerous (without a check) or forbidden (with a check) that they use my library with (potentially seemingly unrelated) libraries. The correct workaround is usually to provide a newtype, for which you can define non-orphan instances. This is not bad, but it certainly is a bit of a tradeoff.
But again, you moved the goal posts. I made no general claim about the suitability of Haskell's expectation of coherence. I objected to your false claim that maintaining coherence involves picking over spurious warnings about orphan instances. It does not.
I am obviously not a haskell person, or I would have just used haskell rather than trying scala first. I am not hurt about scala, it simply was much less productive than haskell.
Scala is not remotely the closest to haskell. Not even the closest JVM language.
And my "claims" are my personal experience, how can they not be "very well founded". You seem to be putting some emotional context into this that has nothing to do with me.
If you want real and well designed FP, pick Haskell.
If you want a pragmatic JVM language that doesn't make your eyes bleed like Java does, pick Kotlin.
I've been haskellin at a large Megacorp environment for the past 1.5 years, with lots of smaller freelance before that.
There's a lot of different value props one can make for different tools. One pragmatic case I make is that in Haskell land it's super easy and rewarding to to engage with upstream to resolve any problems I hit. One other angle that the imvu article and I think a lot of the comments over look is that using Haskell as a shared concrete specification / engineering design substrate for communicating actually makes it much much easier to collab with colleagues on pretty crazy projects. Even if the deployed system isn't ultimately written in Haskell.
That said, with the right colleagues, having the freedom / trust to choose tools that help you best deliver is always the ideal. :)
Cheers!
But it introduces monads very similarly to how he did it: starting with Arrays, drawing parallels to Maybes, then introducing Control.Monad.State through an assignment before moving on to IO. This has helped me a lot in grasping the concept behind monads.