3 ms·
I do not agree that it is "always a bad idea". That is why I use Elm, and not some other compile-to-JS language that allows me more freedom. I don't want free
by yakshaving_jgt 8y ago
I do not agree that it is "always a bad idea".
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.
- StreamBright 8y agoMost of the people want freedom and not some North Korean style crap. The example I gave was explicitly displaying how it is possible to use something from JS on a type safe way. Not sure how could you hang yourself with that. I guess you are just very creative.
- the_gipsy 8y agoOf course you can't hang yourself with `Math.PI` or `window.alert`. Try `Math.random()` and `window.confirm` instead, or much more relevant: `document.getElementById`.
- StreamBright 8y agoI am not saying that everything is going to be super easy to do this way but taking away my ability of using Math.PI because of document.getElementById is silly.
- yakshaving_jgt 8y agoNo, it is not silly. It is referential transparency.
- the_gipsy 8y agoIf you absolutely must run unsafe JS interop inline then maybe Elm is not for you, but it doesn't make its approach "silly". 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/Basics#pi https://package.elm-lang.org/packages/elm-lang/core/5.1.1/Ba...
- StreamBright 8y agoAgain, I could not care less what is in core (which might not be there anymore without a deprecation warning) but I want to use JS functions if I need to. How hard is to understand these requirements?
- the_gipsy 8y agoAs I said, yoy can use any JS function with Elm. It’s just through ports, not inline.
- yakshaving_jgt 8y ago> North Korean style crap 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 ¯\_(ツ)_/¯
- StreamBright 8y agoI gave you examples of using JS type safe way. You don't care. One question I alway use to tilt FP purist zealots: How about Time.now()? :) Source of disturbance, it should not be allowed to be used in programming etc. etc.
- yakshaving_jgt 8y agoUhh… What? I’m confused. Did you think this would be a smoking gun to your argument? 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.
- chickenfries 8y agoI literally have never experienced a bug because of the existence of Math.random(). I don’t think I’ve ever used it outside of a coding interview. Similarly, I don’t spend time debugging runtime errors caused by document.querySelector()? If I do it’s usually only once when I write the initial query. I don’t understand your last argument: why would I divide by 0? 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 https://youtu.be/mZyvIHYn2zk
- 8y ago
- elbear 8y agoWhat happens if you call in your ReasonML code a JS function that throws an exception?
- StreamBright 8y agoAre you asking about this? https://bucklescript.github.io/docs/en/exceptions https://bucklescript.github.io/docs/en/exceptions
- gothy 8y agoI was(am? will be again?) a fan of Elm. Constraints can be helpful and even liberating(in some sense). But that's something that should be balanced carefully with other things, like rules\laws that are clear, universal and follow the common sense. Unfortunately, during my Elm journey, I've found that's not the case for Elm. > 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.
- yakshaving_jgt 8y ago> If you'd like to, why not? It's up to you. You're not forced to do, though. 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.
- gothy 8y ago> 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. 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.