Live data from Hacker News

Elm in Production: 25K Lines Later

charukiewi.cz

251–260 of 278 posts

Re: Elm in Production: 25K Lines Later

#251
post #247

Earlier quoted context omitted.

I agree that Elm is more strict at compile-time than TypeScript, there is no argument there. What I have a problem with is using an example where the programmer is lazy in TypeScript, then assuming the programmer is NOT lazy when coding in Elm. If you just print an empty error string and your app continues running assuming it decoded successfully, you can be in as bad a place as the app that crashed. Actually, in som…

The difference here, is that a lazy programmer, when forced to handle this particular case, would use "Debug.crash 'should not happen'", which causes the Elm application to crash at runtime. The TypeScript program doesn't force you to deal with it, so the lazy programmer can assume everything works, no exception is raised, and you're now running with invalid state. To catch this bug in TypeScript, you'd have to write…

> Elm, again, forces you to write runtime type validation

But it does not force you to handle failures correctly (as your lazy programmer example proves). Forcing you to handle a Left value from an Either type is not the same as forcing you to handle a Left value correctly.

Elm doesn't save you from bad failure handling, which is what the post I replied to claimed.

What Elm does do is remind you that you should handle failures, which I think is very valuable and I'm not arguing against (and is what you're arguing for). But you still need to write a correct handler, and Elm won't force you to do that!

Re: Elm in Production: 25K Lines Later

#252
Something I find incredibly off-putting about Elm is the evangelical and generally unbalanced tone taken by many prominent members of the Elm community. I almost never come across Elm advocates accepting a valid criticism of the language. The response almost always amounts to "you don't understand" or "yes, but". They spend a lot of time celebrating the compiler's humanistic virtues but seem less clearly humanist in their relation to original thinking or diversity of thought. So much of Elm community dialogue (in talks, in articles, in the Elm slack which I follow daily) is simply those with more experience initiating those with lesser experience into the "Elm way" of doing things. For this reason, Elm feels more like a framework with a domain specific language than a fully qualified programming language. And while it might seem like a gentle introduction to functional programming techniques, I'm not confidant that it really teaches people the concepts themselves nor gives them enough room to think critically about how to apply them. Instead, the task is to internalize and apply the "Elm way". The inability to even acknowledge the unprecedented labor required simply to parse a JSON response is a perfect example of the cultish mentality emerging in this community.

Re: Elm in Production: 25K Lines Later

#253

Something I find incredibly off-putting about Elm is the evangelical and generally unbalanced tone taken by many prominent members of the Elm community. I almost never come across Elm advocates accepting a valid criticism of the language. The response almost always amounts to "you don't understand" or "yes, but". They spend a lot of time celebrating the compiler's humanistic virtues but seem less clearly humanist in…

> less clearly humanist in their relation to original thinking or diversity of thought

So what you're frustrated with is that a group of likeminded individuals celebrates their common point of interest and doesn't make room for you to nay-say them?

> So much of Elm community dialogue (in talks, in articles, in the Elm slack which I follow daily) is simply those with more experience initiating those with lesser experience into the "Elm way" of doing things

This could be said of a lot of PL environments. How many Python tutorials stop midstride to browbeat you about how great Python's way of doing things is? Sure feels like a lot to me.

> The inability to even acknowledge the unprecedented labor required simply to parse a JSON response is a perfect example of the cultish mentality emerging in this community.

Right but... what do you want? Acknowledgement? My friend, literally everyone here is agreeing it's harder than JSON.parse. No one argues it is "easier." I can't find a handy example in this thread of anyone saying, "Yeah this is great." There are tools to ease this pain, and there are ways to call external JS code that does this.

At the end of the day though, validating data structures on the wire both structurally and for content is a lot of work. Most Javascript projects don't do it. Hell, most typescript projects just say, 'Well if it breaks it breaks.'.

By pure coincidence this redacted typescript snippet is up on my other screen:

    function validateTaskArgs(cdata: any, ldata: any): [boolean, IDomainObject1, IDomainObject2] {
        if (cdata === null || ldata === null) {
            return [false, null, null]
        }

        const cdkeys = ["key1", "key2", "key3"]
        const ldkeys = ["key1", "key2", "key3", "key4"]

        const checkKeys = (keyset: string[], obj: any) => {
            const result = keyset.reduce(
                (p, c) => { return p && !!obj[c]},
                true)
            return result
        }

        return [
            checkKeys(cdkeys, cdata) && checkKeys(ldkeys, ldata),
            cdata as IDomainObject1,
            ldata as IDomainObject2
        ]
    }
This ugly bit of custom logic just to validate a pair of objects in a larger json datastructure, and even that has bugs. This can't deal with a bunch of problems, but it's just too much pain to actually string together the logic in a composable way in typescript, so I accept this kind of drudgery.

But earlier I actually linked a much more sophisticated piece of purescript that's about the same size and not only is easier to read and is self-describing (the code to build the objects IS the spec), but it uses those properties to report console errors. You can see it here:

https://gist.github.com/KirinDave/9af0fc90d005164743198692f3...

