Live data from Hacker News

ReasonML – React as first intended

imaginarycloud.com

171–180 of 190 posts

Re: ReasonML – React as first intended

#171

Earlier quoted context omitted.

Action creators always felt like and unnecessary abstraction to me. To avoid the aforementioned problem, I passed down a message library, or action object that has all of the actions on it, and dispatch. It's all I need!

Sure, action creators are "unnecessary" - you can always declare action objects and action types directly inline: this.props.dispatch({type : "INCREMENT"}); Nothing's ever _forced_ you to use action creators, or declare your type constants separately. However, we encourage use of action creators as a good practice. See my blog post "Idiomatic Redux: Why Use Action Creators?" [0] for some reasons, as well as the relat…

I respect your opinion but found each of the arguments contained within weak or easily countered.

> 1 ... put the logic for creating that action in one place

This isn't so simple. You end up duping the action in at minimum 1 AC (often many ACs), and onboard the complexity of an unnecessary function, plus importing and connecting that function all over your app. A UNIQUE_ACTION_CONSTANT is an easy refactor, unlike action creators, which can cause a cascade of changes when reworking component structures.

> 3 ... larger logic that goes into preparing the action object,

This justies a function, not necessarily an AC.

> 4 ... lets the action creator worry about how to handle things

Smart components are already aware of the state system by means of connect. Further, in AC aware apps, you have a whole swath of extra imports to manage, more connect calls to manage, and a binding API to consider, which sometimes requires patterns and team agreement on their own. dispatch + messages does away with all of that, and is shown to be simple/effective as popularized in Elm and Reason.

> 5 ... testing

Kinda. I'll meet ya half way here. But stubbing disptach and/or component methods is also very cheap, and super simple to reason about.

I say this all in the spirit of collaboration and productive debate :)

Re: ReasonML – React as first intended

#172
post #115
post #8

Earlier quoted context omitted.

1k upvotes. I check in on Fable and F# semi frequently but SAFE has somehow slipped under my radar. I wonder if the ionide project will get some extra support.. Suave though... Nothing against Suave, but it's not the Phoenix competitor the ecosystem is in dire need of. I was under the impression some newer frameworks like Giraffe were going to fill that void..

Are you aware of https://github.com/SaturnFramework/Saturn ? It's what the S in safe is actually meant to be, not suave. It's very similar, in heart anyways, to phoenix. The fsharp community is fighting what is essentially an uphill battle. We have ML but we've got to jump through dotnet hoops to get shit done. One man's cruft is another man's feature. I doubt ionide will support SAFE, but maybe they will have a sist…

So, I know this is a late reply to this but.. My reaction to the announcement post was "YES!", but I see a few choices in current "Moons" that are part of the same problem the project proposes to fix. Dapper is performant and good for what it is, but entity framework is an amazing ORM IMHO. Simple.Migrations does not have a CLI or support SQL generation?... These are too low level and don't really provide that flash OOTB experience IMHO; same critique(valid) made of Suave and Giraffe. To compete with rails and phoenix in velocity and user experience those technologies are going to have to be swapped out with more feature rich and ambitious libraries..

Re: ReasonML – React as first intended

#173
post #164
post #147

Earlier quoted context omitted.

I played with PureScript a little. It has advanced type system that captures a lot of semantics of JS allowing easy interobility with JS ecosystem. But that comes with a huge price. With all those monads and monad transformers interacting with JS it is easy to end up with stateful mess. Surely, it will be typed and functional mess, but still it is hard to maintain with all state pieces spread through code hiding in l…

Elm is a lang and a FW in one. Very opinionated. Very batteries included. PS is a lang. It compiles well to JS, but there is no friction against making it compile to native, apart from the time it takes to maintain that compiler backend. On top of PS you may pick a FW. Some have React.js under the hood, some follow more closely The Elm Architecture. Only with a FW, PS can be compared to Elm.

Elm is also a language. Surely it's libraries and runtime assume JS and DOM, but nothing prevents creating other ports of the language or creating alternative libraries.

And yes, Elm is opinionated. But that is a consequence of being very simple and pure functional language. As its typesystem does not support using monads or effects to model state with code similar in style to that in non-functional languages, one inevitably ends up with a runtime similar to Elm browser bindings in any Elm embedding.

Essentially Elm is opinionated because its pure functional style is the only style supported by the language with no escape hatches like the do blocks in Haskell or PureScript.

Re: ReasonML – React as first intended

#174
I got curious about ReasonML when I recently applied to a frontend job that strongly preferred candidates with ReasonML along with the standard React and Typescript requirement.

I am using the approaching the mercenary approach to my career so I am interested if ReasonML would be a good long term bet. What do you guys think?

Re: ReasonML – React as first intended

#175

Earlier quoted context omitted.

