News for hackers. Stuff that matters.
[dead]
Re:IBM releases Elm-powered app by the_gipsy on Thursday January 10, 2019 @06:37AM (#18873139)
Of 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`.

Re:IBM releases Elm-powered app by StreamBright on Thursday January 10, 2019 @07:00AM (#18873246)
I 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.
Re:IBM releases Elm-powered app by the_gipsy on Thursday January 10, 2019 @08:47AM (#18873752)
If 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/Ba...

Re:IBM releases Elm-powered app by StreamBright on Thursday January 10, 2019 @02:54PM (#18877430)
Again, 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?
Re:IBM releases Elm-powered app by the_gipsy on Thursday January 10, 2019 @04:43PM (#18878541)
As I said, yoy can use any JS function with Elm. It’s just through ports, not inline.
Re:IBM releases Elm-powered app by yakshaving_jgt on Thursday January 10, 2019 @07:45AM (#18873420)
No, it is not silly. It is referential transparency.
Re:IBM releases Elm-powered app by elbear on Thursday January 10, 2019 @09:35AM (#18874063)
What happens if you call in your ReasonML code a JS function that throws an exception?
Re:IBM releases Elm-powered app by StreamBright on Thursday January 10, 2019 @02:55PM (#18877442)
Re:IBM releases Elm-powered app by yakshaving_jgt on Thursday January 10, 2019 @07:44AM (#18873416)
> 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 ¯\_(ツ)_/¯

Re:IBM releases Elm-powered app by chickenfries on Thursday January 10, 2019 @09:47AM (#18874171)
I 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

Re:IBM releases Elm-powered app by aarpmcgee on Thursday January 10, 2019 @10:30AM (#18874499)
The core question is, "have you ever experienced a runtime error?" Have you ever spent time debugging a runtime error deployed to production?

You can't get those in Elm.

Re:IBM releases Elm-powered app by chickenfries on Thursday January 10, 2019 @12:46PM (#18876022)
No the core question is “does the time and effort spent on those cases justify the cost of switching to elm?” I have to weigh the benefit of no runtime exceptions against things like having to write interop code for libraries that I may have to integrate with.

It might make sense for other people. It doesn’t add up for me.

Re:IBM releases Elm-powered app by StreamBright on Thursday January 10, 2019 @12:00PM (#18875461)
Re:IBM releases Elm-powered app by yakshaving_jgt on Thursday January 10, 2019 @12:44PM (#18876002)
You’ve already posted this.

It’s intellectually dishonest to point to implementation bugs as fundamental flaws.

Re:IBM releases Elm-powered app by chickenfries on Thursday January 10, 2019 @12:48PM (#18876052)
This matters in the real world question of “should I use elm” even if it doesn’t matter to the theoretical question of “is the elm language sound?”. Especially since there is only one implementation of elm that updates very infrequently.
Re:IBM releases Elm-powered app by yakshaving_jgt on Thursday January 10, 2019 @12:55PM (#18876133)
Only insofar as you would check any technology for how well it’s made generally.

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.

Re:IBM releases Elm-powered app by chickenfries on Thursday January 10, 2019 @05:14PM (#18878814)
Fair enough. I don’t considering your complaints about Math.random() or division by zero to be a fair reflection of “real world use.”
Re:IBM releases Elm-powered app by StreamBright on Thursday January 10, 2019 @02:52PM (#18877408)
What are you talking about? You said no runtime errors because you have pure functions and now it turns out that actually implementation also matters?????

Imagine my shock................

Re:IBM releases Elm-powered app by sawady on Thursday January 10, 2019 @11:41AM (#18875217)
List.tail []
Re:IBM releases Elm-powered app by yakshaving_jgt on Thursday January 10, 2019 @11:59AM (#18875455)

  tail : List a -> Maybe (List a)
Nice try though.

https://github.com/elm/core/blob/master/src/List.elm#L548

Re:IBM releases Elm-powered app by sawady on Thursday January 10, 2019 @02:51PM (#18877395)
Haha, sorry. You know what I mean, a partial function.
Re:IBM releases Elm-powered app by yakshaving_jgt on Thursday January 10, 2019 @04:23PM (#18878353)
Except in Elm, the function isn't partial.

You're thinking of the partial functions from Haskell's Prelude.

Re:IBM releases Elm-powered app by StreamBright on Thursday January 10, 2019 @10:31AM (#18874505)
>>> I literally have never experienced a bug because of the existence of Math.random().

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.

Re:IBM releases Elm-powered app by StreamBright on Thursday January 10, 2019 @07:50AM (#18873447)
I 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.

Re:IBM releases Elm-powered app by yakshaving_jgt on Thursday January 10, 2019 @08:16AM (#18873565)
Uhh… 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.