Live data from Hacker News

React and Redux are a joke right?

games.greggman.com

61–70 of 119 posts

Re: React and Redux are a joke right?

#61
post #3

Stopped reading half-way through, as lots of incorrect stuff off the bat. > In the react world though you can’t mutate your data Sure you can. > If you get 3 people react will end up re-rendering 3 times because of the code above. Each call to `setState` triggers a re-render. Nope, calls to setState are batched.

I think sometimes you need an outsider view to call out that the emperor isn't wearing any clothes, and that's going to result in botched details. I don't think it impacts the overall point the author is trying to make. I teach web development at a part-time course, and we recently redesigned our curriculum to use React + Node instead of Rails with JQuery. With the new technologies, the students are profoundly less p…

Most of the problem, IMO, is that everybody seems to think that everything needs to be a SPA.

The reality is that 99% of web applications are "open, check, close" experiences which benefit very little, if at all, from a front-end framework of any kind.

The remaining applications that people actually keep open for long periods of time where the DOM needs to update over long periods of time are the only places where this approach really provides a huge benefit. Things like a chat system or actual web based software that people would be expected to keep working on throughout their day. For those types of application, React is a good fit.

The biggest issue is people jumping on this "we need a front-end framework" train when...you really don't for most things.

Re: React and Redux are a joke right?

#62
post #55

Earlier quoted context omitted.

Updating an array element arr[3] = 'New content'; Updating an array element immutably arr = arr.map((element, index) => { if (index === 3) return 'New content'; return element; }); It's possible, sure, but it feels terrible. JavaScript objects want to be mutated - it's the most idiomatic way of interacting with them. Whether functional programming paradigm is good (I certainly feel it is) is beside the point - JS was…

if you use ES2015: arr = [ ...arr.slice(0, 2), 'New Content', ...arr.slice(3) ]

In my eyes this slice of code is even worse than the array map one, where there is 2.5 pieces of logic (map, if, and 2 return that makes for the .5).

In the version you have 2 spread operators, an array construct and 3 hardcoded ints.

I might not use the correct academic terms, and I might not be yet fully accustomed to es2015, but this way of writing stuff always make me pause and double check the code.

Re: React and Redux are a joke right?

#63
post #58

I'm one of the laggards - Over the years, based on staying around tech communities (esp. HN) I've learned not to invest time / effort into the hype that surrounds a newly launched tech. I did burn my finger a couple of times, especially with MongoDB back then, so these days I'm pretty cautious. I'm one of the very few who didn't invest in React. I waited it out and invested into Vue.JS, instead. This is no framework…

I don't see how vue's take on this same issue is significantly or even marginally better: https://vuejs.org/v2/guide/conditional.html

Instead of getting HTML fragments on your JS, you get JS fragments on your HTML? Whenever you need to programatically generate markup with conditionals and iteration over existing data structures, you end up having to mix a programming language with your markup. (The other option is of course to create an entire programming syntax on top of your markup language.)

BTW, I haven't actually used vue, so this post is by no means me saying that it doesn't have its merits or it's not a good framework.

Re: React and Redux are a joke right?

#64
Judging from the title I expected one of the usual BS posts like "OMG, React mixes code and html!!!" etc and was ready to post a "No, you just don't get it" comment.

But this actually makes several good points on accidental complexity imposed by React/Redux.

I know why they impose it, but there must (should) be a better way.

Re: React and Redux are a joke right?

#65

The article has a point. We tend to fix issues with state by avoiding mutability. That is like going to a doctor because it hurts when you laugh, and they just say "don't laugh". I wish there was a language that embraced mutability instead [1]. Mutability is how the computer works at the lowest levels, and how we tend to think about the world. You would use plain old data objects to store everything. Then you would h…

Mutability is actually a kluge.

Re: React and Redux are a joke right?

#66
post #58

I'm one of the laggards - Over the years, based on staying around tech communities (esp. HN) I've learned not to invest time / effort into the hype that surrounds a newly launched tech. I did burn my finger a couple of times, especially with MongoDB back then, so these days I'm pretty cautious. I'm one of the very few who didn't invest in React. I waited it out and invested into Vue.JS, instead. This is no framework…

>~15 years trying to make everyone separate HTML, JS & CSS. And then suddenly everything went south and we’re writing code like this:

That's definitely not what's bad about React. In fact that's what great about React -- coherent widgets (components) that are defined in a single place. Not to mention that JSX in React it's all JS and properly parsed and checked -- the "HTML" there is just sugar.

