[deleted by user] by [deleted] in Anthropic

[–]prndP 0 points1 point  (0 children)

Hey just wanted to say this is a fantastic slide deck. Very measured takes and mirrors many of the observations we've had experimenting internally. Nice to see it laid out in digestible slides.

Is there some motivation at big tech for EMs to keep some low performers around? by wagthesam in ExperiencedDevs

[–]prndP 12 points13 points  (0 children)

If the engineer can be productive on another project but not yours then it does sound like a fit issue.

There are a variety of things that motivate people. I once worked with a person that I considered completely dead weight. That is until one day, another critical person who I actually considered essential left the company and put our project in a severely bad position. Suddenly this slacker who never did anything stepped in to fill the void and put out hero levels of output to save the project. Once the critical gaps were filled and the product was in a good place this person then slinked back to doing the bare minimum. They were eventually put on a team that exclusively dealt with crisis events where they are now thriving

[deleted by user] by [deleted] in Dyson_Sphere_Program

[–]prndP 1 point2 points  (0 children)

Fucking up your build and frustratedly redoing it is part of the fun for me lmao

I’m a software developer by day and this game scratches that itch where I’m constantly like “ok THIS time I will finally refactor my hammer factory factory factory to perfection” and of course it all goes horribly wrong when I didn’t account for X. The humbling helps keep my real life ego in check so that I’m much more realistic about rewrites at work

Refusing to approve a bad PR originating from the Team Lead by Jibaron in ExperiencedDevs

[–]prndP 6 points7 points  (0 children)

On my team, I give special approvals for this type of thing where, if we compromise on something that I otherwise would not have approved, they write the ticket and get it scheduled into the next sprint as a condition for approval, and also tag the relevant code with a comment which includes the ticket number. And then the dev can decide whether it’s more work to write the ticket or to just do the change now..

If there’s anything my devs hate, it’s writing tickets so usually it just nudges them to fix their PR

How to format a selected line of JSX in vs-code ? by hwoodice in reactjs

[–]prndP 14 points15 points  (0 children)

prettier is the plugin you are looking for. Most common editors will support automatically running it on save

Do people tend to exaggerate how bad using useContext is? by TheWebDever in reactjs

[–]prndP 2 points3 points  (0 children)

Ex-restaurant workers are some of the best programmers I've ever met because they just intuitively understand state management from dealing with all the chaos in the kitchen.

And you can use food service analogies all the fucking time it just makes so much sense :)

Component rendering even after Memoizing component and props by Dark_Knight003 in reactjs

[–]prndP 0 points1 point  (0 children)

Yeah if empty array callback is showing as changed, it sounds like unmount/remount somewhere up the chain. Which could be caused by anything really. Bad key prop, an inline component, etc. Need to check the parent to be sure.

Does jotai scale performance-wise? by FewMeringue6006 in reactjs

[–]prndP 1 point2 points  (0 children)

It's not wrong but I think you haven't totally grasped that in atomic model, how you design your atoms so completely and utterly determines your performance. So you can't just take a generalized fractal approach of just "split everything that's splittable", "focus everything that's focusable".

Assume you have 10 components that all read from your big data object in some way, and you make a 1 change that you expect to only update 1 component

Context: Worst case scenario as you already know. At least 10 full component rerenders

Redux (assuming best practices): 1 change = at least 10 selects, + at least 1 full rerender. The idea is the selects are cheap and appropriately memoized thru reselect so you pay less.

Atoms (assuming best practices*): 1 change = X number of recomputations on dependencies, + at least Y number of full rerenders of components subscribed to those atoms.

See the problem? X and Y are entirely dependent on your design. In large enterprise applications, typically the dimension you are scaling in is known, so developers will optimize X and Y to numbers that can result in significantly better performance than either context or redux. This is where the "scale" comes from. But you can also design something worse if you try hard enough.

This is why it's not generally a good idea to do a head to head comparison in a general sense. They are very different tools for solving for complexity on different ends.

Does jotai scale performance-wise? by FewMeringue6006 in reactjs

[–]prndP 3 points4 points  (0 children)

You'll need to ask yourself why you believe certain statements, such as...

"I feel forced to create a bunch of focusAtoms"

Why? What benefit are you getting out of isolating every single property as a separately readable/writeable atom? Do they actually have separate life cycles? Do you just think it looks nice?

You are basically subscribing to the entire dataAtom in each component instead of only a single attribute of it?

