what the fuck
i want to make userscripts but javascript seems like an abomination the more i look into it
>>108744565functions are technically objects and by that you can also assign properties to them and do other retarded shit>>108744573>javascript seems like an abomination the more i look into itbecause it's one and 'modern' javascript are just convention where you pinky promise not to use a bigger chunk of the language features
>>108744573>i want to make userscriptsdo you also want to harvest your crops by hand?
>>108744610so you can just assign references of objects to any object with a string as the key?>because it's one and 'modern' javascript are just convention where you pinky promise not to use a bigger chunk of the language featureswut
>>108744621ive been using AI to do it but its soulless and often doesnt work
>>108744625get better ai. the models haven't had problem writing them for months now.computers are, and have always been, soulless.get a real passion, like playing an instrument or masturbating.
this is the luau equivelent
>>108744649but most of the time you dont have access to setrawmetatable so you would do it like this
>>108744646im starting to think you are a shill
>>108744659i'm actually sam altman.
>>108744565classic js.
>>108744669holy shitthis is why luau is better, it doesnt have any of that bullshit
>>108744654well you can actually just skip the other table and use the real table directlyi just forget to remove that part ig
>>108744623>so you can just assign references of objects to any object with a string as the key?i mean thats how most map/dictionary type work in other languages, that has nothing to do with being able to treat a function as an object and assigning random properties to it>wutthe language was created in 3 days and has a bunch of regrettable parts in. it's best to just ignore the more dynamic parts and not bother with prototypes
>>108744673Yeah but anything is better then JS.
>>108744565What's your problem with prototypes?
>>108744683>i mean thats how most map/dictionary type work in other languages, that has nothing to do with being able to treat a function as an object and assigning random properties to itin most sane languages only objects that have the purpose of storing references to other objects can do said thing>the language was created in 3 days and has a bunch of regrettable parts in. it's best to just ignore the more dynamic parts and not bother with prototypessomeone should make a better standard
>>108744685fair
>>108744689?
>>108744702??
this is why python is Superior
>>108744669>gais look this old ass scripting language has no typesafety and you can use type coercion to do le funnieit's literally the reason why typescript exists and people dunk on js' type coercion issues without even understanding why they happen. it's reddit tier "humor".
>>108744692I mean look at this shit kek...
>>108744565>console.logNobody reads the console log on the web browser thoever. You barely need it for debugging too. I never had to use it to debug before.Lol.
>>108744716dealing with floats....
>>108744707whats a prototype in javascript
I still love JS and I see you people do too when you make threads about it :-)
>>108744690>in most sane languages only objects that have the purpose of storing references to other objects can do said thingit's actually pretty typical for dynamic languages or ones that have built in runtime reflection, also js is not sane lol>someone should make a better standardthere is one but they just can't deprecate the old stuff immediatelly>>108744713you can do the same with in python with __call()__
>>108744713>significant whitespacekys
>>108744727It's everything brother... it's fucking everything JS was made on meth.
>>108744715>goyscript
>>108744716Garbage in garbage out I don’t like js, I program in cpp mostly, but if you feed a function some turd what did you expect? In cpp this would be UB anyway
>>108744716holy fucking what the actual
>>108744724stupid troll
>>108744736HTML is really good so why is JS so bad then lol.
>>108744733>sane>dynamic languages or ones that have built in runtime reflectionLOL>there is one but they just can't deprecate the old stuff immediatellyname of better standard?
>>108744736its over
>>108744752My cope for this is that at start it was okay but then added complexity killed it and since they didn't give a shit it ended up like this.
>>108744673It's dumb yes, but it's just the result of weak typing and you can avoid all the pitfalls by enforcing code conventions with a linter which you should be doing anyways.For example my editor automatically changes "11"+1 to `11${1}` because my code convention doesn't allow string concatenation via the plus sign since it is confusing.
>>108744730Are you capable of using search engines?
>>108744742use luau
>>108744752>HTML is really good [citation needed]
>>108744744>pass float to function which expects a string>wonder why you get undefined behaviourhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt#using_parseint_on_non-strings
>>108744761what year did that happen anyway
>>108744736I started off writing JavaScript professionally. Looool fuck, I love me a strongly typed language. The IDE experience for Go is fuckin' tight! Can't believe I was writing all those gay console.logs so many years ago for undefined bullshit, shit like that is caught in the IDE instantly. My dick is hard just thinking about it.
>>108744763string concatenation should have its own expression thingie like in luau
>>108744766It is straightforward and so easy literally anybody could make a website in the 90s. You need more? Lol.
>>108744771>function which expects a stringthere should be no such thingyou should either be unable to call it with a string or it should just pass the string normally like in luau
>>108744774why do you torture yourself
>>108744772Im not sure but if you want here is Fireship video about JS. https://www.youtube.com/watch?v=Sh6lK57Cuk4
>>108744780i mean cool cool and all but its really not that great. its in the same tier as json which really says something
>>108744774TypeScript essentially does that for js.
>>108744776It does: `${substring1}${substring2}`
>>108744790>slopship>12 minutes for the ad revenuei would rather kill myself thank you
>>108744798slopscripttypes a are jewish
>>108744801so then why does + do it too
>>108744756>LOLfor better or worse you have to deal with it when doing web stuff, if you don't wanna use js just don't do web stuff lol >name of better standard?everything beyond ES6>>108744782>you should either be unable to call it with a string or it should just pass the string normally great there's typescript for that, even basic linters could probably figure that out too>like in luauare you autistic or whats your obsession with that language
>>108744802i mean understandable...
>>108744826>for better or worse you have to deal with it when doing web stuff, if you don't wanna use js just don't do web stuff lolunironically i think i will do exactly that>everything beyond ES6whats ES>great there's typescript for that, even basic linters could probably figure that out tooawesome>are you autistic or whats your obsession with that languageyes im autistic also its my job
>>108744830fuck these sloptubers make me madits likefuck they dont even know anythingfireship atleast tries to be "ironic" but you can tell he only does it so people dont slit his throat
>>108744812Because stupid people designed that before smarter people came up with something better.And like I said your text editor or IDE should automatically convert the old form to the new form or at least show a warning.Most shit in >>108744736 can also be avoided by not using == or != but using === and !== instead.Again something a text editor/IDE should correct automatically.
>>108744844>whats ESECMAscript, the term javscript is technically copyrighted by oracle>yes im autistic also its my jobcongrats
>>108744855>Because stupid people designed that before smarter people came up with something better.so that means languages that never had it were designed by smart people from the ground up?>And like I said your text editor or IDE should automatically convert the old form to the new form or at least show a warning.i edit in notepad.exe>Most shit in >>108744736 can also be avoided by not using == or != but using === and !== instead.its too javascriptpilled...>Again something a text editor/IDE should correct automatically.why are you fixated on thatwhat IDE do u even use
>>108744863>ECMAscript, the term javscript is technically copyrighted by oracleoh wtfso its just javascript oh ok>congratsthank you nonny :3
>>108744870>so its just javascript oh okyes but as always things grow historically so you have to somehow denote the more modern stuff that was only introduced in the last few years because the language is now 30 years old
It's a magical language.
>>108744947JS is just strange, don't bother with the details
>>108744565>:: pic ::>what the fuckYes. Functions are a special kind of object in JavaScript that derives from Function.prototype.>>108744623>so you can just assign references of objects to any object with a string as the key?Yes. Objects in JS are directable extensible with more properties. If you want to prevent that, you can seal them using the Object.seal or Object.freeze methods. The former prevents addition of further properties. The latter prevents addition of further properties OR changes to the configuration of existing properties.
>>108744947And you're not even getting to the good part yet...
>>108744565Wait until you find out that .greet is just shorthand for ["greet"] and that objects are just hashmaps, and the keys don't even have to be a string it can be another object or non-object i.e. Symbol.
>>108745192JS is also likes music NANANANANA... BATMAAAAN! kek...
>>108745211>Wait until you find out that .greet is just shorthand for ["greet"]this is really basic knowledge thothe dot is just sugar and normal indexing is with an expression between the []isnt this the case in most languages?
>>108745211>objects are just hashmapswhat else are they supposed to be if they store referencesin luau tables are also hashmaps but they can switch to arrays seamlessly depending on how you use them
>>108745211>that objects are just hashmapsand are in comparison to the newish Map type pretty inefficient ones>>108745401>isnt this the case in most languages?no not really, most other languages have a clear distinction between structs/classes and arbitrary key-value storage>>108745413>in luau tables are also hashmaps but they can switch to arrays and i thought php as the only language wish does this
>>108745413also it's better for most cases to just use classes in js
reading this thread gave me javascriptphobiahow are browsers even properly virtualized with so much bullshit
>>108744649>>108744654Ugly, ugly language
>>108744724>how did you know i use alert() for everything?
>>108744565functions are objectswhoaaa
>>108744610>because it's one and 'modern' javascript are just convention where you pinky promise not to use a bigger chunk of the language featuresTo be fair, every modern """multi-paradigm""" language is like this. So production code bases end up a horrific mish-mash of every random feature the language has to offer.I'm calling it that eventually they are going to put in keywords that restrict language features so that codebases stay more coherent.
>>108745629no why are they also hashmaps for no reason
>>108745600cope
Lisp already had this decades before JS was created.
>>108745640>I'm calling it that eventually they are going to put in keywords that restrict language features so that codebases stay more coherent.We actually already had that in the past. Browser vendors *removed it* because it caused compatibility problems with retards no longer being able to be retarded and just drop-in jQuery add-on #24833378 du-jour and just have it work, and were shitting themselves while failing to cope.
>>108744623>so you can just assign references of objects to any object with a string as the key?Well, there's Object.freeze() and browsers protect some global objects but yea, you can shim pretty much anything.
>>108745677Objects are not hashmaps, if you need hashmaps you use maphttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map>>108745640>To be fair, every modern """multi-paradigm""" language is like thisYeah i know python and java aren't much better
>>108745837java is not that terrible in hat regard, there are some language features that aren't very useful, but most of it is good enough. you can't do any of that crazy monkey patching stuff in OP for example, that's a compile error
>>108745837>Objects are not hashmaps, if you need hashmaps you use mapwow the other guy lied
>>108745941>you can't do any of that crazy monkey patching stuff in OP for exampleIm pretty sure you can do that with reflection in java, all the mocking libraries rely on that stuff
>>108745990In the past (pre 2015) maps weren't a thing and you'd actually use objects, nowadays you shouldn't unless you have to target internet explorer
>>10874473630000000000000004.compeople pointing at ieee 754 and reeing about the language will never not be retarded.
>>108746019gemini said it was invented in 1950 tho ?
>>108744565ai generated code
>>108744716shit like this is why typescript exists
>>108744744>holy fucking what the actualsetTimeout("alert(foo)", 0);
>>108744716I don't get it, what should it return?
>>108744565lol I love javascript
>>108746233yes cuz i was asking gemini questions about javascript
>>108746263what does setTimeout do
>>108744565This is how static constructor properties and methods are implemented btw
check this outfunction a () {}var o = new a()a.prototype.spooky = trueconsole.log(o.spooky)
function a () {}var o = new a()a.prototype.spooky = trueconsole.log(o.spooky)
>>108744715Typescript exists for dumb people.
>>108744649That sets __index for all functions, not just that function.
>>108749967it doesnt tho cuz ur setting a new metatable to the functioni dont think functions even have ab metatable by defsult
>>108746003kinda kinda not; the ways what you think happens does happen is way more involved and not at all a 2-linertypically you can do two things for monkey-patching:1. declare and implement a subclass at runtime, and swap out references, overriding methods to do something else2. exclusively with interfaces (traits, in other languages), you can use https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/reflect/Proxy.html to do roughly the same thingthe big difference is that it's very visible, and doesn't have a global scope; you can't monkey-patch core libs and affect 3rd-party code (unless they specifically write that code to allow it; like one does when using mocking libraries)so no, languages like JS and Ruby are exceptionally egregious in that regard, and it's absolutely not standard by any means whatsoever
>>108750434to account for akshyuallys, you can also use stuff like aspectj (aka AOP), but that's essentially the equivalent of attaching a debugger and placing breakpoints to do various thingsand just like attaching a debugger would, it requires explicit actions, is opt-in (and even needs compiler flags, typically) by the application, and can't creep out from a random library like prototype pollution can in monkey-patching langs
>>108744573>>108744625something to block youtube live redirects/ "raids" would be neat
in common lisp that is just (defun greet () (print "Hello!"))(setf (get 'greet :language) "English")(print (get 'greet :language))(greet)
(defun greet () (print "Hello!"))(setf (get 'greet :language) "English")(print (get 'greet :language))(greet)
>>108750555why
>>108744736(((brendan eich))) was a mistake
>>108750569so I could fall asleep to a cozy streamer and not get raided into a LOUD==FUNNY typep.s. twitch is absolute garbage so don't even recommend it
>>108744625>often doesnt workI just oneshot a ~5kloc .m3u / .m3u8 extractor to rip totally-not-porn links, complete with extracting the links from multiple playlists, sorting it by quality etcand that's with bargain bin $20 sub, not the paypig $200 oneuserscripts and simple, contained tasks are literally the perfect fit for ai sloppa.
>>108750579i wonder what the world record for longest raid chain is
>>108744565>>108744610The retarded part is not that you can add properties to functions. The retarded part is that assignment creates properties. So if you made a typo it will just silently create a new property. Of course it's dogshit for performance too.
>>108750434>the ways what you think happens does happen is way more involved and not at all a 2-linerI said that it's possible not that it's easy to monkey patch by hand without any supporting libraries, i just remembered that because a prof back in uni gave us the assignment to do something along the lines to show what fun stuff you can do with reflection (and annotations)
>>108744565what else would you expect?
>>108744866>what IDE do u even use>asking that question>not assuming he uses a jetbrains IDE as any professional wouldCome on man
>>108744565what's wrong with it, it's justpublic class Greeting { public string Language = "English"; public override string ToString() { return "Hello!"; }}
public class Greeting { public string Language = "English"; public override string ToString() { return "Hello!"; }}
>>108744565Let me guess, it just creates a class in the background?
>>108744565This actually good and useful if you don't have a room temperature IQ.