Programming Memes Thread


  • FoxDev

    @Applied-Mediocrity said in Programming Memes Thread:

    @accalia No. A key is not equivalent to an index. Keys identify elements. Indices describe the position of elements.

    You've clearly not done much javascript programming, or if you have you havent bothered to understand the base rules of the language. In JS arrays are Arrays and objects are Objects.

    because of inheritance (granted prototypical inheritance rather than archetypal, but since Object is the base of the tree and *EVERYTHING extends object it still applies) an Array is an Object so when the in operator asks "What are your keys", it gets the answer I have 4 keys and they are "0", "1", "2", "3", because those are the indexes in the array and you can use array syntax to access them. it must present them as strings because object keys are always strings and array access syntax is just dynamic object de-reference syntax. in also checks elements of the prototype chain of the object which is why 'slice' is in the array, it's a method you can call on the array.

    @Applied-Mediocrity said in Programming Memes Thread:

    Javascript's (and many others of the sort) idea that arrays or lists are actually associative arrays is retarded and objectively harmful.

    Javascript has no Lists, only Array and Object., .... and Function.... and Number... and null... and undefined....

    there are a lot of things about javascript that are as you say "retarded and objectively harmful" but using the "test if the key is a valid key for the associative Object" operator and expecting it to check for membership in the array is not one of them. if you want that you should use the .includes() function which is for just that.

    if you're gonna get mad and try to out pedant me, at least make sure your facts are straight first. :P


  • Discourse touched me in a no-no place

    @accalia said in Programming Memes Thread:

    and null... and undefined....

    Now that there is a real good reason for getting mad as hell with JS.


  • FoxDev

    @dkf said in Programming Memes Thread:

    @accalia said in Programming Memes Thread:

    and null... and undefined....

    Now that there is a real good reason for getting mad as hell with JS.

    too damned right! one time in a hundred the distinction is actually handy. the other 99 time it's a beartrap ready to snap and cut your whole paw off.


  • Java Dev

    @accalia said in Programming Memes Thread:

    beartrap ready to snap and cut your whole paw off

    But what if you put the beartraps... with your paws?

    Chomp-chomp!


  • I survived the hour long Uno hand

    @Atazhaia said in Programming Memes Thread:

    @accalia said in Programming Memes Thread:

    beartrap ready to snap and cut your whole paw off

    But what if you put the beartraps... with your paws?

    Chomp-chomp!

    You should spoiler that, there are anime-intolerant persons on this forum!


  • Considered Harmful

    @accalia said in Programming Memes Thread:

    if you're gonna get mad and try to out pedant me, at least make sure your facts are straight first. :P

    I'm not trying to out pedant you, I'm saying your argument is retarded.

    Array is an Object

    Yes, it is. And therefore Javascript has no arrays, only Arrays. Which are Objects that only pretend to be arrays, and you can't even tell from the accessor alone what the fuck it will do.

    let fruits = [];
    fruits["stupid"] = "avocado";
    fruits["0"]= "tomato";
    fruits["1"]= "accalia";
    console.log(typeof fruits); // Object (because of course it is).
    console.log(fruits.toString()); // Where's the goddamn avocado? Oh right, it's this Array thing, actually.
    let key = "stupid";
    console.log(fruits[key]); // Oh look, it's become Object again. Or rather, always has been.
    

  • Notification Spam Recipient

    @izzion said in Programming Memes Thread:

    @Atazhaia said in Programming Memes Thread:

    @accalia said in Programming Memes Thread:

    beartrap ready to snap and cut your whole paw off

    But what if you put the beartraps... with your paws?

    Chomp-chomp!

    You should spoiler that, there are anime-intolerant persons on this forum!

    The rope for them. Its the only way.


  • Considered Harmful

    @Arantor said in Programming Memes Thread:

    @Applied-Mediocrity said in Programming Memes Thread:

    @accalia No. A key is not equivalent to an index. Keys identify elements. Indices describe the position of elements.
    Javascript's (and many others of the sort) idea that arrays or lists are actually associative arrays is retarded and objectively harmful.

    JavaScript does separate the two. Arrays and objects are distinct things with distinct behaviours. I’ll grant you that it gets iffy with sparse arrays depending on exactly what you do but it broadly does operate exactly as you’d expect here,

    Now that I think about sparse arrays, they seem more like the saving grace of in because they make it so that not every i<array.length is "in array". Otherwise it would be just useless.



  • @Applied-Mediocrity while that’s true, I give you the counter example.

    let arr = [1, 2, 3];
    delete arr[1];
    

    Chrome console log reports this contains [1, empty, 3] and has length 3.

    As opposed to:

    let obj = {a: 'a', b: 'b'};
    delete obj[1]; // does nothing
    delete obj['a']; // obj now equals {b: 'b'} and length is undefined
    

    Note that the first example is still of type Array. If you take an Array and fuck with it that it has to coerce to Object, you’ll get an Object and be forever damned, but if you treat it as an Array it will stay as one.

    Unlike PHP, though…


  • FoxDev

    @Applied-Mediocrity said in Programming Memes Thread:

    I'm saying your argument is retarded.

    No, yours is. Stop treating Arrays like objects and expecting them to still be Arrays

    @Applied-Mediocrity said in Programming Memes Thread:

    let fruits = [];
    fruits["stupid"] = "avocado";

    As soon as you did this Fruits stopped being a proper array and became instead this weird amalgam of pain that is an Object that just happens to behave a lot like an Array.

    if you're going to call my argument retarded, maybe don't shoot yourself in the foot trying to show me a counter example.


  • FoxDev

    @Atazhaia said in Programming Memes Thread:

    @accalia said in Programming Memes Thread:

    beartrap ready to snap and cut your whole paw off

    But what if you put the beartraps... with your paws?

    Chomp-chomp!

    oooooooh......

    1. cute.

    2. practical.

    3. SIGN ME THE BLEEP UP!


  • Considered Harmful

    @accalia said in Programming Memes Thread:

    weird amalgam of pain that is an Object that just happens to behave a lot like an Array

    Array is said weird amalgam of pain regardless of whether I do anything or not. The very fact that it can be done is enough.

    expecting them to still be Arrays

    That's the point. It is and it fails at being either.

    if you're going to call my argument retarded, maybe don't shoot yourself in the foot trying to show me a counter example.

    Maybe I wouldn't if the language wasn't a footgun of size. But it is.

    It certainly ranks low among all the ways why Javascript must burn in hellfire, but it adds to that list nevertheless.

    And yes, Array cannot possibly be a language construct, because that's how Javascript works. But because it's a stupid-ass way of working, I've elected to have it go fuck itself.



  • @Applied-Mediocrity by that logic, any language that expresses any type as anything that isn’t explicitly a scalar is retarded? Because I’m sure there’s other languages out there that treat, say, strings as non trivial types with method behaviours.

    The main beef is type juggling from Array to Object but any language that has type juggling is automatically somewhat stupid, just because type juggling basically is stupid even when it has quite tightly defined semantics.


  • FoxDev

    @Applied-Mediocrity said in Programming Memes Thread:

    I've elected to have it go fuck itself.

    Good luck with that.

    The internet is here to stay, short of WWIII and the extinction of all life on this planet, and that means so is Javascript as the base scripting language that every web browser (to within margin of error, sorry Lynx devotees) supports.

    You can fume and swear and get angry and go to war against it, but what will it change?

    [insert Edwin Starr's famous song here because i am too boomzilla kneeling warthog to find it an embed it here]


  • Considered Harmful

    @accalia said in Programming Memes Thread:

    You can fume and swear and get angry and go to war against it, but what will it change?

    I don't want it to change, I want to be angry.

    Elsewise it would appear I have misread the point of :wat: 📅 :wtf:


  • BINNED

    @Arantor said in Programming Memes Thread:

    @Applied-Mediocrity by that logic, any language that expresses any type as anything that isn’t explicitly a scalar is retarded? Because I’m sure there’s other languages out there that treat, say, strings as non trivial types with method behaviours.

    :wat: :wat:

    Everything except C treats strings as objects of one kind or another.

    Python:

    >> s = "hello"
    >>> "lo" in s
    True
    >>> "hi" in s
    False
    
    >>> l = [1, 2, 3, 4]
    >>> 4 in l
    True
    >>> "4" in l
    False
    

    JS:

    s = "hello";
    "lo" in s;
    Uncaught TypeError: cannot use 'in' operator to search for "lo" in "hello"
        <anonymous> debugger eval code:2
    
    0 in s;
    Uncaught TypeError: right-hand side of 'in' should be an object, got string
        <anonymous> debugger eval code:3
    

    I'm not sure what that's supposed to tell us.


  • FoxDev

    @Applied-Mediocrity said in Programming Memes Thread:

    I want to be angry.

    if that's true, then i'm genuinely sorry for you. there's too much beauty in this world to be angry....

    but if it's your wish....


  • Discourse touched me in a no-no place

    @accalia said in Programming Memes Thread:

    You can fume and swear and get angry and go to war against it, but what will it change?

    YMBNH™



  • @topspin the argument that Array as an Object is retarded so I extrapolated this to 'well, if you're going to the point that an array cannot be a language construct, anything that isn't strictly a scalar is retarded because by the same definition it is also not a language construct but something else'

    Everything except C treats strings as objects of one kind or another.

    I give you PHP.

    $string = 'Hello';
    echo $string[0];
    

    Will duly output H. But it's not quite the same because string is a fundamental type in PHP, such that it isn't an object, and things can be cast to a string.

    For bonus points, PHP still fucks up the Unicode thing such that a string is an arbitrary not-array of bytes and if you want to actually deal in characters you have to go out of your way every time, whether you're dealing with PCRE (remembering the U parameter where it's relevant), or the mbstring/iconv/intl extensions.

    But we can also handwave all this bollocks away under 'PHP thinks like C' and in every respect should be treated as 'C for CGI with a fuck load of safety rails, some of which are stupid'

    That said, all programming languages are stupid in different ways and it's allowed to be angry that humans can't invent good things.


  • Discourse touched me in a no-no place

    @Arantor said in Programming Memes Thread:

    But it's not quite the same because string is a fundamental type in PHP, such that it isn't an object, and things can be cast to a string.

    There are other languages that make strings a fundamental type too, and not all of them are insane in the brain. The best approach tends to be to model the string as a sequence of Unicode characters (and hiding whatever those sequences are implemented as; ASCII strings are still common enough to be worth having a special case for).


  • Banned

    @Arantor said in Programming Memes Thread:

    all programming languages are stupid in different ways

    Does giving birth to a sect of the most annoying zealots in recorded history count as stupid? Because if not, I think I found a counterexample.


  • BINNED

    @Gustav you stopped counting yourself in for those?
    🦀


  • Banned

    @dkf said in Programming Memes Thread:

    The best approach tends to be to model the string as a sequence of Unicode characters

    Up until you look up the definition of the Unicode character.



  • @Applied-Mediocrity said in Programming Memes Thread:

    I don't want it to change, I want to be angry.

    "it means ‘hate’—proper hate, for by the Martian ‘map’ you cannot hate anything unless you grok it, understand it so thoroughly that you merge with it and it merges with you—then you can hate. By hating yourself. But this implies that you love it, too, and cherish it and would not have it otherwise. Then you can hate—and (I think) Martian hate is an emotion so black that the nearest human equivalent could only be called mild distaste.”


  • BINNED

    @Gustav said in Programming Memes Thread:

    Does giving birth to a sect of the most annoying zealots in recorded history count as stupid?

    Not sure if JavaScript or Rust 🤔

    I certainly see far more annoying JS apologists than Rust evangelists.



  • @Arantor said in Programming Memes Thread:

    I give you PHP.

    Ewww. Yeah, thanks, but no thanks.



  • @dkf said in Programming Memes Thread:

    The best approach tends to be to model the string as a sequence of Unicode characters

    There ain't no such thing. There are codepoints, graphemes and grapheme clusters.

    Now usually unicode ‘character’ means codepoint, but then you get to the other problem: that random access is either slow, or you waste a lot of memory for the common cases. Of course random access to graphemes is out of question.

    The best solution is to not provide random access at all, just way to iterate over the different subunits that you need to operate on for different purposes. Which can be, for simplicity, usually still encoded as strings. At least graphemes and grapheme clusters still are.



  • @Bulb said in Programming Memes Thread:

    The best solution is to not provide random access at all, just way to iterate over the different subunits that you need to operate on for different purposes. Which can be, for simplicity, usually still encoded as strings. At least graphemes and grapheme clusters still are.

    Two string types: one ("String") is just the sequence of bytes, the other ("Text") is a sequence of Unicode codepoints. And make converting between them clearly visible (if the bytes of your string don't represent properly-encoded Text the conversion fails). You get random access into Strings, but not with Text (and not just because of slow iteration; taking substrings of Text can result in changing codepoints at the ends).



  • @Watson said in Programming Memes Thread:

    Two string types: one ("String") is just the sequence of bytes, the other ("Text") is a sequence of Unicode codepoints.

    That's what everybody is converging to except for the names: the former is simply an array of bytes, so it is either simply that construct (array<byte> by whatever syntax) or if there is a reason to make it special, called something like ‘bytes’, and ‘string’ is the text, because everybody is used to put text in a type called ‘string’.

    And make converting between them clearly visible (if the bytes of your string don't represent properly-encoded Text the conversion fails). You get random access into Strings, but not with Text (and not just because of slow iteration; taking substrings of Text can result in changing codepoints at the ends).

    Both utf-8 and utf-16 are self-synchronizing (you can always tell whether the codeword you are looking at is a start of codepoint or not), so arbitrary indexing can't change codepoints at the end, it fails if you try to take a substring that starts or ends in the middle of character.



  • @Bulb said in Programming Memes Thread:

    so arbitrary indexing can't change codepoints at the end,

    I was thinking of languages where the grapheme used for a character differs depending on whether it's in initial, medial, or final position.


  • Considered Harmful

    @jinpa said in Programming Memes Thread:

    @Applied-Mediocrity said in Programming Memes Thread:

    I don't want it to change, I want to be angry.

    "it means ‘hate’—proper hate, for by the Martian ‘map’ you cannot hate anything unless you grok it, understand it so thoroughly that you merge with it and it merges with you—then you can hate. By hating yourself. But this implies that you love it, too, and cherish it and would not have it otherwise. Then you can hate—and (I think) Martian hate is an emotion so black that the nearest human equivalent could only be called mild distaste.”

    Well played.



  • @Watson said in Programming Memes Thread:

    @Bulb said in Programming Memes Thread:

    so arbitrary indexing can't change codepoints at the end,

    I was thinking of languages where the grapheme used for a character differs depending on whether it's in initial, medial, or final position.

    Oh. While Unicode does have separate codes for the initial, medial and final position, the standard logic is that the stored text always uses the canonical one, the initial/medial/final distinction is handled in the display layer and the specific codes are only used for font encoding. So most code shouldn't need to care.


  • Discourse touched me in a no-no place

    @Bulb said in Programming Memes Thread:

    @dkf said in Programming Memes Thread:

    The best approach tends to be to model the string as a sequence of Unicode characters

    There ain't no such thing. There are codepoints, graphemes and grapheme clusters.

    Now usually unicode ‘character’ means codepoint, but then you get to the other problem: that random access is either slow, or you waste a lot of memory for the common cases. Of course random access to graphemes is out of question.

    I am amused by how you are wrong. You still think of the storage format first. It would probably help you a lot if you were to instead think of them as an interface defining a set of operations that can be performed, none of which include getting a pointer to anything to on the inside. There is an important distinction, but it is between the modifiable and the immutable (at least from the perspective of the outside world) as they support different uses: you can change a modifiable string and you can use an immutable one as a key in a mapping. However, the manner in which that string is stored in memory is not part of the interface, and can consequently be changed to support the operations that have historically been performed on the string (as past usage does tend to be a strong predictor of future; it's just not 100%).

    Fast access to the graphemes is possible, but expensive in terms of space (and a one-off time cost). It requires a scan of the underlying data to build an auxiliary index (except in some fairly common special cases, enough so that they're worth putting effort into). You have the interface to hide that you may do sophisticated stuff.

    The best solution is to not provide random access at all, just way to iterate over the different subunits that you need to operate on for different purposes. Which can be, for simplicity, usually still encoded as strings. At least graphemes and grapheme clusters still are.

    Graphemes and larger units can't be anything less than strings.



  • I’m just going to drop &zwj; here.



  • @dkf said in Programming Memes Thread:

    I am amused by how you are wrong.

    You don't actually contradict anything I wrote though.

    You still think of the storage format first.

    No, I don't think of storage format first, though I do think of it, because string operations are very common and therefore need to be efficient.

    It would probably help you a lot if you were to instead think of them as an interface defining a set of operations that can be performed, none of which include getting a pointer to anything to on the inside.

    At the low level a lot of them do. In high-enough language that can be hidden behind common facade, but internally it should be references into the original memory for performance reasons. Anyway, I already said that:

    The best solution is to not provide random access at all, just way to iterate over the different subunits that you need to operate on for different purposes. Which can be, for simplicity, usually still encoded as strings. At least graphemes and grapheme clusters still are.

    Graphemes and larger units can't be anything less than strings.

    Yeah, that's what I said, isn't it.


  • ♿ (Parody)

    @dkf said in Programming Memes Thread:

    I am amused by how you are wrong.

    Good sig material there.


  • 🚽 Regular

    Random thought: Unicode hardware acceleration.



  • @Zecc needs firmware update support as the spec changes yearly.


  • Notification Spam Recipient

    @kazitor said in Programming Memes Thread:

    @Gustav said in Programming Memes Thread:

    Does giving birth to a sect of the most annoying zealots in recorded history count as stupid?

    Not sure if JavaScript or Rust 🤔

    I certainly see far more annoying JS apologists than Rust evangelists.

    That’s because no one needs to use rust but we’re stuck with js. They’re more abused spouses than they are apologists.



  • @DogsB said in Programming Memes Thread:

    @kazitor said in Programming Memes Thread:

    @Gustav said in Programming Memes Thread:

    Does giving birth to a sect of the most annoying zealots in recorded history count as stupid?

    Not sure if JavaScript or Rust 🤔

    I certainly see far more annoying JS apologists than Rust evangelists.

    That’s because no one needs to use rust but we’re stuck with js. They’re more abused spouses than they are apologists.

    It’s perfectly possible to build functioning applications without JavaScript. No one needs to use JavaScript.

    You can do a lot more with it if you do, including types of apps that would be supremely awful without it.

    But it’s not essential. We had functioning sites, including form based ones, when JS was still a toy for animation.



  • @Arantor said in Programming Memes Thread:

    You can do a lot more with it if you do, including types of apps that would be supremely awful without it.

    There are no such types of apps any more. You can do web apps, even fully client-side ones, in the likes of Blazor, Flutter or Dioxus and never write a line of javascript. The apps will contain javascript, but it will either be compiled from the other language you wrote, or just a glue provided by the toolchain (and your code compiled to webassembly instead).



  • @Bulb I was going on the :pendant: angle that they still contain JS even if not written as such. When I said that you could write apps without JS, I did mean the fully no JS, not even WebAsm kind.



  • @Arantor Note that WebAssembly is an bytecode of slightly higher level than typical assembly (it has notion of functions and loops and no jumps) that has nothing at all to do with JavaScript. But in browsers you still need a bit of JavaScript to load and start the WebAssembly, so yes, you technically you can't avoid it, yes.



  • @Bulb I am being deliberately :pendant: about this for the sake of making my point, but yes.


  • Banned

    @Bulb said in Programming Memes Thread:

    @dkf said in Programming Memes Thread:

    The best approach tends to be to model the string as a sequence of Unicode characters

    There ain't no such thing. There are codepoints, graphemes and grapheme clusters.

    And extended grapheme clusters. Don't forget extended grapheme clusters.


  • I survived the hour long Uno hand

    @Gustav said in Programming Memes Thread:

    @Bulb said in Programming Memes Thread:

    @dkf said in Programming Memes Thread:

    The best approach tends to be to model the string as a sequence of Unicode characters

    There ain't no such thing. There are codepoints, graphemes and grapheme clusters.

    And extended grapheme clusters. Don't forget extended grapheme clusters.

    Ob. your mom’s an extended grapheme cluster


  • Banned

    @Arantor said in Programming Memes Thread:

    @DogsB said in Programming Memes Thread:

    @kazitor said in Programming Memes Thread:

    @Gustav said in Programming Memes Thread:

    Does giving birth to a sect of the most annoying zealots in recorded history count as stupid?

    Not sure if JavaScript or Rust 🤔

    I certainly see far more annoying JS apologists than Rust evangelists.

    That’s because no one needs to use rust but we’re stuck with js. They’re more abused spouses than they are apologists.

    It’s perfectly possible to build functioning applications without JavaScript. No one needs to use JavaScript.

    Not quite yet. There's still the matter of non-JS web UI frameworks.

    You can do a lot more with it if you do, including types of apps that would be supremely awful without it.

    JS is supremely awful for literally every type of app in existence. For every single type of app there's like two dozen better language choices than JS. It's just that the ecosystem is already there for JS but not for other languages.


  • Banned

    @Arantor said in Programming Memes Thread:

    When I said that you could write apps without JS, I did mean the fully no JS, not even WebAsm kind.

    I think you're confusing Wasm with asm.js.



  • @Gustav said in Programming Memes Thread:

    @Arantor said in Programming Memes Thread:

    When I said that you could write apps without JS, I did mean the fully no JS, not even WebAsm kind.

    I think you're confusing Wasm with asm.js.

    No, you still need a JS loader for Wasm. (Also, they finally agreed on Wasm? Eh, whatever. I just vaguely remember noises about avoiding collisions with some other assembler tool. Don’t know for sure, don’t care, don’t use it, etc)


  • Discourse touched me in a no-no place

    @Bulb said in Programming Memes Thread:

    But in browsers you still need a bit of JavaScript to load and start the WebAssembly, so yes, you technically you can't avoid it, yes.

    Apparently (and I've no personal experience in this) you also need a few bits of JS to handle the binding of the wasm to the outside world, whether that is by exporting functions from the wasm bundle to whatever is going on in the rest of the webpage, or importing access to the browser (so the wasm is able to manipulate the page DOM).


Log in to reply