Live data from Hacker News

Elm from a Business Perspective

gizra.com

51–60 of 79 posts

Re: Elm from a Business Perspective

#51

Earlier quoted context omitted.

My major question is: how do you write reusable code without type classes? It's not really possible, as far as I can tell.

Well of course there are ways to write reusable code without type classes. But let's say for the sake of argument that that's really what you want. You can in fact implement ad-hoc polymorphism, or something very close to it, without type classes. Type classes can be seen as a way to implicitly add a set of values to scope, but this can be done explicitly by using a record type. Consider (I'm guessing at syntax, I do…

I'd like to refer you to the article that was posted earlier today on exactly this technique in Elm:

http://reasonablypolymorphic.com/blog/elm-is-wrong

Re: Elm from a Business Perspective

#52
post #47

Earlier quoted context omitted.

> Well, the burden of proof should be on the proposer: that the feature is useful. A good next step would be for someone who's interested in persuading you of the importance of typeclasses I agree! That would make for a much more straightforward discussion. :)

As an example, I see code all the time with many showX functions whose sole purpose is to turn come ADT into a string, this is the kind of boilerplate that would be reduced with some kind of abstraction mechanism. Same for map operations, fold, etc. Then there's other things that would benefit from further abstraction, like being able to compose apps or update functions without boilerplate. These are just a few examp…

Hi leshow, can you be more concrete? If I have a record

  `data Foo = Foo {fooA :: Text, fooB :: Text}`
then I must write a method `show :: Foo -> Text` for it. It is immaterial if I write

  `instance Show Foo where`
  `   show foo = (... implementation ...)`
or

  `shooFoo foo = (... implementation..)`
I save no code with typeclasses (at this point at least). (I do save code with the magic "deriving", but that's not part of the typesystem; it's just the compiler implicitly generating a bit of code for me.)

Likewise, map operations, fold. They need to be written and used.

I'm sceptical of Elm's claim that typeclasses aren't useful, but your post doesn't show what it sets out to, because it lacks concreteness.

Out of your post, it is only when you get to function composition that typeclasses can theoretically help — but the question isn't, can they theoretically help, it's do the help in practice.

So can you show some example? To meet the challenge and provide convincing evidence that a language without typeclasses is lacking, you would need to say "This is what the code is. And this is what it could be with typeclasses". Unless you do that, Noredink's claim that their code wouldn't be simplified with typeclasses stands.

I do not think you are obliged to do this. It is perfectly legitimate for you to ignore my message. But I think both sides can agree that this is what would be convincing to the anti-typeclassists.

Re: Elm from a Business Perspective

#53

Earlier quoted context omitted.

> Would also be nice to know how they deal with boilerplate, which is a big annoyance with Elm in my opinion when you come from, eg, Haskell. Elm certainly has a lot of boilerplate compared to Haskell, but that might not be a fair comparison as they don't really have a shared use case. Elm ends up with considerably less, in my opinion, than something like React/Redux.

> Elm certainly has a lot of boilerplate compared to Haskell This is not true based on my experiences with Elm and my knowledge of Haskell. Could you elaborate on why you are certain of this?

Instead of abstractly arguing over "writing generic code", here are some concrete examples I came up with when running down a random Haskell file:

* Thing.map :: (a -> b) -> Thing a -> Thing b instead of deriving Functor (or Applicative, Monad, Generic, ...)

* showThing :: Thing -> String, readThing :: String -> Maybe Thing instead of deriving Show/Read

* decodeThing :: Json.Value -> Maybe Thing, encodeThing :: Thing -> Json.Value instead of deriving From/ToJSON

* lenses definitions instead of makeLenses ''Type

* things like

    update (Event childEvent) model -> let (m, fx) = Child.update childEvent model.child in ({ model | child = m }, Fx.map Event fx)
instead of using lenses

* append :: (a -> a -> a) -> (b -> b -> b) -> (a, b) -> (a, b) -> (a, b) instead of reusing the Monoid instance on tuples

* toDyn :: (a -> TypeName) -> a -> Dynamic, fromDyn :: (a -> TypeName) -> Dynamic -> Maybe a instead of deriving Typeable

* things like type StateLogger st = { log :: [st], current :: st } and then writing StateLogger.map, StateLogger.return, StateLogger.andThen, StateLogger.modify, StateLogger.tell instead of just type StateLogger = WriterT [st] (State st) and getting all of that for free... not only that, but now you can use lenses for manipulating a deeply nested state as well, because guess what, Control.Lens.Zoom is written generically

And those are just the possible, but cumbersome things. There's stuff that's impossible to do:

* free monad custom DSLs

* GADT datatypes for typesafe request/response communication

* existential quantification in ADTs

Now this is very down-to-earth get-things-done Haskell code. All these things are there because they make the code simpler, easier to understand and eliminate repetition.

Re: Elm from a Business Perspective

#54

Earlier quoted context omitted.

There are many points to respond to here. 1. Evan (the Elm author) has pledged to support type-classes, it's on the issue tracker, and because he believes that they are useful. 2. "The academics" is a mischaracterization. I use Haskell and PureScript professionally and share the same problem of the "Elm is Wrong" author, which is that it's impossible to do any generic programming. 3. Generic programming is important…

And yet plenty of programmers somehow manage to ship perfectly good solutions to everyday problems without "generic programming" capabilities as you define them. The author of "Elm is Wrong" might have good intentions but the tone of that post is so condescending and inflammatory that all the points being made are lost. The title alone already starts everything on the wrong foot. Instead of sitting on such a high hor…

> And yet plenty of programmers somehow manage to ship perfectly good solutions to everyday problems without "generic programming" capabilities as you define them.

This is definitely true. The firmware on your phone is probably written in assembler.

> Instead of sitting on such a high horse the more constructive approach is to outline the shortcomings, implement the solution, and contribute it upstream.

You complain about sitting on high horses while the author did exactly that and got a high-horse response from Evan.

> Comparing a language that programmers use every day to ship working solutions to another one that has considerably smaller mindshare and community

Are you talking about PureScript? Judging by GitHub popularity I'd say both languages are about equal in that regard, but who knows.

Re: Elm from a Business Perspective

#55
post #54

Earlier quoted context omitted.

And yet plenty of programmers somehow manage to ship perfectly good solutions to everyday problems without "generic programming" capabilities as you define them. The author of "Elm is Wrong" might have good intentions but the tone of that post is so condescending and inflammatory that all the points being made are lost. The title alone already starts everything on the wrong foot. Instead of sitting on such a high hor…

> And yet plenty of programmers somehow manage to ship perfectly good solutions to everyday problems without "generic programming" capabilities as you define them. This is definitely true. The firmware on your phone is probably written in assembler. > Instead of sitting on such a high horse the more constructive approach is to outline the shortcomings, implement the solution, and contribute it upstream. You complain…

> Are you talking about PureScript? Judging by GitHub popularity I'd say both languages are about equal in that regard, but who knows.

I'm not talking about any language in particular. Just a generic observation about the pattern I've noticed across language communities. I'd much rather see less inflammatory rhetoric and more awesome stuff being made in whatever language people enjoy using so that the rest of us can see the technical design decisions and trade-offs involved. As I said in another comment programming languages are tools, they're not religions, so we should stop treating every little shortcoming as an affront to the one true way to write code and ship software.

Re: doing the right thing. I don't think he did. He didn't even bother looking into why the decision was made to take out a certain feature. He just assumed the decision was wrong because it made a certain design pattern he likes hard to emulate.

As I'm writing this I think I've spent too much time on explaining why the quality and approach of posts like "Elm is Wrong" is not the proper way to approach language design discourse. I'm sure it feels good to a certain segment of the population to point things out this way but to the rest of the community, especially other programmers that just do programming as a job all this drama seems quite childish and I think it again goes back to the point about programming languages being tools. When put in the proper context the drama is amateurish.

Re: Elm from a Business Perspective

#56
post #54

Earlier quoted context omitted.

> And yet plenty of programmers somehow manage to ship perfectly good solutions to everyday problems without "generic programming" capabilities as you define them. This is definitely true. The firmware on your phone is probably written in assembler. > Instead of sitting on such a high horse the more constructive approach is to outline the shortcomings, implement the solution, and contribute it upstream. You complain…

> Are you talking about PureScript? Judging by GitHub popularity I'd say both languages are about equal in that regard, but who knows. I'm not talking about any language in particular. Just a generic observation about the pattern I've noticed across language communities. I'd much rather see less inflammatory rhetoric and more awesome stuff being made in whatever language people enjoy using so that the rest of us can…

I agree the blog post wasn't professional, but there was none of that tone where it mattered, the Github issue.

I can see where his frustration stems from though, getting a response like "I don't want to unless you show me a use case" when clearly presented with a use case after spending weeks trying out someone's language can be infuriating. As I said, not very professional, but understandable imo.

Re: Elm from a Business Perspective

#57
post #49

Earlier quoted context omitted.

To be clear, I'm not saying it's not useful! No need to convince me of that. :) What I'm saying is that even useful features come with both benefits and drawbacks. For example, I think user-defined typeclasses would add significant complexity to the language and especially to the library ecosystem. I'm not saying "these are worthless ideas," I'm saying "these benefits wouldn't improve my life enough to justify the co…

