News for hackers. Stuff that matters.
Re:IBM releases Elm-powered app by yakshaving_jgt on Thursday January 10, 2019 @03:00AM (#18872286)
> Ports == lots of boilerplate and “loose” typing

This is a common criticism of Elm, and I've never understood it.

The criticism seems to be that "Elm is bad because I still need some JavaScript, and JavaScript is dangerous."

Like, what's the alternative? More JavaScript?

Re:IBM releases Elm-powered app by StreamBright on Thursday January 10, 2019 @03:59AM (#18872507)
Have you seen ReasonML?

  [@bs.val] external pi : float = "Math.PI";
  let tau = pi *. 2.0;
  [@bs.val] external alert : string => unit = "alert";
  alert("hello");
Elm was trying to make it very hard to use JS in Elm which is always a bad idea when you are a transpiled language. Clojure is so popular because you have access to most of Java and the libraries written in Java. ReasonML makes super easy to use JS (or other languages, same FFI interface) while being an ML family language just like Elm. For me ReasonML is clearly the winner of type safe JS for these reasons.
Re:IBM releases Elm-powered app by k_bx on Thursday January 10, 2019 @09:18AM (#18873960)
> Elm was trying to make it very hard to use JS in Elm which is always a bad idea when you are a transpiled language.

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.

Re:IBM releases Elm-powered app by yakshaving_jgt on Thursday January 10, 2019 @04:21AM (#18872578)
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.

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

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

Re:IBM releases Elm-powered app by gothy on Thursday January 10, 2019 @10:43AM (#18874629)
> 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.

Re:IBM releases Elm-powered app by yakshaving_jgt on Thursday January 10, 2019 @11:12AM (#18874885)
> I'd also like to pick up some "silver bullet", like Elm(if I got you right)

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.

[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.
Re:IBM releases Elm-powered app by fmap on Thursday January 10, 2019 @07:32AM (#18873370)
Elm is different to ML in that it is explicitly designed to be a pure language. Purity is important for the Elm architecture and allowing arbitrary side effects in your apps would break everything.

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. :)

Re:IBM releases Elm-powered app by haskman on Thursday January 10, 2019 @03:22AM (#18872354)
Coming in from the other (Functional Programming) side, Elm can be restrictive (no typeclasses, do notation etc.). But it does walk a fine balance, and I love that there's a popular-ish language that is exploring the ease-of-use design space.
Re:IBM releases Elm-powered app by yakshaving_jgt on Thursday January 10, 2019 @03:45AM (#18872447)
Yeah, it's pretty restrictive for FP people, but I think that's fine. I think it's easier for FP people to deal with that amount of restriction, than it is for the average JS developer to quickly understand how to wield as much power as e.g. PureScript gives you.

Also a little surprised you mentioned do notation; it's just syntax sugar after all :)

Re:IBM releases Elm-powered app by haskman on Thursday January 10, 2019 @04:30AM (#18872615)
> Yeah, it's pretty restrictive for FP people, but I think that's fine. I think it's easier for FP people to deal with that amount of restriction, than it is for the average JS developer to quickly understand how to wield as much power as e.g. PureScript gives you.

I have heard this sentiment earlier, and I believe that there is a better middle ground. Use a less restrictive platform and simply don't use features you deem too complicated. That's a better approach because as the developer becomes more familiar with typed FP, they would be able to use better and better tools at their disposal. i.e. the toolset will grow with their skill.

> Also a little surprised you mentioned do notation; it's just syntax sugar after all :)

Oh it's less of an issue, but syntax does matter a lot. I find that Monads become intractable for new devs without do-notation.

Re:IBM releases Elm-powered app by yakshaving_jgt on Thursday January 10, 2019 @04:36AM (#18872633)
> I find that Monads become intractable for new devs without do-notation.

That's a fair point, and I agree, however this somewhat negates your previous point:

> Use a less restrictive platform and simply don't use features you deem too complicated. That's a better approach because as the developer becomes more familiar with typed FP, they would be able to use better and better tools at their disposal. i.e. the toolset will grow with their skill.

I can't say definitively, but you could argue that on a team, a more experienced developer might use more advanced features of a technology, which less experienced developers then have to just deal with. They might feel intimidated by that, and discouraged from working with the technology at all. I'm using "team" in a more abstract sense here too; it could be all the collaborators (existing or potential) of an open source project.

I'm not arguing the anti-intellectual position that everything should be dumbed-down. I just believe — as you said — there is some middle ground, which also isn't universally applicable.

Re:IBM releases Elm-powered app by haskman on Thursday January 10, 2019 @05:23AM (#18872811)
> I can't say definitively, but you could argue that on a team, a more experienced developer might use more advanced features of a technology, which less experienced developers then have to just deal with.

Actually in practice that's much less of an issue when using typed FP. I've found that it's easy to modify parts of code which you do understand the implementation of, while still being able to use the interface of other potentially more complex parts. Of course YMMV.

Re:IBM releases Elm-powered app by cttet on Friday January 11, 2019 @12:56AM (#18881320)
The alternative is less Javascript logic written by the app developer (and instead use packages and APIs directly).

Elm disguised as a beginner friendly language for web front-end, which is not true with the case of ports. Where you need to be fairly familiar with Javascript.

The Elm community also advertise a lot on the advantage of development happiness of Elm over Javascript, and mention the Javascript fatigue a lot. But the truth for a beginner is that you can't escape the Javascript ecosystem when using Elm, and sometimes it requires even more Javascript experience than using just Javascript framework like React to build something that require a web api that's not in the tiny list that Elm provided.

If web development is not someone's main job and they are just finding a tool with better dev experience to build some side projects, the fact that they need to design an interface for almost every external package is not aligned with their original reason to use Elm.

Re:IBM releases Elm-powered app by yakshaving_jgt on Friday January 11, 2019 @11:55AM (#18884794)
> sometimes it requires even more Javascript experience than using just Javascript framework like React to build something that require a web api that's not in the tiny list that Elm provided.

I don't understand. You're saying a codebase of 5% JavaScript demands more JavaScript experience than a codebase of 100% JavaScript.

This seems self-evidently false.

> If web development is not someone's main job and they are just finding a tool with better dev experience to build some side projects, the fact that they need to design an interface for almost every external package is not aligned with their original reason to use Elm.

Seems like the argument is Elm isn't ideal if you're not a programmer, because you can't cargo-cult it.

I think I'm ok with that.

Re:IBM releases Elm-powered app by cttet on Sunday January 13, 2019 @10:57PM (#18900519)
> You're saying a codebase of 5% JavaScript demands more JavaScript experience than a codebase of 100% JavaScript.

A codebase of 100% Javascript does not usually mean 100% written by the app developer. If you are coding in react for some basic app, like some basic crud with react using existing backend with Firebase, it almost only require you to learn the some basics of react and Javascript syntax, and fill in the template. You can also use other modules by just follow their documentation when you need some extra functionality.

However in Elm Ports we are required to pass async messages for everything which is much harder. I am OK with the boilerplate for the JSON encoder and stuff, but I have to wrap around my head for how to write a port for lots of basic web APIs.

Port is hard even for people that familiar with Javascript. There are plenty of experienced Javascript programmers willing to dive into the source code of Elm to write native modules to avoid ports even. https://www.reddit.com/r/elm/comments/81bo14/do_we_need_to_m...

In addition, even the 5% of Javascript will eventually leads to the full Javascript stack, where Elm, without an official recommend JS stack, feels more like additional choice as a part of the JS fatigue. Beginners ends up looking up on browserfy/gulp/webpack etc and figuring out a way to integrate Elm in.

> Seems like the argument is Elm isn't ideal if you're not a programmer

I program daily for machine learning, and I have used many programming languages. But Javascript is not the language that I want to dive in too much, which it is the main reason I learn Elm. If your requirement of being a programmer is having a job as a software developer, then I am not. But I think a language with an aim of going into education and scientific computing shouldn't limit itself to that. https://www.youtube.com/watch?v=uGlzRt-FYto

I enjoy Elm. It is one of my favourite programming language. But I have not gotten anything done with it mainly because of ports. If I am pursuing a career in front-end related development, I would dive into Javascript and build stuff. I understand the decisions from Evan and friends and I am just thankful for Elm as it is, there is no right for me to demand anything anyway.

[edit: formatting]