• 0 Posts
  • 23 Comments
Joined 1 year ago
cake
Cake day: July 9th, 2023

help-circle


  • People creating functions as objects inside of other functions. A few days ago saw a person create a function with two object functions inside, then passed one of the functions as an argument to the other function. Then returned the second function.

    It’s hard to find such a mess in other languages. Yeha, functions as objects are cool. Closures are also cool… But why abuse that shit?





  • My problem with it is that it gives people too much freedom. They can write the code in very, VERY ugly ways… And they do. It’s a language that let’s you write a mess pretty easily.

    That’s really my only complaint. The ugliness happens mainly in:

    • callback hell. For some reason some people still do callback hell in 2023.

    • functions as objects. This is pretty neat actually, one of the best things in Javascript, but some people just abuse the hell out of it.


  • Come on, Javascript is pretty nasty. Trying to read that shit always gives me brain tumors. Why do they need to wrap every fucking thing in a function inside a function inside a function that is passed as a parameter to a function inside another function?

    Like, bro, you know people are meant to understand what you just wrote?

    It just gives too much freedom and people forget they need to write code that is easy to read for people who aren’t totally familiar with the code base.

    They even bring that shit into typescript. Like they are already using a language that is meant to fix that shit and they are like, nope, let me create 5 nested functions just because.







  • pazukaza@lemmy.mltoProgrammer Humor@programming.devOnly 14.99$
    link
    fedilink
    arrow-up
    8
    arrow-down
    1
    ·
    1 year ago

    Actual question. Isn’t installing stuff from third party repos like super dangerous? The package scripts run with root access, right?

    So, I guess you could tell if the hash of the package matches the hash of the code after you build it… But, what about upgrades on that package after it is installed? They could change the setup scripts and screw a lot of people right?

    Not saying these guys do it, just wondering about security stuff.



  • I guess this is beating a dead horse but you can have pointers to pointers for 2D arrays.

    The first pointer tells you which coulm you’re on. The second pointer tells you which is the first object of each column. That way you can iterate the columns without loosing a reference to the current column you’re standing on.


  • pazukaza@lemmy.mltoProgrammer Humor@lemmy.mlpointers are very eleganto
    link
    fedilink
    arrow-up
    6
    arrow-down
    1
    ·
    edit-2
    1 year ago

    In C# it is different.

    In C if I give you a pointer to a memory address, you can totally overwrite what is in that memory address, even write a new struct in there. So you’re getting a “real” writable memory address. You could even write a different type of structs and break the program. You could tweak specific bytes.

    In languages like Java or C# you aren’t given a reference to the memory address but a reference to the object. You can only write to the object using it’s own interface (methods) but you can’t say “I’m going to totally overwrite this memory address with a new object”.

    If you receive an object in a parameter, let’s say a “Person person” object and you do something like “person = new Person();” you didn’t really overwrite the memory address. The original person reference that was passed in the parameter is still intact. You can only modify it with something like “person.setName(…)”.

    So, with real pointers you can do more stuff, but higher level languages don’t want you to do that because it breaks some of their principles for what “good programming” is. In this case they are protecting encapsulation. You shouldn’t be able to mess around with the memory contents of objects directly, only through their interfaces. Encapsulation is safer because objects should expose how to operate them safely via their interfaces.