DEV Community

Discussion on: You don't need null

 
martinpham profile image
Martin Pham

Sorry but I wouldn’t consider an api which has consistent response for nullable object, as a poor implemented api..

 
loucyx profile image
Lou Cyx

Me neither, that doesn't have anything to do with null. You can just omit something when is "nullish" which translates to .... you guest it, undefined, and it has the added value that payloads are smaller 🎉

 
patroza profile image
Patrick Roza

Absence and null are different things, as said.
What constraints are you under that these minor payload sizes matter? you’ll probably get more out of gzip than omitting nullish.

 
martinpham profile image
Martin Pham

Payloads are smaller by omitting some characters, good.
But if it causes confusion between null (value is set as no value) and undefined (value is not set), I wouldn’t take it as a good thing.

 
loucyx profile image
Lou Cyx

"Absence and null are different things" ... how? The size of the payload doesn't only affect the request, also the parsing. You're literally loading something trough the wire and in memory that you could omit, just to use null X_X

Some comments have been hidden by the post's author - find out more