HNHacker News
TopNewBestAskShowJobs

codeptualize

1,689 karma · joined March 3, 2021

Twitter: @codeptualize Email: codeptualize[at]pm.me
submissionscomments
codeptualize··on Introducing react.dev
Departure from class based components was one of the motivations behind hooks, those are:

1. It’s hard to reuse stateful logic between components

2. Complex components become hard to understand

3. Classes confuse both people and machines

See https://legacy.reactjs.org/docs/hooks-intro.html#motivation for details. Agree or not, but it is a very intentional and well motivated direction.

codeptualize··on Introducing react.dev
Skimmed over your article. The infinite loop situation is not exclusive to hooks and very much exists in classes.

The situation is calling setState from useEffect, which triggers a render, triggers the setState, render, etc...

If you setState in componentDidUpdate without any guards you will end up with the same loop. I don't remember how debugging this worked, but I'm pretty sure it wasn't pretty.

As to big messy components: I don't think you can blame that on hooks. Hooks make it easier to split all of that up so you have isolated well contained chunks of logic that are much easier to test, debug, and manage.

Vue; not super familiar but I believe they use reactivity right? I think reactivity can be nice, but is also not as great as it's made out to be as it gets tricky as soon as you need to take control and prevent extra renders etc. A lot of it is making diffing and memoization less explicit, which can be nice, but also has some tradeoffs.

codeptualize··on Introducing react.dev
How do you mean? Imo it's easier to organize as you can split up your logic into normal functions and custom hooks (which are also just functions).

I also find functions much easier to read as there is no "this" and you can simply read them top to bottom for order of execution.

codeptualize··on Stop Using Custom Web Fonts
No, the article tells you that aesthetics have impact on (perceived) usability, fonts are hugely important to aesthetics. Better usability is whats going to sell more widgets.

But in terms of sales the branding is probably even more important, brands are hugely important in selling products, and fonts/typography are a big part of that. I did not focus on that as the article made the aesthetics-do-not-serve-purpose claim, but for sales branding is as relevant if not more relevant.

So if you are selling things I think you can pretty easily justify nice fonts to make your brand and products more desirable.

It does matter what your brand is of course, if your USP is cheap no frills a system font might serve that well.

codeptualize··on Introducing react.dev
Every week? Hooks are from 4 years ago..

Only new things now are suspense and server components, both completely optional.

React is amazingly stable and largely backward compatible (where it’s not there are usually codemods available to do most of the work).

codeptualize··on Introducing react.dev
It’s funny that controllers are conceptually not that different from hooks just with classes. Question: can controllers access everything on the host? As that would easily turn into a giant mess. Probably you shouldn’t but isn’t that the same as hooks rules?

Classes have lots of rules and best practices to prevent a mess, just like hooks. Also stateful classes are notoriously hard to debug as everything can change everything all the time.

I think you also should try hooks for a bit. Some of your statements about them are incorrect or really not that prevalent in normal use, you might be surprised how nice they can be. Especially use react-query or swr for fetching and something like zustand for state.

codeptualize··on Introducing react.dev
Access to this.setState would be horrible, imagine the conflicts. You need separate state, and then you sort of have hooks again.
codeptualize··on Introducing react.dev
You are not wrong, I think renderprops are valid, and I still use them in some situations.

They are imo not ideal as they are hard to memoize because of the render function. It’s funny that if you try to memoize renderprop components you likely have to use some sort of inputs array just like hooks.

Besides the memoization issue it also gets pretty messy if you need to implement many of them. Instead of just putting things in variables you are now nesting many levels deep.

I think renderprops and hooks are functionally not that different, but hooks have better ergonomics when using many.

codeptualize··on Introducing react.dev
With merge props I mean passing down the local state to the next component. If you see the react article I linked it’s the injectedProps.

I think this might be quite common, if you haven’t experienced HOC hell I can understand the confusion why hooks are necessary.

In terms of putting it in a function: there is only one state object per component, you could pass setState around, but you can imagine what would happen if many functions call it. It’s also a lot more effort on the implementation as you would have to basically pass state, and call do some sort of update in the lifecycle methods. It would probably work for one function, but with many it will get problematic. You would almost have to write your own pseudo hooks framework to make this work in a decent way.

