News for hackers. Stuff that matters.
Re:I made JSON.parse() 2x faster by MichaelNozbe on Saturday March 04, 2023 @08:25AM (#35020604)
Speed is the ultimate User Experience. Especially when it comes to exchanging JSON data which is what apps do all the time these days. Great job!
Re:I made JSON.parse() 2x faster by randyrand on Saturday March 04, 2023 @03:20PM (#35024121)
This is a great blog post with few comments. Impressive work.

Did they merge it?

Re:I made JSON.parse() 2x faster by radex on Saturday March 04, 2023 @03:30PM (#35024223)
Thanks! There's a preliminary PR with a discussion here: https://github.com/facebook/hermes/pull/933 (and broader context here: https://github.com/facebook/hermes/issues/811 ). But we'll see if there's any interest on Hermes' side to merging it. They definitely want to improve the parser, but it's unclear to me if they want to take on the simdjson/simdutf dependencies.
Re:I made JSON.parse() 2x faster by KomoD on Saturday March 04, 2023 @03:29PM (#35024215)
I quite enjoyed this blog post to be honest
Re:I made JSON.parse() 2x faster by radex on Saturday March 04, 2023 @03:31PM (#35024229)
Appreciated!
Re:I made JSON.parse() 2x faster by mfbx9da4 on Saturday March 04, 2023 @03:35PM (#35024266)
Nice little rabbit hole you ended up in!
Re:I made JSON.parse() 2x faster by aabdelhafez on Saturday March 04, 2023 @04:17PM (#35024581)
Re:I made JSON.parse() 2x faster by Waterluvian on Saturday March 04, 2023 @05:54PM (#35025319)
This is delightful!

Maybe next you can make the object spread operator faster ;). I was recently bitten by it in a hot loop, thinking it was generally syntactic sugar. Turns out that if I know all the property names in an object, it’s far far faster to just assign them all manually.

Re:I made JSON.parse() 2x faster by radex on Saturday March 04, 2023 @06:01PM (#35025377)
That could be interesting! Curious: are you taking about a plain object spread, or are you talking about JSX spreads? The latter has more overhead. Also, which JS engine?

BTW. I recently measured the spread operator in a microbenchmark. Interestingly, while the native spread was faster on Hermes and JSC, it was slower on V8/Chrome, and it's faster there to use `Object.assign()`, i.e.:

['@babel/plugin-proposal-object-rest-spread', { loose: true, useBuiltIns: true }]

Re:I made JSON.parse() 2x faster by v0idzer0 on Saturday March 04, 2023 @07:08PM (#35025797)
Doesn’t assigning properties behave differently? Spread creates a new object while assigning reuses the existing. Unless you mean creating a new object and then assigning the properties. I’d be surprised if that performed worse though. Also curious if the properties are primitives?
Re:I made JSON.parse() 2x faster by pcthrowaway on Saturday March 04, 2023 @08:24PM (#35026203)
I wonder if you can just configure this as part of the compile step with typescript, when the object you're spreading has a known type
Re:I made JSON.parse() 2x faster by bblackwood on Saturday March 04, 2023 @07:40PM (#35025993)
Great blog post! As someone who isn't particularly familiar with javascript internals (or many language internals for that matter), this was really easy to follow and a lot of fun.
Re:I made JSON.parse() 2x faster by i-use-nixos-btw on Saturday March 04, 2023 @08:01PM (#35026100)
See, this is the difference between a productive engineer and a purist.

You are a productive engineer. You see a fast library that needs a different encoding, so your first thought is to add a transcoding step and make a 2x gain in a short timeframe.

I am a purist. I see a fast library that needs a different encoding, and my first thought is “ok, I’ll fork that library and make it work with UTF-16 natively”. 24 months later I’ll be found, bearded down to my kneecaps, staring at the bottom of a bottle of scotch, mumbling a mixture of curse words and “PowerPC”. But Id get a 2.05x speedup eventually, so…

Re:I made JSON.parse() 2x faster by radex on Sunday March 05, 2023 @10:20AM (#35030315)
Thanks for the chuckle :D And of course you use nixos :]