"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
@lunarmagpie430515 сағат бұрын
😂
@pixl_xip16 сағат бұрын
"And the sausage stops growing" Never heard that one
@Whateverworksism14 сағат бұрын
Thanks for all you do Andreas and also thanks for uploading to youtube, I enjoy it. I wish you a good weekend.
@awesomekling14 сағат бұрын
Thanks for stopping by! I wish you a good weekend as well
@theevilcottonball3 сағат бұрын
\x1b[0;30mIs this how you do it?
@theevilcottonball3 сағат бұрын
color now?.
@theevilcottonball3 сағат бұрын
How did you color :^) and how did you do it that when I copy it I only get "caret"
@pp00ww7 минут бұрын
@@theevilcottonball You have to become a channel member to use that emoji.
@relakin9 сағат бұрын
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!
@sammmba16 сағат бұрын
Careful with the `typeof R === 'object'` because in javascript `null` is also an object!
@REALsnstruthers8 сағат бұрын
interestingly enough, this is actually more of a misfeature than a bug. in the earliest javascript engines, there was a feature called “liveconnect” which allowed for direct interoperability with java classes. unfortunately, because all java objects are nullable & in spite of javascript already having undefined (in practice if not necessarily defined as a keyword until quite a bit later), javascript ended up with an empty, nonexistent object called null which technically has a typeof object
@RubenKelevra14 сағат бұрын
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. :)
@Daktyl1987 сағат бұрын
I'm sure he knows. This sounded a whole lot more like a "I wonder if this would work" type of thing.
@somebodystealsmyname15 сағат бұрын
The bitmask optimization should go into LB regardless of the other tests you did.
@awesomekling15 сағат бұрын
Certainly yeah, just gotta clean it up!
@somebodystealsmyname14 сағат бұрын
@@awesomekling That optimization was not that hacky, should be easy to polish up.
@michal_havlicek16 сағат бұрын
Well Hello Andreas!
@awesomekling16 сағат бұрын
Well Hello Michal!
@miko00714 сағат бұрын
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
@GabrielSoldani11 сағат бұрын
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.
@Bobbias6 сағат бұрын
That was my thought too. But still, performance isn't really the current top priority, and if it turns out in the future that this code ends up as a candidate for optimization in the future maybe it will eventually be rewritten in C++ with better optimizations. I think this was really just intended as an experiment (and something that would make for a good video).
@kingkonefpv45532 сағат бұрын
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.
@knobbymcfeck15 сағат бұрын
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...?
@awesomekling15 сағат бұрын
Oh yes, you are absolutely right! So the code was buggy. With that fixed, performance doesn’t change though :) Great observation dude!
@knobbymcfeck3 сағат бұрын
@@awesomekling Woohoo! Thanks! For everything! I love these videos, thank you so much, tussentack!
@pigalex13 сағат бұрын
here's another crazy idea you might consider: rewrite the UI (e.g the address bar area) in HTML. that would reduce dependence on Qt and would help with porting (could also make a desktop/tablet HTML UI and a mobile/vertical UI)
@spiritofstar5 сағат бұрын
Yes, Firefox and Edge do it and they are relatively successful
@Bobbias6 сағат бұрын
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).
@Derrickasaur9 сағат бұрын
Swift vs Rust solved = just use JavaScript
@ninadsachania365215 сағат бұрын
Nice video, AK! Why did you change your OS from Linux to macOS? Just curious.
@awesomekling15 сағат бұрын
I really missed the Instruments profiler, so I bought a MacBook Pro and started using it :)
@ninadsachania365215 сағат бұрын
@@awesomekling I also noticed that you started using a debugger instead of printf() debugging. What changed?
@awesomekling14 сағат бұрын
Trying to use some new tools! But I still use printf debugging every day :)
@su1cedek13 сағат бұрын
Thank you, I was missing your longer videos
@Entarra15 сағат бұрын
Curious to know if the c++ version could also cache its work and be faster still
@awesomekling15 сағат бұрын
There’s definitely ways to achieve that, but then we’d lose out on the comfy vibes of writing JS in JS! 😎
@thislooksfun115 сағат бұрын
I was wondering that too! That seems like it would have a more profound impact to me, but maybe there's some limitation as to why that's not easy to do. I might spend some time this weekend messing around with it though.
@Entarra11 сағат бұрын
@@awesomekling Hah, well then by all means :)
@jeffalonet8 минут бұрын
just curious, in macos, how are you dragging the window from anywhere?
@fredleckie588016 сағат бұрын
Huzzah! A Stag beetle and a Scarab beetle?
@msclrhd15 сағат бұрын
IIRC, both Mozilla and Google implement some of the JS functions in JavaScript.
@awesomekling15 сағат бұрын
Yeah, WebKit as well. It does make a lot of sense :)
@StevenHokins3 сағат бұрын
Very interesting, thank you for video of prototyping this
@perotubinger15 сағат бұрын
I might totally missed this, but why couldn't you just use the flags substring and return that? And after you extracted the flags to a bit mask, couldn't you use that to make the native C++ accessor faster?
@msclrhd15 сағат бұрын
The JavaScript spec specifies a flag order so if you say /foo/gi or /foo/ig then flags will return the same value in both cases. This is useful for checking in JS if two RegExp objects have the same flags, etc.
@cxboog15 сағат бұрын
Because javascript is optimisation's worst enemy; that behaviour is required by the spec (also) because the user is allowed to subclass RegExp and override...almost everything, even the pattern string itself.
@nordern114 сағат бұрын
@@cxboog True, but it's fairly safe to assume that, most of the time, it will be invoked on a native RegEx object without overrides. Maybe there could be a fast path in that case?
@perotubinger14 сағат бұрын
@@msclrhd ah, makes sense. That's what I meant by "I might have totally missed this" :)
@cxboog14 сағат бұрын
@@nordern1 yeah there's tons of these optimisation opportunities!
@JamesGroom13 сағат бұрын
Since there are only 8 flags, that means there are 256 possible string values, so can't you precompute those and use a LUT?
@fritz179816 сағат бұрын
WHF! Very interesting and hackish, love it!
@Sosisoos16 сағат бұрын
Sorry for the off-topic question, but do you see yourself returning to Serenity sometime?
@awesomekling16 сағат бұрын
Not anytime soon. I have a browser to build!
@Oarix2416 сағат бұрын
@@awesomekling❤
@FredClausen16 сағат бұрын
WHF!
@awesomekling16 сағат бұрын
Well Hello Fred!
@BrazilMentionedHueHue16 сағат бұрын
How has been your experience with copilot so far?
@awesomekling16 сағат бұрын
Love it! Don’t think I’ll ever go back to programming without LLM autocomplete. So much less friction, especially when doing less interesting tasks. :)
@XeZrunner12 сағат бұрын
It makes so much more sense to use LLMs as autocomplete helpers instead of fully writing entire files/classes/functions with them. After all, they're basically super good word/token predictors behind the curtains.
@Siminfrance5 сағат бұрын
Wouldn't optimising the c++ code be more beneficial in the long run?
@markbauermeister54497 сағат бұрын
When I wanna "cache" something in my C++ game engine I just write it to an unordered map and load it back from there later. Not sure how accepted that is as a solution, since I'm not the most proficient C++ dev.
@dennisheij879311 сағат бұрын
Couldn't you use the flags enum to create the flags string from C++?
@aiuno15 сағат бұрын
Hey! Haven't watched in a bit. When/why did you switch to Mac?
@TheRealFallingFist14 сағат бұрын
I believe he was always on Mac, running SerenityOS in a VM. But he's put creating Serenity on hold, since he's focusing on the Ladybird browser exclusively right now.
@TBasianeyes13 сағат бұрын
@@TheRealFallingFist Nah, he worked on Ubuntu for years. The latest Macs just compile so much faster than anything else so why wouldn't you use that.
@charleyramm19 сағат бұрын
I enjoyed that very much!
@Tabonx_15 сағат бұрын
Where would I even start to learn this kind of wizardry? As an iOS dev, it all feels so foreign. I barely touch the terminal, and mixing languages, especially the way you did here, seems impossible to me.
@awesomekling15 сағат бұрын
Try doing new things just outside your comfort zone every week :)
@ferdynandkiepski50262 сағат бұрын
And touching the terminal is quite useful. You could see how he forced himself away from lldb.
@ferdynandkiepski50262 сағат бұрын
Would the length of the regexp have an impact on the speed? I could see this being where JS gets slower. Your regexp was very short and quite sane. What people create with regexp isn't sane.
@awesomekling58 секунд бұрын
The regular expression itself will still be evaluated by the same C++ regex engine we have. We're not implementing a regex engine in JS :)
@doyouwantsli96804 сағат бұрын
Js with good usage of sqlite is faster than c++ with poor usage of a db (especially a more bloated one)
@ChillerDragon2 сағат бұрын
Catchy title hehe
@alexander329316 сағат бұрын
Doesn't V8 even have a "custom language" to do this?
@aetube16 сағат бұрын
Well that's debatable
@inukonet2 сағат бұрын
Why not just return the inner flags string?
@inukonet2 сағат бұрын
Ah the flags property has a defined order and the input flags param can be in any order. Hm bizarre, returning the u32 flags to cpp should be faster still. Anyways, i like the idea od pushing stuff to js, as that makes you “dogfood” your js runtime and thus have (another) reason to make it fast.
@GodlyBuTcheR15 сағат бұрын
Well Hello!
@SachinDolta16 сағат бұрын
Good one
@asphexor14 сағат бұрын
This is mad hacking video!
@my_name_is_ahad14 сағат бұрын
I like your desktop wallpaper.
@TheHanutaXD14 сағат бұрын
Wait, why does this video have so many dislikes? At least RYD thinks it is disliked :/
@awesomekling14 сағат бұрын
This video currently has zero dislikes. Your extension is just showing you a random number :)
@TheHanutaXD14 сағат бұрын
@@awesomeklinggood to hear :) seems like it is 50/50ing for some reason
@TobyAsE12054 минут бұрын
whk! js hacking, very fun!
@ericdanielski480216 сағат бұрын
Nice video.
@nopair568813 сағат бұрын
no way ?
@underflowexception14 сағат бұрын
TIL: vim !$
@ankk9813 сағат бұрын
!$ in bash refers to the last argument of the previous command. It's a quick way to reference and reuse the last parameter from your previous command.
@Oarix2416 сағат бұрын
MORE OF SerenityOS PLZ
@deckard5pegasus67314 сағат бұрын
I only watched until 7:00 but as soon as you said it was a problem with C not caching previous gets, I stopped the video. In those cases I do something similar this, and problem solved. I have a bit field to see if the get has been previously called, and another bit field to for the boolean get values. This is "old republic" C, if you don't like bit fields and bit manipulation, just use an array of booleans, or whatever, although it's less memory efficient. Maybe I should have watch the entire video, because maybe this isn't what you are looking for, but I didn't have time for an hour video today. bool getFlag(RegExpObject* regexp, const String& flagName) { static char FlagNames[][16] = { "global","ingoreCase", "multiline", "sticky", }; static int numFlags = sizeof(FlagNames) / sizeof(FlagNames[0]); static int RegExpFlags = 0 , RegExpCached = 0; for(int i=0; i> i) & 1)) { RegExpCached |= (1 get(flagName))) RegExpFlags |= (1 > i) & 1); } } printf("error not found"); return false; }
@Bobbias5 сағат бұрын
Maybe you should have paid a bit more attention to what he was saying before you stopped the video, because it wasn't that the flags themself aren't cached. The issue is that a property access requires walking the prototype chain to find where the property actually exists, and in C++ there is no cache in the property lookup function, so they're forced to walk that chain every time. JS caches that part of the property lookup process. He also did use a bitfield to hold the actual flags because he discovered that the flags were being stored as a string and each lookup was calling contains() to search for each letter, but that was after moving to JS to take advantage of the property lookup caching.