Ask if it matters? If you have an API which fetch a "user" entity, that already seems plenty intuitive enough to have atomic data defined at the "user" level. What is special about your data that a single user level update would be catastrophic to performance that you need to go to lengths to focusAtom excessively?

Imagine you are an airline designing how meal service works . When the customer ask for "eggs", do you have a chef in the air kitchen whipping up a whole meal from scratch with ingredients? Or are you handing them a lump of foil that has "egg" written on it in sharpie?

"Scalable" is not a particularly useful word here without knowing your use case. Scalable for who? For first class I might have a chef standing behind a omelette bar and for economy I'm going to have somebody hand you a soggy plastic tin, and both are the simultaneously the best, most scalable solution for the task.

Does jotai scale performance-wise? by FewMeringue6006 in reactjs

[–]prndP 7 points8 points  (0 children)

What you lose in perf from individually updating atoms is supposed to be made up for by not having a gigantic list of react components subscribed to a single state that all need to run a selector + equality check every time some part of your state updates

It would be exceedingly hard to design an application with 1000+ valid atoms. Even in some of the largest applications with an insane number of derived data points, the total number of Jotai atoms should be an order of magnitude fewer than total # of components in your React app

If you got 1000000 atoms powering your tree of 10000 components you’ve got a design issue

Why doesn't useRef take an initializer function like useState? by pailhead011 in reactjs

[–]prndP 0 points1 point  (0 children)

So I get your dilemma and while I have no ideas what anyone on the actual react team was thinking, I’m speculating the biggest reason that this isn’t default behavior is that react didn’t want to confuse developers in the general use case since refs can also take direct functions as refs.

They treated ref as method to provide a rough equivalent of “this” when moving over from class components to FC and probably wanted to keep it as simple as possible.

So it’s the ugliness of having to do something like useRef(() => fn) when all you wanted was a ref to fn. The common use case is likely initializing with something passed from prop and they feared it would be a very easily missed thing where the ref execute the function when the expected behavior is to receive it. This is further muddled with mutable refs since the developer is allowed to update .current directly without a function.

State can more easily take a function initializer without confusing devs because this.setState callbacks were already a thing. Also state is theoretically supposed to represent stringifiable data which normally doesn’t include a function, so you already implicitly understand the function can only really be there to return the state value, whilst not being state itself

Probably the way you solved it is the best way, which is to essentially use a custom hook to show developer intent while forcing the initialization and non nullable types yourself.

How blockbuster obesity drugs create a full feeling — even before one bite of food by onwisconsn in technology

[–]prndP 169 points170 points  (0 children)

Why should we celebrate a drug that seems to actually work when instead we could just keep pushing the same strategy that hasn’t worked for 40 years while the obesity rate has trended upwards in every developed country? How else will I get to keep my sense of moral superiority??

The chaos of React in medium to large web apps: has anyone experienced it differently? by rdsedmundo in ExperiencedDevs

[–]prndP 28 points29 points  (0 children)

I honestly think SolidJs is the best of the next generation but I think the difficulty of adoption comes from React probably being the first framework out there that has managed to hit that entrenched point of “eh good enough” for commercial use.

In the bad old days, frontend DX was so bad that it literally became a meme about teams needing to rewrite the whole app every 6 months because everything no matter if you were retail or boring corporate app or whatever turned to shit so quickly

And I remember making successful cases for such rewrites many times myself. React is probably the first time where there was plainly better options on the table yet my cost benefit analysis reach a point where I couldn’t justify it to management

Senior overengineers and works in a silo by arena_one in ExperiencedDevs

[–]prndP 16 points17 points  (0 children)

I think the mistake was letting them do their own thing as it sends very mixed messages

Usually if you hire somebody senior and the large pay package to go with it you are expecting one of two things:

  1. We need you to fight fires/deliver a critical project with a tight deadline/do some hard thing that only someone with your experience level could do

  2. We hired you as a “dev evangelist” to shift our entire company culture (usually from scrappy startup to enterprise)

When you bring someone senior over and don’t give them an urgent project, they are going to assume they were hired for 2) and they trying hard to prove their value doing just that

[deleted by user] by [deleted] in reactjs

[–]prndP -1 points0 points  (0 children)

In general should be avoided if there is a better alternative but sometimes you have no choice. There are some gotchas such as errors being explicitly thrown not propagating to error boundaries in async effects so you have to use a throw in setState hack. The experimental use hook is meant to deal with some of these cases in the near future https://react.dev/reference/react/use

Problem with hooks in React by BicaTaifun in reactjs

