Can we use JavaScript to go faster than C++ in Ladybird?

preview_player
Показать описание
Today we try out an interesting idea.. Let's see if it pans out!

Рекомендации по теме
Комментарии
Автор

"And the sausage stops growing" Never heard that one

pixl_xip
Автор

"Implement parts of our JS engine in JS and gain performance benefit from it"

...writing down to my notebook of sentences that have not been uttered ever

egemengol
Автор

Thanks for all you do Andreas and also thanks for uploading to youtube, I enjoy it. I wish you a good weekend.

Whateverworksism
Автор

Yes! Finally got an hour long video. There is no other channel that I can just sit and watch someone for an hour straight and still wish that the video was longer. Thanks for posting!

relakin
Автор

These are interesting beyond any reason, thank you so much for making them still. Been here for over 4 years when i had just started uni, your videos of you in the car inspired me a lot. I adopted your C++ style and a lot of the commit etiquette, and of course changed it to fit my needs. I'm happy in a job now, finished uni, and am married, and I think these videos are one of the few things that keeps bringing me joy and gives me new things to learn, even if they're small things sometimes.
Thanks for making these. I doubt you remember my comments from 4 years ago, you responded to them, I always had a good time here :)

lionkor
Автор

Careful with the `typeof R === 'object'` because in javascript `null` is also an object!

sammmba
Автор

Just curious, why not make object_get from C++ benefit from the cache instead? It’s probably even faster, and speeds up every call rather than just the ones on this specific built-in you’ve ported.

GabrielSoldani
Автор

I mean, you could also compile those to byte code while compiling lb, so you don't have to compile them to byte code on execution. :)

RubenKelevra
Автор

Don't those flags need to be left-shifted on creation, or in the enum? It's been ages since I did C++, so maybe I'm misunderstanding...?

knobbymcfeck
Автор

i may be missing something here, but if those flags are basically immutable after the regexp object is created, why dont you build that string on object creation and just ask for it later?

you could even build a lookup table with all possible strings and use that bitfield to index it. then you just can return a reference to the string and save on memory big time

miko
Автор

very cool experiment! I remember recommending this some time ago so I am really interesting to see how it would go

solcloud
Автор

Since there are only 8 flags, that means there are 256 possible string values, so can't you precompute those and use a LUT?

JamesGroom
Автор

My initial thought when seeing the JS was to use an array and join them instead of doing the string manipulation for every flag, you then mentioned the string concat exactly when I was about to comment so you were ahead of me 🤠

Автор

The bitmask optimization should go into LB regardless of the other tests you did.

somebodystealsmyname
Автор

Nice video, AK!

Why did you change your OS from Linux to macOS? Just curious.

ninadsachania
Автор

It makes perfect sense that avoiding the contains() should make best and worst case closer in speed.

Unless I'm mistaken checking every flag would be O(nm) where n is the number of flags on the Regex and m is the number of flags to check against. Turning the flags into a bitmask would flatten this into O(m) since checking the bitmask is O(1) rather than contains() which is O(n).

Bobbias
Автор

Curious to know if the c++ version could also cache its work and be faster still

Entarra
Автор

Thanks that was very amusing! i wrote a lot of js when node was new and you still had to use brains to make it run fast in the browser.

kingkonefpv
Автор

I'm sorry for the off topic comment, but what tool are you using to be able to drag a window from anywhere on a Mac?

iSellEverything
Автор

Are you constructing all those buildings objects in native or is there already some javascript shim code which gets installed in the runtime, then you can add the accessor there and don’t need extra parse runs (and also it can better optimize the whole call chain if the compiler sees all code on JS stack I imagine).

berndeckenfels