Your claim was that Elm isn't boilerplate heavy, but without these types of abstractions, it is. Perhaps you can't see the benefit and you're happy writing 10 implementations of "show", but don't claim there is no boilerplate. For the record I don't care if it's typeclasses and I wouldn't want to see Elm turn into haskell. I'd just like some other type of mechanism for abstraction besides extracting to a function.

> Your claim was that Elm isn't boilerplate heavy, but without these types of abstractions, it is.

You seem very certain of this, so surely finding some real-world code examples to back it up should not be too difficult, yeah? :)

> Perhaps you can't see the benefit and you're happy writing 10 implementations of "show"

Like I said, I do see the benefit, but don't think it's worth the drawbacks.

Also, "deriving" saves you from writing "show" implementations, not typeclasses, so I'm not sure why you're bringing that up.

Re: Elm from a Business Perspective

#58
post #2

Well. Summary: "I have no idea about the technical criticism or type classes, but we use Elm and it works for us. It's easy, you are productive quickly (quicker than with React/Angular), it prevents bugs, devs like it, and so it saves us money." It's nice to hear that a company is able to utilize Elm effectively. It would be nice to know how big their 5 Elm projects "in various stages and different scale" are to judg…

> Would also be nice to know how they deal with boilerplate, which is a big annoyance with Elm in my opinion when you come from, eg, Haskell. We have over 55,000 lines of Elm code in production at http://noredink.com and it's now the majority of our front-end. Students use our site to answer millions of questions per day, and they've answered over 2 billion questions total. I think this qualifies us as a "big project…

Is that 55,000 lines of elm in a single large project or across all projects?

Re: Elm from a Business Perspective

#60

Earlier quoted context omitted.

JavaScript code is or can be extremely DRY. I have noticed this especially on a redux (inspired by Elm's architecture) codebase. The pitfall is that JavaScript is very unsafe and hard to read. I've worked with TypeScript too, and there I started to notice more repitition and boilerplate, although IMO It is very well worth the safety.

Javascript is dynamically typed though. And Typescript has generics or circumventing the type system with :any to enable reusability.

Exactly my point, dynamically typed means writing less boilerplate. At the cost of safeness and mantainability.

TypeScript's any is more for compatibility with js libs though.

Post reply on HN