Such separation of HTML/JS/CSS was misconceived. It makes sense for web documents and simple forms, but not for web apps with rich widgets etc (which is what we're trying to do). Tons of problems stemmed from cargo cult adherence to that.

Everybody else, including those that add JS instructions (or ad-hoc "templating language" instructions inside HTML tags) are getting it wrong.

Re: React and Redux are a joke right?

#67
post #58

I'm one of the laggards - Over the years, based on staying around tech communities (esp. HN) I've learned not to invest time / effort into the hype that surrounds a newly launched tech. I did burn my finger a couple of times, especially with MongoDB back then, so these days I'm pretty cautious. I'm one of the very few who didn't invest in React. I waited it out and invested into Vue.JS, instead. This is no framework…

The whole "separate HTML, JS & CSS" idea I don't believe is something that should go unchallenged.

It was "best practice" back in the days for years and mostly just because it was best practice, but also because at that time it made juust that much more sense where web applications were more primitive and closer to a semantic HTML "document" with some interactivity sprinkled on top (remember when AJAX was bleeding edge jaw dropping? "LOOK THE PAGE DOES NOT EVEN REFRESH!").

It's just some theoretical ideal that never pays any dividends in the real world and is not appropriate for a sophisticated modern web application.

The separated HTML, JS and CSS of your sophisticated datetime picker element or auto-suggest fancy textbox are of no use or importance separately. They all need each other, they are all inter-dependent and if you force that separation on some ideological idealistic principle you create the spaghetti that any commercial web developer out in the front lines is well aware of.

You spend a good 60% of your time on "where is the HTML for this JS" ... "where is the JS for this HTML" ... "where is the CSS for this HTML".

I'm sure a lone programmer is going to come down here and reply about their snowflake project that "was done right".

I don't care. Frame the code and hang it on your wall.

Out there in the real world in teams of 10+ people with varying degrees of skill and care who join and leave over multiple years you can't have a snowflake project that is perfect in every regard. So if the eco-system doesn't give you strong suspension belts things will go south.

If you could easily and practically switch and mix and match custom HTML/JS/CSS for any given web application then that would be something.

We would need much tighter and stricter interfaces and so on for something like that to work.

We all know that's nowhere near the case. Any non-trivial commercial web application will inevitably have HTML/JS/CSS that are all heavily dependent on each other and as a result the separation of them doesn't provide much benefit, and creates a whole series of problems on top too.

Re: React and Redux are a joke right?

#68
post #58

I'm one of the laggards - Over the years, based on staying around tech communities (esp. HN) I've learned not to invest time / effort into the hype that surrounds a newly launched tech. I did burn my finger a couple of times, especially with MongoDB back then, so these days I'm pretty cautious. I'm one of the very few who didn't invest in React. I waited it out and invested into Vue.JS, instead. This is no framework…

Vue components are really following the same paradigm React does: styling, view and logic are all in one place. The only thing in which react differs here is that it uses different syntax. Instead of using attributes in the template which create a new language, react went with slightly modified javascript. And in the production build, Vue compiles html to javascript functions anyway.

Re: React and Redux are a joke right?

#69
post #58

I'm one of the laggards - Over the years, based on staying around tech communities (esp. HN) I've learned not to invest time / effort into the hype that surrounds a newly launched tech. I did burn my finger a couple of times, especially with MongoDB back then, so these days I'm pretty cautious. I'm one of the very few who didn't invest in React. I waited it out and invested into Vue.JS, instead. This is no framework…

Is it actually better to need to have three files open at a time in order to work on a UI component?

I think React components perfectly follow the single responsibility principle. You have a single file that is responsible for one thing: mapping data to UI. Yeah, it has some crazy syntax but it's just sugar.

I tend to use separate stylesheets, but that file lives right next to the component file.

Re: React and Redux are a joke right?

#70
post #58

I'm one of the laggards - Over the years, based on staying around tech communities (esp. HN) I've learned not to invest time / effort into the hype that surrounds a newly launched tech. I did burn my finger a couple of times, especially with MongoDB back then, so these days I'm pretty cautious. I'm one of the very few who didn't invest in React. I waited it out and invested into Vue.JS, instead. This is no framework…

To paraphrase somebody, separating HTML, JS & CSS is like taking an essay and separating out the nouns, verbs and adjectives. Sure you have achieved "separation of concerns", but your codebase now no longer has any semblance of coherence.
Post reply on HN