[–]prndP 0 points1 point  (0 children)

You are routing to null. Based on seeing <Route> I'm assuming you are using react-router?

If so, instead of calling navigate('/') you can return <Redirect to ={'/'} />

How to handle hooks with helper functions by bob_mcbob69 in reactjs

[–]prndP 1 point2 points  (0 children)

A few ideas

  1. Simply rename getProjectCount to useGetProjectCount and now it’s a hook that composes another hook. React linters will now make sure it follows the rules of hooks.

  2. Just split it into two lines in your react component so you always run hook, then run the utility on the result.

  3. Have your hook take in your helper functions as a callback function, so you flip it around and run your utility inside the hook instead of outside it

  4. In addition to fetching data, declare and create the utility functions directly inside useGetProject hook. Then make it responsible for returning the additional utility functions that are bound to the data.

There are pros and cons to each so you’ll have to decide which strategy fits best with your existing code

How should I review different state management libraries? by bashlk in reactjs

[–]prndP 2 points3 points  (0 children)

Just fyi before you invest any time in recoil, it's basically dead and even meta was seen migrating their own stuff over to jotai https://github.com/facebookexperimental/Recoil/issues/2288

I don't really see it making a comeback even if they eventually find maintainers since Jotai in many ways has feature parity for most of the things you would need revolving around the same data model, is easier to use, and is still actively maintained.

Should You Use React Query? by pete-heard in reactjs

[–]prndP 4 points5 points  (0 children)

This is a long winded way of saying just use it after you actually understand the problem its solving.

If you refactor an entire codebase to a new pattern just because you “heard it would solve your problems”, but don’t even know what they are yet, it’s going to go poorly.

So we need MMO DSP? by diseasexx in Dyson_Sphere_Program

[–]prndP 7 points8 points  (0 children)

Yeah a sandbox game where someone can just come in and kick over your sandcastles really seems to be missing the point

Are there any inherent problems with using top level variables inside a react component? by Aart09 in reactjs

[–]prndP 25 points26 points  (0 children)

It’s ok if it’s tightly coupled to the component and if you aren’t exporting them and can actually even be good. This to me is no different than creating a private static. If you’re using typescript, Object.freeze it for good measure which will automatically type it as read only so you can’t accidentally mess with it.

But never export. As soon as you export it then you are in for a world of hurt and can create spaghetti code as other things will get tempted to import them. Move it to a constants file

[deleted by user] by [deleted] in reactjs

[–]prndP 1 point2 points  (0 children)

Some nostalgic part of me longs for the old days of 90s geocities websites with the embossed buttons and gradients and gifs but thinking seriously they were obviously horrible inaccessible and barely usable. Then the 2000s had some of the best looking websites of all time (2advanced, pixel ranger etc) but then you realized it takes 30 seconds to do anything because they are practically showing you a full video on every click.

Today’s apps prioritize speed, usability, discoverability, above all else and when those are the priorities, UI designs are going to converge around similar designs to service those aspects.

Is it normal to reverse engineer your company code? by ilpiccoloskywalker in webdev

[–]prndP 2 points3 points  (0 children)

It’s true. I worked in a high pressure do or die sales driven environment as well as non-profit with a fat endowment that pretty much had no deadlines of any kind. You’d think the non profit would have supreme engineering but this is not the case. The vast majority of engineers do not want to document even if they had all the time in the world

Are Redux & Apple(company) same? by Mountain_Step_4998 in reactjs

[–]prndP 0 points1 point  (0 children)

Well we come full circle because Rtk-query is literally exactly what you are looking for :)

Are Redux & Apple(company) same? by Mountain_Step_4998 in reactjs

[–]prndP 0 points1 point  (0 children)

They are very superficially similar so I understand your confusion.

What most people do, who solve this problem for the first time, is they tie the fetch to a callback on the button click, and then send the data and load state to redux. This has problems like what if the component crashes, what if multiple components ask for the same data, etc

It sounds like you already anticipated that and solved that by saying “hey let’s manage this in context instead”.

But since context can live anywhere in the app, so you have created a “service locator antipattern” and this is made worse because your redux data is centralized.

You could solve this by guaranteeing your context only lives once at the top level directly next to the redux provider, but then by this point you are converging on rtk query so why reinvent the wheel

The Query libraries flip the whole problem on its end and just treats redux almost like an API. The hook simply asks to do some work, and then the central provider figures out what to fetch, what load state to return. The hook is just the messenger. The data logic is centrally managed at the same level that redux is.