17 ms·
The Story of Haskell at IMVU
- chadaustin 10y agoHi! Author here. Let me know if you have any questions. 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-haskell/ https://engineering.imvu.com/2014/03/24/what-its-like-to-use...
- rakpol 10y agoHoping for a little advice: I'm trying to push for some development culture changes at work, one of which is doing more local, incremental refactors rather than large, all-at-once changes (i.e. the sort of thing for which one books 'architecture meetings'). Since we'll hopefully be massaging large parts of the codebase, there's an opportunity to jump into something new with both feet. 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? [1]: https://github.com/pure4j/pure4j https://github.com/pure4j/pure4j [2]: https://github.com/Frege/frege https://github.com/Frege/frege
- codygman 10y agoI can't speak for pure4j, but I would be very wary about suggesting Frege at my workplace to (what I'm assuming are) Java programmers. 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.
- rakpol 10y agoFair point, but it might almost be worth it just to suggest it just to see what the opposition is like -- if there isn't much, or any, go with Frege; otherwise, fall back to pure4j. I'd imagine framing the decision as picking from two choices would improve the odds of at least one being selected.
- pron 10y agoYou may want to consider http://www.ocamljava.org/ http://www.ocamljava.org/ instead of Frege.
- rakpol 10y agoThat definitely made the short list! I picked up ocaml for a side project and enjoyed the language quite a bit. However, ocamljava is either dead or dormant at this point (last commit to master in June of last year) and it seemed to only have had one major contributor -- it would seem irresponsible to adopt such a solution in light of that.
- pron 10y agoIn that case, it's almost as irresponsible to adopt Frege... It's not like it's got any real traction, either.
- rakpol 10y agoAah, fair point, it is pretty niche. Still, merely going off of their comparative contribution graphs [1] [2] and issue trackers [3] [4], it seems like Frege has a fair bit more throughput: for better or for worse, it seems like more _things_ are happening. Although I'll be the first to admit it's a misleading metric for determining the maturity of a project, it's still something. Imagine finding a bug in Frege: it seems like they merge even small patches from contributors, whereas ocamljava is essentially a one man show. Adopting ocamljava would probably mean forking and maintaining it too, whereas there's a possibility of just contributing to Frege. 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 https://github.com/Frege/frege/graphs/contributors [2]: https://github.com/xclerc/ocamljava/graphs/contributors https://github.com/xclerc/ocamljava/graphs/contributors [3]: https://github.com/Frege/frege/issues https://github.com/Frege/frege/issues [4]: https://github.com/xclerc/ocamljava/issues https://github.com/xclerc/ocamljava/issues
- 10y ago
- chadaustin 10y agoPersonally, I think you'll have more success with something more gradual than a complete syntactic overhaul. I've never used pure4j or frege but it sounds like pure4j is something you could try out incrementally, which could be quite immediately useful for your team. Best of luck!
- rakpol 10y agoThe idea behind both would be to introduce it incrementally, carving out parts of the codebase to be rewritten one section at a time. You're right, though; pure4j offers an immediate and easily obtainable win, so it'd definitely be an easier pill to swallow. Thanks :)
- Buttons840 10y agoScala is an obvious option as well. I haven't used Scala but it's surely more palatable to Haskellers than plain Java. Also. There is work underway to enable GHC to compile for the JVM.
- wtracy 10y agoTo expand on this suggestion: Scala isn't big on purity (AFAIK the language has no concept of pure functions out of the box) but it is big on immutable data types, and mostly-pure functions arise naturally when you're working with immutable types. 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.
- roflc0ptic 10y agoThis was the compromise our team made. Our team was having a bad time dealing with Spring. Our lead dev is a functional buff who really likes Haskell, and got us all hype about trying something new. We picked scala in lieu of Haskell because the learning curve with Haskell was a much harder sell. We avoid mutable data types unless there's a compelling reason (interop with Java libraries, for example), and most of our functions are implicitly pure. ScalaZ might have some purity constraint, idk. 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...
- MustardTiger 10y agoWe tried the same thing, but it did not go well at all. We picked scala because people should be able to learn it easier and more gradually. But we found as people learned FP using scala, they realized how much scala held them back. We ended up redoing a PHP project in scala, then as it was 80% done redoing it again in haskell. And then from there out using haskell for everything.
- 10y ago
- rjtobin 10y agoNot relevant to this particular blog post, but I just wanted to say thank you: one of your old projects, Sphere, had a big influence on me as a young programmer (in my early teens), and is a big part of why I got into programming. SCons is also awesome. I'm glad to see you are still doing cool stuff :)
- chadaustin 10y agoSuper cool! Glad I could help! Isn't it hilarious how almost everything you could do in Sphere is actually quite easy directly in browsers these days?
- rjtobin 10y agoHaha yeah. You might say that your choice of ECMAScript was prescient :)
- groovy2shoes 10y agoI toyed around with Sphere a bit, but RPG 6.5 was where it was at for me. I spent weeks poring over that code, and it was my first encounter with C++. I learned so much, especially from the implementation of the toolkit (tile editor, map editor, etc.). I never was able to compile it myself, though, as I didn't have access to a proper Borland C++ compiler for DOS, but that didn't matter so much as long as I could read the code and see the end result. Cheers!
- Bromskloss 10y agoI'd love to take your course on Haskell. :-)
- majewsky 10y agoI'm just learning Haskell through a university course. It's quite traditional in the author's nomenclature, with extensive discussion of laziness, currying and point-free notation. 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.
- cmrx64 10y agoGreat read. I love it when oral history in our field gets recorded. One of my great fears is that more interesting stories than not will be lost to time.
- wyager 10y agoGood read! We've had a few good "haskell in production" articles recently. Hopefully this encourages some folks to try it.
- mmbaghdad 10y agoNice read, you encouraged me to give haskell another round.
- douche 10y agoInteresting, especially about the cultural division and politics. Something to think about, since I'm thinking of swapping out some problematic C# code for F#. Pattern matching and a stronger, more expressive type system would be very nice. F# isn't as far off the reservation as Haskell, but I'm not sure how well throwing a monkey wrench, at the team will go.
- louthy 10y agoMoving from C# to F# is much less politically difficult than moving to Haskell. For a start the framework they're on is the same, and actually, you can write object oriented F# that looks almost the same as C# (not that I would advise that, I prefer to use the OO side of F# as a last resort). I'm the CTO at my place of work, and our primary app is C#. I wanted to tame some of the excesses of the language, and started looking at Haskell - I knocked up a few small projects with it; got it talking to the C# app through RabbitMQ, all happy days. But a few months later I came back to the projects to find they had rotted because of cabal. Some projects I found it next to impossible to recover. That left a pretty sour taste, which was gutting because I loved the language. Then I took a look at F#. It's not as impressive as Haskell as a language, but it really does sit in that sweet spot for 'fitting in' to a big project environment. I've found that creating satellite projects to our core app in F# has been the perfect way to go. It's moved the team into that mindset slowly without having to force the issue.
- douche 10y ago> I've found that creating satellite projects to our core app in F# has been the perfect way to go Can you elaborate on how that is laid out? I've identified some existing C# code in various of our current projects that could benefit from conversion to F#, but I'm not sure how the resulting projects should be structured.
- louthy 10y agoSome things are just projects in the main VS solution. So for example I wanted to create a document search system. So I created an F# project in the main solution, brought in Lucene.NET from nuget. Half an hour later, done. You can call the functions in F# directly from C#. There are sometimes some type interop issues to deal with, but mostly it's painless. Other projects are separate microservices that talk to our main app through my messaging framework [1]. It's an actor-model that I built a C# and F# API for, and they communicate via Redis. But tbh you can use anything you like: make it RESTful, use WebServices, RabbitMQ, etc. The great thing is you have access to the same libraries on both languages. If you're thinking of refactoring existing projects then you could go the mechanical route of just converting classes like-for-like. But you miss out on some of the amazing type system benefits of F# if you do that. What I tend to do is design all of the types first, as records or discriminated unions. A bit like if you were doing a DB related project you might spend some time designing the schema first, thinking about how the data should be laid out. With ADTs you can design the states of your application, whatever it is, and then you write the functions that transform those states in a referentially transparent way. Then you book-end your lovely functional code with the IO. This whole process is much simpler when you start with smaller services; so if you've found sections of your existing app that you want to break out, then that's perfect. By the way, if you want some of the functional niceness in C# too, then check my library below. It was built with your situation in mind (because it's mine too). It also has some utility functions for F#/C# interop. [1] https://github.com/louthy/language-ext https://github.com/louthy/language-ext
- ayberkt 10y agoIt makes me sad how people think imperative programming is a "natural" way to think. I have known lots of people who resist using functional languages for serious projects, marginalizing the "functional" way of thinking as though thinking in terms of "labeled boxes with data in them" (Von Neumann architecture) is some sort of more normal way to think. Before computers people modeled the real world using a Haskell-like pseudocode called "mathematics".
- douche 10y agoOr a imperative-esque pseudocode called "instructions" or "recipes". Claiming primacy for mathematical modeling is not a priori the answer.
- ayberkt 10y agoThe recipe analogy is certainly very natural, but it does not extend as we get into things like assignments and references, which are a crucial part of Von Neumann languages (which is really the thing I am criticizing). Tactic languages in theorem provers like Coq are stateful too: you have a proof state and you keep giving instructions for it to change. I wouldn't say that this is an unnatural way to think; for that subtask of the problem, we can view the proof as something with state without any problems. "Mathematical modeling" sounds too sophisticated to be natural for humans. Let me illustrate what I meant; the kind of naturality I was talking about is this: sorted(xs): a permutation xs' of xs such that, as we traverse xs' each element is greater than or equal to the previous one. This is a perfectly fine sorting algorithm. It contains all the information we need to sort a list of comparable things, and it is very unlikely to contain an error; it is the _definition_ of sorting. There are righteous performance concerns about this but ignoring all performance issues this is still more natural than listing out the steps needed to carry out the task of sorting. I don't think it is possible come up with a simpler recipe-like algorithm for this task. There are recipe-like tasks in programming: ones that don't involve modeling the world; for those the functional paradigm would not be a good one. But these are rare if you are doing programming the right way.
- 10y ago
- kmiroslav 10y agoIt's refreshing and uncommon to see someone who sees value in PHP, Java and Haskell at the same time. Nice to see open mindedness about languages for a change.
- MustardTiger 10y agoWhere are you seeing that? "PHP was not usable" doesn't sound like seeing value in it.
- yawaramin 10y agoThe value was it came with less drama among his colleagues.
- MustardTiger 10y agoThat isn't seeing value in PHP. That is stating that he values things other than language enough to use something he finds terrible.
- todd8 10y agoI like Haskell, perhaps because of my strong mathematics background. My dilemma is should I spend more time developing my Haskell skills or should I spend some time with the new C++ features, or learning Rust, or just programming in the languages that I am already productive in? When I assess a programming language, one of the questions I ask myself is "How will this programming language help me write correct programs?" In more detail I want a language that helps with four goals related to the ability to produce programs that achieve their specifications: (1) Partial correctness: the program doesn't give wrong answers (2) Total correctness: the program does (1) and doesn't deadlock or get stuck in an infinite loop. It eventually produces a correct answer. (3) The program does (2) within the desired performance bounds specified. (4) The program does (3) while making efficient use of hardware. Haskell definitely helps with (1). Reasoning about the partial correctness of Haskell programs is easier than it is with imperative programming languages. Total correctness is very hard, especially with multi-thread, multi-process, or multi processor programs, but I think that Haskell is helpful here as well. The real problem is that Haskell makes (3) and (4) very difficult to understand. Some of this is that compilers for functional programming languages are magic, making it hard to reason about what they are doing. This is further aggravated by Haskell's non-strictness. A discouraging look at Haskell: "Why Is Haskell Used So Little In The Industry"[1] and "Disadvantages of Purely Functional Programming"[2] [1] http://flyingfrogblog.blogspot.co.uk/2010/05/why-is-haskell-used-so-little-in.html http://flyingfrogblog.blogspot.co.uk/2010/05/why-is-haskell-... [2] http://flyingfrogblog.blogspot.co.uk/2016/05/disadvantages-of-purely-functional.html http://flyingfrogblog.blogspot.co.uk/2016/05/disadvantages-o...
- seagreen 10y agoCiting Credit Suisse and Standard Chartered is just name-dropping big banks in the hope that it will deceive people into thinking that these institutes are seriously invested in Haskell. They are not. Lol, Standard Chartered is hiring like 30 haskellers _this year_, and I'm pretty sure they were heavily invested in Haskell in 2010. That writer of that article has an axe to grind, and is twisting facts to suit it.
- seagreen 10y ago
- dhab 10y agoI have programmed in Java for some time now, and I have only recently dabbled in the functional world (Haskell, and still ways to go before getting any better in it). My observations about it is that functional programming in typed and immutable world, provide better composability, reusability, terseness and maintainability. It does have it's drawbacks - Haskell is known to be difficult for estimating complexity, and i think it lags in many benchmarks. I think OO can be thought of as an extension of functional programming, except it has some fancy names and idioms (single responsibility principle, polymorphism, abstractions ... ), but in the end are incarnations of functions. For example, int String.length(){..} could be thought of as length(char[]):int function, and List.size() as length(List):int. Node Tree.next(DepthFirstStrategy) could be thought of as traverse(Tree, traversalFunction):Node. But because OO languages tend to be mutable, they lose the benefits of the FP world. However, because they are mutable, they tend to perform better in benchmarks. I think OOP implemented in an immutable language would be over-engineered FP, whereas OOP implemented in mutable language is just glorified imperative programming. With my experience so far learning functional programming, I think it is a better tool: All the things you can do in OO world, you can also do in FP world, mostly better. When performance is of real concern, then those bits could be factored out into some imperative code - whether it's done in OOP or assembly, C is a matter of choice. In other words, I think in the order of technology preferences, FP should be prioritized higher than others although there seems to be a steeper learning curve. I think FP is not getting the attention it deserves as a better tool.
- SkyMarshal 10y agoSo Haskell got you all of the following: * GHC’s support for safe concurrent programming is world-class * Sound type safety led to refactoring being a breeze * Fun, stretches the mind (for some people) * Perfectly reliable unit tests. * Concurrent batched IO. * Abstractions for things like timeouts and running tasks on other threads while correctly bubbling failures. * Fantastic support for safely encoding and decoding JSON. * One of the best benchmarking tools I’ve ever used. And the complaints amounted to: * Devs have to think more about which String representation to use * Devs have to think more about syntactical differences from the more familiar C-derived languages * The team has to support more backend platforms, duplicate infrastructure * Not a mainstream language (harder to learn, hire for, bus factor) * “at this stage in my career I don’t want another programming language” 75% were for and 25% were against. Frankly the only complaints worthy of serious response were infrastructure duplication and hiring/skill development/bus factor. The rest are people just being close-minded and lazy.