ReasonReact doesn't have Context, the API is unstable so they aren't binding to it.

The new API as of 16.3 is stable, so I suspect ReactReason will support it soon (if it doesn't already, by default). https://reactjs.org/docs/context.html

Ah, that's great that it's finally settled. RR is on v15 in terms of what it has to support though, so no dice; main focus at the minute seems to be on dropping v15 support and migrating to v16, which cleans up some of the code (particularly w/r/t the async side), but that has to happen before they bind to the new API, so going to be a while.

Re: ReasonML – React as first intended

#176
post #90

Earlier quoted context omitted.

You are comparing a view library (react) with a full framework (ember). Ofc you are supposed to pull things together with react, that's exactly what's intended. Compared to react, ember is: slow (1), more difficult to learn (2), has a much smaller community (3) and, most important aspect to me, has a huge footprint (4). (I'm not against ember, it might have some nice aspects and features. It was really nice during th…

I don't disagree with any of your points. React is faster. React has a larger community. All of it, I agree. But. When it comes to productivity (actually building something and maintaining it), I can achieve way more in Ember.

I'm only guessing that's because you have prior experience with Ember and are only starting to use react now.

I find code written in ReasonML is 100x more maintainable than anything written in javascript, whether it's react or ember

Re: ReasonML – React as first intended

#177

Earlier quoted context omitted.

That doesn't really address the issue that the use of Facebook's software supports Facebook. The industry needs to pay more attention to the long-term results of its choices and actions.

I'm not sure what the connection is here. Is it because Facebook sponsored development of Reason? Should we consider not using anything that Facebook touches? What if Facebook pays a developer to work on another popular library like Vue.js? Should we consider stop using Vue?

Maybe we can think of this as Facebook's payment to us for using our data.

Re: ReasonML – React as first intended

#178
post #118

Earlier quoted context omitted.

I'm going to blame any communication breakdown on the fact that I know nothing about ReasonML or React-Reason. However, the point of having to store state so you have something to compare against strikes me as a really odd choice for the React-Reason library to introduce, since it deviates from the functionality of React itself. I was curious enough to glance at the React-Reason doc's and they say that `shouldUpdate`…

No, you're absolutely correct. Coming from two years of React-ing myself, I went down the exact same thought path as you. The documentation is outdated, and the {oldSelf, newSelf} doesn't exist anymore. You had to use the `withRetainedProps` component for this to work, but that now results in an error message on compilation, telling you to use a reducerComponent instead. I think it's something they intend to figure o…

Ah, +1 for your point about the poor documentation.

Thanks for taking the time to clarify, and thanks for the original pros/cons post. I'm currently working on a mid-sized MVP project that is standard ES6 + Flow. I've recently been exploring our options for migrating to TypeScript or something like ReasonML. I've worked extensively with TypeScript, but am only starting to dip my toes into other options. You've been more helpful than just reading the documentation :)

Re: ReasonML – React as first intended

#179
post #47

Currently using Reason. Here's what they don't tell you: Pros: * Compile speed is mindblowing. As in, a big project compiles within a few seconds, and incremental compiles are instantaneous. The productivity gains of this cannot be overstated; you just don't get those moments anymore when you're waiting for webpack, your mind wanders off, lets just check HN real quick, ... no, you just stay in the flow. It's great. E…

Yea, thays been very much my experience as well. Still a little bit off usable imo, docs are still very iffy, and there's only really Real World OCaml as a great learning resource for the actual language. refmt formatting drives me a bit nuts, especially the.lines thing; it's steadily improving though. One thing though - Belt is the WIP standard library (so OCaml), whereas JS is just bindings to JS, they're very diff…

I don't know where (or if) |. is documented, I think I saw someone use it in a Github thread somewhere. I use it all the time – for instance

    someList
    |. Belt.List.map(i => i + 1)
... because most Belt.List functions take the list as the first argument, and |> feeds its input as the last argument.

Edit: apparently |. is BuckleScript, lots more discussion here: https://github.com/facebook/reason/issues/1452 ... just another instance of Reason still finding itself.

Re: ReasonML – React as first intended

#180

Earlier quoted context omitted.

That doesn't really address the issue that the use of Facebook's software supports Facebook. The industry needs to pay more attention to the long-term results of its choices and actions.

I'm not sure what the connection is here. Is it because Facebook sponsored development of Reason? Should we consider not using anything that Facebook touches? What if Facebook pays a developer to work on another popular library like Vue.js? Should we consider stop using Vue?

As far as I know, they aren't a sponsor of the project -- they own the project (as opposed to something like Cassandra).

Companies release these libraries because they benefit the companies. The successes of projects like React help Facebook.

I think that people who believe that Facebook is an unethical company should consider alternative technologies on new projects whenever possible.

Post reply on HN