Pinned Tweet
An important skill for successful software engineering is:
1) being able to tell that two or more things are in fact the same thing, thus should be called by the same name;
2) being able to tell that things with the same name in two or more places are in fact different things.
Ivan Babak retweeted
I like the way Vercel designs software, I really do. Their attention to detail and DX have been inspiring me for years.
But the decision to patch global "fetch" is borderline wrong. It even results in a poor user experience, counter-intuitively—something I feel was the sole reason of going into this slippery slope of module patching.
Okay, what's happening and why it's bad. Next patches the "globalThis.fetch" function for you. It's a globally available function to perform requests. Why? To support caching: nextjs.org/docs/app/api-refe…
And I get it, creating an illusion that you can control cache from your fetch call is neat. Until it's not. I think we as a community have learned that patching things you don't own in JavaScript is a terribly bad idea ever back in jQuery days. I leave the googling to you to educate yourself.
Briefly, it's bad for two main reasons.
First, it misleads the user. It's fair to say that 99% of Next users have never read the Fetch API specification. No shame in that. But what we use gets carved into your mind, and once Next users get used to this really neat caching API that seems to be coming from global fetch but not really, they will just confuse themselves. What will happen is those users will go to a different framework or, damn, just open their DevTools, and will expect "fetch" to handle caching. Only it won't. Because that's not what fetch does, it's not in the spec and is borderline confusing.
The second reason patching fetch is a terrible API design is that it blocks any third-party libraries that rely on module patching. See, not only Next patches fetch but it does it as the very last thing during the framework bootstrapping. This means that no third party can patch fetch themselves. "Wait, you are advocating against patching fetch but now say Next prevent other libs from doing that and it's somehow a bad thing?" Yes, precisely. Keep in mind, some packages have no other choice but to indulge in module patching. API mocking is one bright example, and I have a bit of expertise in that. There are simply no means in Node to intercept requests, so libraries patch request-issuing modules to do that. It's nasty terrible hack but, I stress it once more, there is literally no other way.
But there is a way if you are a framework designing a caching feature. In fact, there are a multitude of ways to achieve it, even preserving the "native-like" feel of that API. Here's but one example:
import { cache } from 'next'
const response = await cache('no-store', fetch(url, init))
I can't say it's a gigantic degradation of user experience, to be honest. I spent a few seconds coming up with this example, I'm certain that a team of some of the best engineers in the field can come up with a much better API here.
All the more confusing why that didn't happen.
This isn't a rant, really, just an observation of how framework features leak into standard code and harm both the users and the ecosystem in the long run. Don't modify things you don't own. That was true a decade ago, it's still true now.
Ivan Babak retweeted
this isn’t to say that every application should have its own totally bespoke database. most of them probably shouldn’t. but these things are not magical and we should remember that they’re just code, too. code we can understand and debug and modify as needed.
Ivan Babak retweeted
databases are just software. compilers are just software. cryptography is just software. operating systems are just software. if you’re a software engineer, you are capable of understanding software.
Ivan Babak retweeted
"Clean code always looks like it was written by someone who cares." – Michael Feathers
Ivan Babak retweeted
Some parts of creation (“fun”) can be painful because of boilerplate code. However, the solution to boilerplates is not LLMs but the right kinds of abstractions and good programming languages.
Ivan Babak retweeted
This is brilliant and will save devtools authors many a headache 😁
namechecker.vercel.app – at San Francisco, CA
Do I remember when I joined Twitter? No. But Twitter does! #MyTwitterAnniversary
52
Ivan Babak retweeted
I believe one of the most valuable things we can do in code reviews is improve naming.
"I'm unclear what this variable name means."
"This function's name doesn't seem to match the implementation. It looks like it does x. Can we rename it to x?"
Ivan Babak retweeted
how to have URL routes inside your scene, as well as bind webgl text to html to that it's accessible, selectable, and webgl gets to refract it.
codesandbox.io/s/router-tran…
Ivan Babak retweeted
✏️ To see if the XYZ coordinate is inside the closed mesh, we can just cast a ray from XYZ in any direction and check if the number of intersections is odd
Full explanation in the thread 🧵
Live demo & source code: codepen.io/ksenia-k/full/xxQ…
Made with @threejs
Hosted on @CodePen
Ivan Babak retweeted
Replying to @SentimentIO @Lauramaywendel
Private data members are crucial when building a framework that protects the data it manages from misuse by many engineers using the framework. The getters layer is required to validate authorization to read the data; setters, to write. But building such frameworks is uncommon.
Ivan Babak retweeted
The most effective software engineers I know always had a tendency to revert to writing "C" style code.
Nothing seems to come close in terms of readability / maintainability.
Ivan Babak retweeted
Replying to @shamwhoah
Yes, exactly! The "error path is out of sight, out of mind" rubs me the wrong way.
Possible error states should be explicit, you should be forced to consider them, even if you decide to ignore them. Right now it's implicit, which makes it so easy to forget that it can go wrong
Ivan Babak retweeted
The thing I mainly miss from TypeScript is error typing.
I want to see from a type definition of a function if it can throw, and I want to see _what_ it can throw.
I find TypeScript a great language, but this is the biggest thing I miss when writing it.
Ivan Babak retweeted
If you're working in a TS codebase make sure you have these lint rules enabled, these just caught several serious bugs in a 5+ year old codebase 😬





