codeptualize··on Introducing react.dev
Sure! It's generally about "stateful logic". Basically logic that relies on state and/or the lifecycle methods (componentDidMount, componentDidUpdate, etc) as with classes those are only available as part of a component.

You can "sort of" reuse component logic with classes, the most common way is by using Higher order components (see https://legacy.reactjs.org/docs/higher-order- components.html).

The example in that article is pretty good: Subscribing to some external data source. That requires on mount, state, and on unmount.

Using HOC's is not actually reusing logic though, it's creating more components and wrapping them to compose the logic. It's a workaround.

HOC's have a bunch of downsides, imo the most obvious one is the props; you need to pass the previous props, and merge in the new ones. That can create conflicts. Another typical one is refs. You need to be very meticulous about structure and how you compose and order your HOC's to make sure it all works.

In hooks you can define this stateful logic truly disconnected from a component, resolving a lot of the issues of HOC's as you can just call a bunch of functions without impacting the render tree. The "plumbing" is much simpler.

Hope that is sort of clear, but let me know if I should clarify any of this.

codeptualize··on Introducing react.dev
Why are so many comments about class components, I thought we ended that debate 3 years ago?

Hooks are better because they allow you to reuse component logic, impossible with class components. They solve all the issues and gotcha's of HOC's.

Don't compare class components with hooks, compare HOC's with hooks.

The best way to grow appreciation for hooks is to try wrapping many HOC's and deal with conflicting props and "innerRefs". People seem to very easily forget the horrors of the old.

Also lets be real, hooks aren't that bad. Yes dependencies arrays and useEffect take some getting used to, but I rarely get into situations where I actually get into questionable territory. Use react-query/swr for fetching, use Zustand (or whatever) for state, and you cut out 95% of the problems.

Anyway, the new docs are great, well done, nice work!

codeptualize··on Introducing react.dev
And then we have another framework! This is why we have so many :D
codeptualize··on Stop Using Custom Web Fonts
Umm...like I pointed out, it doesn't have to be as we now have "font-display" which provides multiple strategies for loading (or not loading) web fonts.

MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/...

Demo: https://font-display.glitch.me/

More info, pro/cons: https://www.smashingmagazine.com/2021/05/reduce-font-loading...

And there is even more on the way: https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/...

As to the "better or not", read my previous comment(s).

codeptualize··on Stop Using Custom Web Fonts
The aesthetic–usability effect has been studied in the types of experiments you describe. It is also pretty easy to find yourself if you do some simple usability tests.

There is a scale to it of course. It's not like aesthetics can fix unusable products, it's just one of the tools you can and should use. And this is just usability, ignoring the value of branding, identity, etc.

If "custom fonts are good or bad" is imo not something you can get a definitive answer on. The impact on perception of usability obviously depends heavily on the fonts that are loaded, how they are used, and the rest of the page. Making broad statements will probably miss the nuance of usability and user experience.

Loading time is also a bit of a strange thing to take as a downside. Loading fonts does not have to be blocking (see font-display css), also there is a difference between loading 2 font files or 17, fonts are usually cached, and we even have variable fonts these days reducing size significantly. In other words it depends on the situation.

As with most usability topics the real way to find out is to test your use case. In my experience a few kb's more or less is not going to have a significant impact in many situations, especially if they are loaded in a non blocking way.

By all means test your case, it's always a good idea to test, and you will likely find 10 issues more urgent and more important than a couple of fonts.

codeptualize··on Stop Using Custom Web Fonts
If you take individual stylistic elements you can easily argue they don't make a difference, but all these little details combined is what makes the difference.

Fonts and typography are hugely important, especially in minimalistic styles.

I think there is also a misunderstanding in this article that aesthetics don't serve purpose. Aesthetics have impact on how things are perceived, meaning it actually has impact on the user experience https://www.nngroup.com/articles/aesthetic-usability-effect/

codeptualize··on Ask HN: Are we still allowed to be controversial without censorship?
But I think nobody is arguing that all of it should be illegal, but there is a big difference between legality and whats socially acceptable.

That's often conflated, and actually the point I have been trying to make; you can say a lot of wild stuff legally, but you can not expect others to just accept it, not react to it, and not change their opinion of you.

There are also things that should be illegal, as example do you think death treats are fine? Or is that what you are referring to in my comment?

codeptualize··on Ask HN: Are we still allowed to be controversial without censorship?
It's because generally people want everyone to just be able to live their lives and not get discriminated, bullied, or even physically harmed for who they are, what they believe in, where they come from, or who they love.

Things you can not influence, things you can not change, things that do not harm others.

The intolerance towards intolerant is necessary for that to happen, which explains the battle.

People censoring themselves to not be hateful might honestly be a good thing, maybe they should figure out where those thoughts come from and if they should reconsider them. I would advocate for them to get help, therapy, social support, whatever they struggle with. I think being caring and empathetic strengthens society in the short and long term.

codeptualize··on Ask HN: Are we still allowed to be controversial without censorship?
I think on the surface I agree. Hate mobs doesn't sound great and death threats are simply illegal and should be prosecuted.

If it is in fact all lies etc, then sure. But, I do think this is often exaggerated, and a lot of times "start a conversation about incredibly nuanced topics" might not be so nuanced and in fact hateful, look at dog whistles for example. That there is no tolerance for intolerance is kinda necessary (paradox of tolerance). Idk the case you are referring to so can't say if that's relevant to this situation or not.

I do strongly disagree that people suck. My experience with people is that generally they mean well, try to live their best live, and wish well on others, even if they might disagree on some things. A good test is to just think about the people you interact with day to day in real life, not tv, not twitter, not whatever. That's reality.

codeptualize··on Ask HN: Are we still allowed to be controversial without censorship?
I did not make that jump, I said "often" controversial is used for hateful speech which is true, and I specifically clarified that I was not assuming this was the case here. The reason I had to include it is that the original comment refers to "censorship", doesn't mean it is, but it's not that far fetched to think it could be.

That distinction is relevant to the question as the reaction to a controversial take, something that's likely to cause disagreement, is very different from the reaction to hateful speech. If it's not the case here; great!

If you read the rest of my comment I mostly say it's totally fine to have controversial opinions. At the end, albeit in jest, I even refer to my own controversies. It is true though, I often disagree with people on many topics, but I have not been censored.

My main point through all of it is that free speech is not free from consequences, everything one does has consequences, positive or negative. Expecting everyone to just embrace and except everything is just not realistic also not fair. Say what you need to say, but also expect people to react.

codeptualize··on Ask HN: Are we still allowed to be controversial without censorship?
It depends on the things you want to say and where you say them. In most countries, even the US, free speech has limitations.

If you stay within the law you are totally fine to say whatever you want, but it's a fuck around and find out situation, there might be consequences. If you say wild shit at work your employer might rethink your position, if you say wild shit to your friends they might not appreciate your company anymore, if you say wild shit online the platform might remove it. This is imo fair, you get to make your decisions, others can make theirs.

"Questioning a narrative" sounds innocent, but can certainly be used in hateful and malicious ways. The same rules apply; you can likely say it, but people might not appreciate it, and that's ok.

Often "I want to say controversial things" is a way to say "I want to say hateful things". The tolerance for hate speech is decreasing and hopefully will decrease further, which is great. If that applies to your situation (and I'm not saying it does), I suggest you question your narrative a bit more.

If it's not about hate speech you can absolutely discuss controversial takes, given that the other people are willing to hear about them and you have some decent arguments to back them up. I have plenty of controversial coding and design takes, nobody ever even tried to censor me, and some even agree!

codeptualize··on React is holding me hostage
I've been involved in quite a lot of usability testing and I'm often positively surprised by the responses. Which is why I'm sort of skeptical when reading such claims. Also because I think user experience overall has improved, by a lot, the standards now are so much higher than the used to be.

I think it almost always comes down to one thing: Can people achieve the thing they want to achieve in a somewhat efficient way?

If the answer is yes there is lots of tolerance for all sorts of crap before people experience it in a negative way.

That means managing the experience. As example a multi minute upload process can be totally fine if handled properly, a .5s delay on an input can make it unusable. My point being; reality is a lot more nuanced than the blanket "it all sucks, and performance is everything" statement, and personally I don't think it's helpful. Unless we can actually look at metrics and assess their importance and how we can address them.

Don't get me wrong; we should absolutely keep trying to improve, especially crafting well made usable interfaces that are a delight to use. Performance is certainly very important, but it's not the be all end all of user experience and atm wrongly used to justify silly points why [my fav framework] is so much better than React.

codeptualize··on React is holding me hostage
I’m seeing a lot of anecdotes, not a lot of research.

Nngroup used to publish analyses of the state of usability, but I don’t think they have done one recently.

The old ones always showed progress, and that’s also what I would expect talking about the average situation.

Average progress doesn’t mean there are no shitty situations and we should always strive to improve, I just think claims like this are not helpful as they are used to make blanket statements about nuanced situations.

Unless you can back them up of course, and I would still love to see the data if anyone can find it.

codeptualize··on React is holding me hostage
> the modern webapp experience is so miserable for the average person.

I see this claim a lot and I'm curious what this is based on, can somebody drop some links to further reading?

codeptualize··on My mindfulness practice led me to meltdown (2021)
It sounds like he tortured himself then got PTSD from it.

Most things are fine when done in moderation, most things are bad when taken to the extremes.

"13 days to go" suggest this was some crazy regimen, if you would do that to prisoners I bet it's actually considered torture.

If I read about his past, it sounds to me like he might have some underlying mental health problems that would be good to address. Not by guru's, retreats, or pseudoscience, but psychologists and other professionals.

I think he does come to the right conclusion that the extremes can be very harmful. They are not that far from cults, always some guru or leader, then many people blindly following their weird practices based on absolutely nothing but pseudo science and believe, with a tendency to get more extreme (and more expensive!) the deeper you get into them.

Meditation is fine if done in moderation and as long as you don't expect it to solve all your problems. It can help with certain things, it also won't solve serious mental problems.

Working through mental health problems is no fun and a lot of work with many ups and downs, there is no easy solution, there are no shortcuts. Get professional help, get therapy, get medication if needed, be kind to yourself, and just keep working at it one step at a time.

codeptualize··on Ask HN: Is anyone else getting AI fatigue?
Haha that's amazing. This is exactly what I mean, for the right use cases it's absolutely amazing.

Good luck with the drama! Make sure to read a summary for the next family meeting haha.

codeptualize··on Ask HN: Is anyone else getting AI fatigue?
Thanks! Very interesting. I guess our challenge will be surviving the inevitable dip.
codeptualize··on Ask HN: Is anyone else getting AI fatigue?
You are probably right, kinda sad.

My last resort is to just remove all AI references from my marketing and just deliver the product.

codeptualize··on Ask HN: Is anyone else getting AI fatigue?
> complex genomics papers

I think it's fair to say this is not one of the use cases where it shines. It's not great at logic, it's also not that smart.

That's exactly what the hype does. Too big claims and then it gets dismissed when it inevitably doesn't live up to the hype.

codeptualize··on Ask HN: Is anyone else getting AI fatigue?
I think this is sort of the other side of the hype, totally dismissing it is also incorrect imo.

Yes, it's overhyped, but it's not useless, it actually does work quite well if you apply it to the right use cases in a correct way.

In terms of accuracy, in ChatGPT the hallucination issue is quite bad, for GPT3 it's a lot less and you can reduce it even further by good prompt writing, fine tuning, and settings.

Can we just recognize it for what it is?

codeptualize··on Ask HN: Is anyone else getting AI fatigue?
I'm working on a project that uses GPT-3 and similar stuff, even before the hype. I think the overhype is really tiring.

Just like with most of these hype cycles there is an actual useful interesting technology, but the hype beasts take it way overboard and present it as if it's the holy grail or whatever. It's not.

That's tiring, and really annoying.

It's incredibly cool technology, it is great at certain use cases, but those use cases are somewhat limited. In case of GPT-3 it's good at generative writing, summarization, information search and extraction, and similar things.

It also has plenty of issues and limitations. Lets just be realistic about it, apply it where it works, and let everything else be. Now it's becoming a joke.

Also, a lot of products I've seen in the space are really really bad and I'm kinda worried AI will get a scam/shitty product connotation.

← PreviousPage 7 of 15Next →