Live data from Hacker News

How I learned to stop worrying and love React

firstdoit.com

31–40 of 107 posts

Re: How I learned to stop worrying and love React

#31

> However, all template languages are inherently crippled: they can never achieve the same expressiveness and power as code. Quite simply, {{# each}}, ng-repeat and databind="foreach" are all poor replacements for something that is native and trivial in JavaScript: a for loop. On the other hand, when using a template language I can put `foreach` loops and `if` conditions right into the template itself. And when using…

Which is why I prefer Ractive.js to React.

I like it too when I read the docs but haven't been able to try it yet for anything real. Have you actually used it for real work?

Re: How I learned to stop worrying and love React

#33

I went through something similar...and then I found Mithril ( http://lhorie.github.io/mithril/ ). I may be alone on this, but I've enjoyed working with Mithril much more than I ever did React. If you haven't given it a shot, I highly recommend you do.

We went with Mithril over React too. Both are good, but React + all of the libs needed to match Mithril is a fairly large payload for mobile-optimized websites, whereas Mithril is tiny.

Mithril didn't quite have everything we needed, though, so we made a small wrapper that provides nicer templating, event delegation, etc.: https://github.com/dailymuse/mithril-coat

Re: How I learned to stop worrying and love React

#34
There is a lot of good and even awesome things in ReactJS universe, except JSX. Thousands of developers took their lessons in PHP/Perl/Python about mixing logic and representation, and now in nightmares they will generate HTML from logic, especially by parts and in worst case - using conditional cases. Everybody who tried to change design of website, written using something like "if ($birthday) $html .= getBirthdayButton()", will understand me.

Maybe JS developers should go through it, through this circle of hell, to avoid it in future, so JSX is necessary evil.

//despite of that, I sincerely thankful for people behind React, for their new ideas and how they changed fields of JS frameworks and mobile apps. Big respect!

Re: How I learned to stop worrying and love React

#35
I encourage anyone who likes React and doesn't mind lisp to check out Reagent, an awesome Clojurescript library built atop React that manages to completely hide its complexity. It's by far the most fun I've ever had with web development; the way I feel now is like how I imagine people who've had religious epiphanies must feel when trying to show potential converts the proverbial light of god.

https://reagent-project.github.io/

Re: How I learned to stop worrying and love React

#36

I went through something similar...and then I found Mithril ( http://lhorie.github.io/mithril/ ). I may be alone on this, but I've enjoyed working with Mithril much more than I ever did React. If you haven't given it a shot, I highly recommend you do.

I like Mithril a lot, but the only thing that puts me off it over React and Angular is I don't really know how to tie in third-party libraries like d3 and dropzone.

http://mithril.js.org/integration.html shows how to integrate a Select2 field in a Mithril template (thus interoperaing with jQuery).

You can use the same approach for other libraries:

Add a function as `config` attribute to your virtual DOM element. That function gets the real DOM element as a parameter, and you can act on it with third party libraries.

Re: How I learned to stop worrying and love React

#37
post #6

I recently worked on my first React project, after working with Angular code for a while. I'm willing to accept that as an app gets more complex, React/Flux really pays off. But there's something to be said for having a single template file for a single page in Angular, versus having JSX scattered among 20+ components for that same single page in React. When you want to get a 10,000-foot-view of how it all comes toge…

The new Glimmer engine in Ember.js gives you React-like DOM diffing without the use of JSX, and baked into a very organized and easy to grasp framework to boot.

Re: How I learned to stop worrying and love React

#38
post #13

I went through something similar...and then I found Mithril ( http://lhorie.github.io/mithril/ ). I may be alone on this, but I've enjoyed working with Mithril much more than I ever did React. If you haven't given it a shot, I highly recommend you do.

What makes you like Mithril more? I've been looking at it for a while, and it seems very nice and lightweight. All I really want is an easy way to get performant DOM manipulations. With React I have to build the whole view around the component system, which isn't so flexible. Am I right in thinking that Mithril allows you to put the view together any way you want, as long as the end result is an object it can diff in…

> Am I right in thinking that Mithril allows you to put the view together any way you want, as long as the end result is an object it can diff into the DOM?

That's correct. Virtual DOM nodes are plain JS objects with `tag`, `attr` and `children` attributes (the last two being optional).

The `m()` helper gives you some sugar on top of that.

Idiomatic Mithril view code, however, is more about declaratively generating vDOM nodes based on a model and/or a view model than, say, jQuery-style DOM manipulations...

Re: How I learned to stop worrying and love React

#39

There is a lot of good and even awesome things in ReactJS universe, except JSX. Thousands of developers took their lessons in PHP/Perl/Python about mixing logic and representation, and now in nightmares they will generate HTML from logic, especially by parts and in worst case - using conditional cases. Everybody who tried to change design of website, written using something like "if ($birthday) $html .= getBirthdayBu…

This is the first thing every dev says when he/she first discovers React.

Logic and representation are not two unrelated pieces to keep them separate.

Re: How I learned to stop worrying and love React

#40

There is a lot of good and even awesome things in ReactJS universe, except JSX. Thousands of developers took their lessons in PHP/Perl/Python about mixing logic and representation, and now in nightmares they will generate HTML from logic, especially by parts and in worst case - using conditional cases. Everybody who tried to change design of website, written using something like "if ($birthday) $html .= getBirthdayBu…

You might be confusing programming languages with concepts.

Don't think of React as "a container for logic and a system for doing views". Think of it solely as view logic.

It's not mixing views with program logic. It's only view. There's nothing to mix. It just happens --- wonderfully --- to use a real programming language to represent those views.

The notions of logic, controllers, models, storage, and all that jazz are why there's also Flux (or Backbone or whatever else it is you want to use; we use Flummox, it's fine).

Post reply on HN