If you want to make Elm better at JSON, that's the sort of stuff you wanna ask for. And folks will rightly be resistant. Because the programming concepts that make that work (free applicative, in this case) are not things the elm target audience has learned about, yet. Elm's leadership is acutely aware of how big a stack of new concepts they're putting on everyone's plate, and they're cautious about offering more.

Re: Elm in Production: 25K Lines Later

#254
post #233
post #161

Earlier quoted context omitted.

The only way I can think to relate them is (a) FP tends to highlight the importance of value-semantics over all others, (b) non-termination is an effect, (c) FP also, subsequent to a, tends to emphasize control of side effects, (d) in a terminating lambda calculus all evaluation strategies are confluent/equal under the value-semantics, thus (e) laziness is particularly _available_ in a FP language.

Attempt at translation from CS-speak: Laziness matters less in a FP language because if we consider non-termination an effect (impure), all pure functions should behave exactly the same regardless of whether they're "lazy" or not (plus in FP sameness is defined as same values, due to "value-semantics" - unlike OO where every object has a unique identity, different from all others) because in the absence of side-effec…

Ha, thank you.

Re: Elm in Production: 25K Lines Later

#255

Earlier quoted context omitted.

Ah. That derives both "ToJSON" and "FromJSON", as Aeson calls them. Cool!

Yeah, and it's actually more general than that: it describes how to serialize and deserialize them generally, so you could use, say, serde_json to get json, or serde_yaml to get yaml.

Huh, nice.

Re: Elm in Production: 25K Lines Later

#256
post #242
post #28

Earlier quoted context omitted.

I'll make an observation: I write C# for a living. The great thing about that is that it has a truly great debugger. But, as you rapidly discover, it's easier to debug some code than others. For one thing, you want to be able to go back to the start of the function and re-run it. That means that methods that mutate internal state are hard to debug. Also, it's even better if you can follow the chain of reasoning witho…

Dumb question: Have you tried IntelliTrace in VS Enterprise (sadly only available there)? It tries to solve many of the issues you're mentioning. You can even start a remote IntelliTrace debugging session in production.

Not a VS enterprise shop, sadly. Don't think I've ever worked for anyone prepared to pay for it! It does sound enormously cool. Does it also handle one of my favourite problems: when a method fails because a constructor parameter was wrong, it's pretty hard to rewind.

With that said, VS Pro still has one of the best debuggers on any platform. To the extent that I think C# developers sometimes cut corners because the debugger helps so much.

Re: Elm in Production: 25K Lines Later

#257
post #222

Earlier quoted context omitted.

Agree in general that Elm is nicer than Redux. However... >>> You don't have to transpile or add a linter, or a type checker, or stitch new libraries every few months because the trend changed. Elm is still in alpha, and is adding and removing breaking features all the time. (See ports for example) [1] >>> No webpack or babel or eslint or immutable.js or typescript or flow or any of those. If you are integrating elm…

> Elm is still in alpha, and is adding and removing breaking features all the time. Elm has had 2 releases since 2015 which had breaking changes. The elm-upgrade[0] tool has automated away a lot of the upgrade progress, and the compiler tells you about all the remaining things that need to change. Put another way, Elm doesn't actually change very often, and when it does, it is typically a smooth ride. (I've been arou…

[deleted]

Re: Elm in Production: 25K Lines Later

#258

Earlier quoted context omitted.

For an average JS developer Elm is totally alien tech compare to React or Angular To turn your argument the other way. The JS landscape, where "trendy" libraries change every few months, is also alien to anyone that doesn't keep with the latest libraries every few months. Is that not worse? I don't have to explain "JS fatigue", it's a fact. For example, I just got into a new team, and I have to now use what they use.…

Well sure, but as an architect/CTO I do not care about trendy, I care only about properly working, easy to develop and maintain and wildly used so I can hire for. Elm is none of these at the moment, but React is.

The most common stance on hiring Elm developers is to not look for people with experience with Elm (because there are relatively few) but people who are smart and willing to learn it. It is a different way than for hiring in other languages.

For example:

https://groups.google.com/forum/#!msg/elm-discuss/92dXqmB4nJ...

But this is common in niche languages. Most of my background is in Clojure, which has a vastly larger userbase than Elm, but it can still be very difficult to find good developers for it. Many of the professional Clojure developers I know learned the language on the job when they went to work for a company that used it. I wouldn't doubt it is similar with Elm. I saw a presentation once by a CTO of a company that started using Elm in production, and he mentioned that hiring is one of the larger risks to adopting it. But that shouldn't necessarily stop anyone, depends on a company's goals (and spirit).

Re: Elm in Production: 25K Lines Later

#260

Earlier quoted context omitted.

Can you not do the same thing as JSON.parse() in Elm by parsing into an unstructured JSON type?

Parsing into Json.Encode.Value gives you that Value but no way to work with it except, at later time, using Json.Decode.decodeValue on it. And you're back to specifying decoders...

Seems like you could easily make a library that just parses into some Union type that represents JSON values.

It's likely a design decision to force people that otherwise wouldn't to represent their data in a more structured way.

Post reply on HN