[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: file.png (35 KB, 877x336)
35 KB PNG
what the fuck
>>
i want to make userscripts but javascript seems like an abomination the more i look into it
>>
>>108744565
functions 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 it
because 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 userscripts
do you also want to harvest your crops by hand?
>>
>>108744610
so 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 features
wut
>>
>>108744621
ive been using AI to do it but its soulless and often doesnt work
>>
>>108744625
get 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.
>>
File: file.png (70 KB, 768x426)
70 KB PNG
this is the luau equivelent
>>
File: file.png (164 KB, 1920x1080)
164 KB PNG
>>108744649
but most of the time you dont have access to setrawmetatable so you would do it like this
>>
>>108744646
im starting to think you are a shill
>>
>>108744659
i'm actually sam altman.
>>
>>108744565
classic js.
>>
>>108744669
holy shit
this is why luau is better, it doesnt have any of that bullshit
>>
>>108744654
well you can actually just skip the other table and use the real table directly
i 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
>wut
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 prototypes
>>
>>108744673
Yeah but anything is better then JS.
>>
>>108744565
What'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 it
in 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 prototypes
someone should make a better standard
>>
>>108744685
fair
>>
>>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 funnie
it'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".
>>
File: file.png (14 KB, 773x269)
14 KB PNG
>>108744692
I mean look at this shit kek...
>>
>>108744565
>console.log
Nobody 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.
>>
>>108744716
dealing with floats....
>>
>>108744707
whats a prototype in javascript
>>
File: 1756571059960552.png (837 KB, 1006x670)
837 KB PNG
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 thing
it'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 standard
there is one but they just can't deprecate the old stuff immediatelly
>>108744713
you can do the same with in python with __call()__
>>
>>108744713
>significant whitespace
kys
>>
File: javascript total.jpg (52 KB, 632x715)
52 KB JPG
>>108744727
It's everything brother... it's fucking everything JS was made on meth.
>>
>>108744715
>goyscript
>>
>>108744716
Garbage 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
>>
>>108744716
holy fucking what the actual
>>
>>108744724
stupid troll
>>
>>108744736
HTML is really good so why is JS so bad then lol.
>>
>>108744733
>sane
>dynamic languages or ones that have built in runtime reflection
LOL
>there is one but they just can't deprecate the old stuff immediatelly
name of better standard?
>>
>>108744736
its over
>>
>>108744752
My 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.
>>
>>108744673
It'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.
>>
>>108744730
Are you capable of using search engines?
>>
>>108744742
use luau
>>
>>108744752
>HTML is really good [citation needed]
>>
>>108744744
>pass float to function which expects a string
>wonder why you get undefined behaviour
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt#using_parseint_on_non-strings
>>
>>108744761
what year did that happen anyway
>>
>>108744736
I 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.
>>
>>108744763
string concatenation should have its own expression thingie like in luau
>>
>>108744766
It is straightforward and so easy literally anybody could make a website in the 90s. You need more? Lol.
>>
>>108744771
>function which expects a string
there should be no such thing
you should either be unable to call it with a string or it should just pass the string normally like in luau
>>
>>108744774
why do you torture yourself
>>
>>108744772
Im not sure but if you want here is Fireship video about JS.
https://www.youtube.com/watch?v=Sh6lK57Cuk4
>>
>>108744780
i mean cool cool and all but its really not that great. its in the same tier as json which really says something
>>
>>108744774
TypeScript essentially does that for js.
>>
>>108744776
It does: `${substring1}${substring2}`
>>
>>108744790
>slopship
>12 minutes for the ad revenue
i would rather kill myself thank you
>>
>>108744798
slopscript
types a are jewish
>>
>>108744801
so then why does + do it too
>>
>>108744756
>LOL
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 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 luau
are you autistic or whats your obsession with that language
>>
>>108744802
i mean understandable...
>>
File: file.png (39 KB, 371x308)
39 KB PNG
>>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 lol
unironically i think i will do exactly that
>everything beyond ES6
whats ES
>great there's typescript for that, even basic linters could probably figure that out too
awesome
>are you autistic or whats your obsession with that language
yes im autistic also its my job
>>
>>108744830
fuck these sloptubers make me mad
its like
fuck they dont even know anything
fireship atleast tries to be "ironic" but you can tell he only does it so people dont slit his throat
>>
>>108744812
Because 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 ES
ECMAscript, the term javscript is technically copyrighted by oracle
>yes im autistic also its my job
congrats
>>
>>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 that
what IDE do u even use
>>
>>108744863
>ECMAscript, the term javscript is technically copyrighted by oracle
oh wtf
so its just javascript oh ok
>congrats
thank you nonny :3
>>
>>108744870
>so its just javascript oh ok
yes 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
>>
File: 1760781590700685.png (6 KB, 322x225)
6 KB PNG
It's a magical language.
>>
>>108744947
JS is just strange, don't bother with the details
>>
>>108744565
>:: pic ::
>what the fuck
Yes. 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.
>>
File: the-good-part.jpg (6 KB, 339x38)
6 KB JPG
>>108744947
And you're not even getting to the good part yet...
>>
>>108744565
Wait 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.
>>
>>108745192
JS 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 tho
the dot is just sugar and normal indexing is with an expression between the []
isnt this the case in most languages?
>>
>>108745211
>objects are just hashmaps
what else are they supposed to be if they store references
in luau tables are also hashmaps but they can switch to arrays seamlessly depending on how you use them
>>
>>108745211
>that objects are just hashmaps
and 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
>>
>>108745413
also it's better for most cases to just use classes in js
>>
reading this thread gave me javascriptphobia
how are browsers even properly virtualized with so much bullshit
>>
>>108744649
>>108744654
Ugly, ugly language
>>
File: 1753968960773948.jpg (50 KB, 1080x1350)
50 KB JPG
>>108744724
>how did you know i use alert() for everything?
>>
>>108744565
functions are objects
whoaaa
>>
>>108744610
>because it's one and 'modern' javascript are just convention where you pinky promise not to use a bigger chunk of the language features
To 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.
>>
>>108745629
no why are they also hashmaps for no reason
>>
>>108745600
cope
>>
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.
>>
>>108745677
Objects are not hashmaps, if you need hashmaps you use map
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
>>108745640
>To be fair, every modern """multi-paradigm""" language is like this
Yeah i know python and java aren't much better
>>
>>108745837
java 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 map
wow the other guy lied
>>
>>108745941
>you can't do any of that crazy monkey patching stuff in OP for example
Im pretty sure you can do that with reflection in java, all the mocking libraries rely on that stuff
>>
>>108745990
In 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
>>
>>108744736
30000000000000004.com

people pointing at ieee 754 and reeing about the language will never not be retarded.
>>
File: 1709293556815188.png (241 KB, 900x806)
241 KB PNG
>>108746019
gemini said it was invented in 1950 tho ?
>>
>>108744565
ai generated code
>>
>>108744716
shit like this is why typescript exists
>>
>>108744744
>holy fucking what the actual
setTimeout("alert(foo)", 0);
>>
>>108744716
I don't get it, what should it return?
>>
>>108744565
lol I love javascript
>>
>>108746233
yes cuz i was asking gemini questions about javascript
>>
>>108746263
what does setTimeout do
>>
>>108744565
This is how static constructor properties and methods are implemented btw
>>
check this out
function a () {}
var o = new a()
a.prototype.spooky = true
console.log(o.spooky)
>>
>>108744715
Typescript exists for dumb people.
>>
>>108744649
That sets __index for all functions, not just that function.
>>
>>108749967
it doesnt tho cuz ur setting a new metatable to the function
i dont think functions even have ab metatable by defsult
>>
>>108746003
kinda kinda not; the ways what you think happens does happen is way more involved and not at all a 2-liner
typically 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 else
2. 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 thing
the 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
>>
>>108750434
to 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 things
and 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
>>108744625
something 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)
>>
>>108750555
why
>>
>>108744736
(((brendan eich))) was a mistake
>>
>>108750569
so I could fall asleep to a cozy streamer and not get raided into a LOUD==FUNNY type
p.s. twitch is absolute garbage so don't even recommend it
>>
>>108744625
>often doesnt work
I 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 etc
and that's with bargain bin $20 sub, not the paypig $200 one
userscripts and simple, contained tasks are literally the perfect fit for ai sloppa.
>>
>>108750579
i wonder what the world record for longest raid chain is
>>
>>108744565
>>108744610
The 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-liner
I 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)
>>
>>108744565
what else would you expect?
>>
>>108744866
>what IDE do u even use
>asking that question
>not assuming he uses a jetbrains IDE as any professional would
Come on man
>>
>>108744565
what's wrong with it, it's just
public class Greeting {
public string Language = "English";
public override string ToString() {
return "Hello!";
}
}
>>
>>108744565
Let me guess, it just creates a class in the background?
>>
>>108744565
This actually good and useful if you don't have a room temperature IQ.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.