by shakna · 9y ago · 0 comments
This is odd thinking. Everyone hates the current JSON Decoders. That suggests that there is something wrong with them, not that the audience should simply "get used to them".
If Elm could open up and allow developers to experiment with other architectures, like pretty much every other language, and not be so restrictive in forcing everyone into the exact same pattern, I think it would be very successful, because the language itself is nice. If someone wants to use Elm as it currently is, that should be one simple option available to everyone. But you should be able to easily discard that if you want to, and do other things, including making a choice on the trade-offs for JavaScript interaction. Languages that don't give developers much choice in how they are used are usually not going to be very successful.
I've had the opposite experience. From what I've seen, Elm's development culture requires hearing outside ideas and experiences, to a greater degree than I've seen in any other programming language community.
Many design discussions get blocked on Evan saying "We need to research what's out there more before we can proceed. What do other languages do? Which approaches have people liked and disliked? What are the trade-offs of each approach?"
It slows down development, for sure, but I think it's worth it. :)
The "our way is the right way" mentality
that is common in the Elm community is
really the larger issue here, and it has
been a bit of a turn off for me.
This is exactly how I felt as well.I really enjoyed Elm in the beginning but soon hit the abstraction wall as the complexity of my apps grew. I never got the impression that the Elm community was going to fix those problems any time soon. I now use PureScript which is far more pleasant to use, albeit it took a while to get up to speed with the language.
Also I'm not the only one who went to PureScript from Elm: https://youtu.be/ngWo5e-294o?t=19m14s
It's natural for people to have language preferences, but let's not pretend there's some spooky "abstraction wall" prohibiting a nice experience at scale. ;)
1) The experiences you've personally had do not capture all problems that everyone has, and to assume you've seen it all is pretentious at best. You are quick to dismiss the very idea that anyone would find limitations in the language or its architecture, without even knowing the details of the myriad other projects out there; sorry, that is just naive or arrogant.
2) I've noticed that on nearly any forum, you like to brag about the size of your... codebase. The quality of a project and the problems it has solved are not revealed in quantity of lines. It doesn't matter if you have 100K or now you say 150K lines of code. I have no idea what problems you are solving, nor you us; so stop hiding behind a nice round number and claiming it gives you all manner of authority on what developers need.
> let's not pretend there's some spooky "abstraction wall"
Honestly, it's comments like this that underscore what many others here have said about the general stance in the Elm community. How about actually listening to people's experiences rather than dismissing them? You can't end your comments with little emojis and pretend it washes over the general brush-off you are presenting.
javascript already lets you do whatever you want, whenever you want. evan's goal isn't to be 'javascript with different keywords'; he wants to create something with a specific set of properties.
a language doesn't need to be all things to all people. runtime guarantees are a core part of elm's identity. if you want to introduce null and undefined, there are plenty of other options.
Come say hi on Slack! People there will help you judge if Elm is for you. If it's not, that's a shame. If it is, great!
Go chose tabs over spaces which are configurable in your editor, so everyone wins. Elm has other awkward style choices, like 'comma-first', and excessive line-breaks in-and-around statements. If they had less obnoxious defaults, people might be less bothered about this issue.
And honestly, as a dev you work at a company for what, 3 months minimum. How hard is it to setup a .eslint file, vs. having to always write code in a style you don't enjoy.
Universal consistency of code format just isn't that important, consistency within a team or company is what matters, and you don't lose that by allowing configuration.
I'm sure one reason so many people have particular trouble with them is because, according to the survey, the vast majority of them come from a dynamically-typed language where you'd just go `user = JSON.parse(string)`.
I think a lot of people would be helped by tacking a bunch of real-world examples onto the actual Json.Decoder docs like how to decode `[1, [3, 5], 7, 9]` (nested range) into `[1, 3, 4, 5, 7, 9]`. One issue is that it's pretty hard to derive understanding from just function signatures, so a dozen quick-start / cookbook examples gives people something to chew on.
Combinators are really good at forbidding runtime errors which is a central theme of Elm, but it comes at the expense of a steeper learning curve than the weaker alternatives that come to mind: reflection and manual descent.
> I'm sure one reason so many people have particular trouble
Those two sentences don't really fit together. Elm isn't an academic experiment, which means people need to use it.
If the vast majority of people find it overly difficult, then it probably is.
> come from a dynamically-typed language where you'd just go `user = JSON.parse(string)`
Not just dynamic languages.
Haskell, one of Elm's inspirations, can handle it a hell of a lot easier.
Define an interface, then use it on a string:
data Coord = Coord { x :: Double, y :: Double }
deriving (Show, Generic)
let req = decode "{\"x\":3.0,\"y\":-1.0}" :: Maybe Coord
I am cheating a bit, as that's the aeson package... But decoding the JSON is a lot simpler than the Elm equivalent, and Haskell doesn't even target web browsers, where JSON is so prevalent.But, here's another static example, this time, C++.
auto j3 = json::parse("{ \"happy\": true, \"pi\": 3.141 }");
You can use auto to avoid writing a massive type definition, or you can write it ensure it's correct.Static typing has nothing to do with not being able to write JSON.parse(string), because it doesn't prevent that. At all.
If that's your view then Elm's approach is a plus for the language since it eliminates a potential pitfall.
Can anyone further substantiate this argument, I feel like it's not very strong as is.
Your example would lead us to believe that nobody is writing custom decoders in Haskell that look like Elm's decoders, and that's... very misleading.
Luckily there's a whole range of tools dedicated to making your life there a bit easier:
- json-to-elm http://json2elm.com
- swagger-elm https://github.com/ahultgren/swagger-elm/
- elm-graphql https://github.com/jahewson/elm-graphql, https://github.com/jamesmacaulay/elm-graphql
- elm-export https://hackage.haskell.org/package/elm-export
And so on :) While it would be nice to solve Json Decoders in a better way, these solutions are very helpful for the time being. Long term, I personally believe the right route is hard to decide on. We could go with json-decoders being part of the language and compiler itself. We could generate decoders from type aliases. Or some template solution like template Haskell. Or tagged unions like Go. The issue is that decoders are not a blocker to people who write a lot of Elm. They make me sad, but they're not a blocker. That means that the solution is not such a high priority.
Yes, and I was simply pointing out that, that is not helpful thinking.
JSON is fundamental to working with the web, and Elm works on the web.
A high learning curve on something fundamental is fine in languages that are academic in nature, intentionally obtuse, or designed to be difficult. It's not fine in a language intended for production use.
This post was about a language survey.
It says that JSON decoders are too hard for the audience.
A helpful step forward, is seeing how to make them less obtuse. An unhelpful step backward, is tell everyone just deal with it.
We'll see which step Elm takes in the coming months.