Your code will produce runtime errors which will be rendered into console with ReasonML runtime guts in it. I would disagree that this is in any way superior to Elm's promise of no runtime errors, and JS via ports having no runtime in its errors.
That is why I use Elm, and not some other compile-to-JS language that allows me more freedom.
I don't want freedom. I want constraints.
Freedom is the rope with which I can hang myself.
Constraints keep my bug tracker silent.
> Freedom is the rope with which I can hang myself.
If you'd like to, why not? It's up to you. You're not forced to do, though.
On the other side, being a hostage of some secret plans in "people in power" minds, you might be forced to do any kind of staff. New constraints are here and they're enforced on anyone. That's a catch with constraints, you can be OK with existing, but you'll never know what comes tomorrow.
Well, yeah. If I'd like to hang myself, I'd pick a technology with fewer correctness guarantees. As it turns out, that's not what I want. This is self-evident.
It's also not a valid criticism for you to say that you've found Elm doesn't "follow the common sense". This is too vague to be any kind of constructive criticism.
That's exactly what I'm talking about. I'd also like to pick up some "silver bullet", like Elm(if I got you right), for any new project.
Unfortunately, real world is usually a little bit more complicated than "I'm free to pick up any technology that I want. All browsers are the same, their behavior is consistent, mobile web is pure joy and all of our users know their plugins might cause an issue to our app, therefore they're disabling them when they launch our app".
Anybody who does webdev knows that. Different projects, different requirements(sometimes very, very strange), brand new requirements right before the release, deadlines, etc. There're lots of things you have to deal with to end up with a good website\app. Picking a language with nice "correctness guarantees", is not going to help you much.
There were times, long time before 0.19, when there were at least discussions on effect managers, extending the type system, native modules were a nice escape hatch to fix your problem at hand with nasty browser bug or even Elm runtime issue. Those were times when I was so excited to use Elm, did some tiny (sub)projects in it, did a workshop at the office.
Since then, many things have changed to the worse, imho. Some features were removed, not even deprecated. No public discussions, no roadmap, no bugfix releases, no escape hatches for special cases. But who cares what some random guy on the internets thinks :)
Don't get me wrong, I think Elm is a great experiment in the land of static languages, lots of great stuff is getting into mainstream languages(like Elm architecture, error msgs). I still hope we'll see the 1.0 version and things might get better in terms of feature stability, feedback and building things a little bit more complex than counter apps without hitting even more pain points than we have with modern JS\TS.
Nothing is a silver bullet. Never claimed it was.
> Anybody who does webdev knows that.
I am a web developer, and I disagree with you.
> Picking a language with nice "correctness guarantees", is not going to help you much.
That hasn't been my experience.
> Since then, many things have changed to the worse, imho
Exactly — it's your opinion. Removing surface area for runtime areas is a change for the better, in my opinion.
> building things a little bit more complex than counter apps
My businesses are more complex than counter apps.
Try `Math.random()` and `window.confirm` instead, or much more relevant: `document.getElementById`.
You can run absolutely any JS code, just through the ports API. Trivial things like Math.PI are in the core[1] or some package.
[1] https://package.elm-lang.org/packages/elm-lang/core/5.1.1/Ba...
This confirms my belief that most criticisms of Elm are emotional responses, not rational ones.
Allowing arbitrary JS functions to be called from wherever would indeed break everything. Want to use `Math.random()`? Whoops! There goes referential transparency. Want to use `document.querySelector()`? Hello runtime errors my old friend. Want to use `function(x) { return x / 0; }`?
Yeah, have fun with that. I'll stay in North Korea ¯\_(ツ)_/¯
Everyone’s relationship to their tools of choice has an emotional component. Check out this talk, you might find it interesting:
“The Pervert’s Guide To Programming Languages” https://youtu.be/mZyvIHYn2zk
You can't get those in Elm.
It might make sense for other people. It doesn’t add up for me.
It’s intellectually dishonest to point to implementation bugs as fundamental flaws.
After a couple of years running in production, my opinion is that it is well-made generally.
Finding clever ways to break a technology isn’t a fair reflection of “real world” use, in my opinion.
Imagine my shock................
tail : List a -> Maybe (List a)
Nice try though.You're thinking of the partial functions from Haskell's Prelude.
You must be doing something wrong than. :)
The world is impure. Pretending it is not is just laughable. I am saying this and I am actually writing only functional code for living, but I understand when I cannot solve the problem with functional concepts.
Few example:
- now()
- random()
- runSqlQuery()
- open a file
My code might be 90% pure functions but the rest is mutations, handling non-idempotent things, dealing with state, as the world is.
How about Time.now()? :) Source of disturbance, it should not be allowed to be used in programming etc. etc.
Of course Time.now() is an effectful routine.
This is not a strange idea to “FP purist zealots” either.
How is it defined in Elm?
Time.now : Task x Posix
How is it defined in Haskell? Data.Time.Clock.getCurrentTime :: IO UTCTime
And no, you have not given any examples of using JavaScript in a type-safe way. If you think you have, it means you don’t adequately understand type-safety.That said, you could add effects and a JavaScript FFI using monads or algebraic effects. You could also get rid of a lot of boilerplate in the Elm architecture using existential types. It's a safe bet that the Elm developers know this. But all of these extensions would make the language less approachable. I think one of the reasons why Elm is doing so well is because it's not Haskell. :)