5 ms·
More specific shenanigans aside, JavaScript will always be the king of unintuitive syntax. Some of these f-string tidbits are very much strange, but you'd have
by va1a 1y ago
More specific shenanigans aside, JavaScript will always be the king of unintuitive syntax. Some of these f-string tidbits are very much strange, but you'd have to be implementing something specific to encounter them. Meanwhile over in JS you're still waiting for your dependencies to install so you can compare two arrays.
- cluckindan 1y agoThat is exactly the kind of unfounded, strawman-riddled criticism I was after ;-) What does an algorithmic task such as array comparison have to do with language syntax? The answer is nothing. Sure, some languages might have builtins for comparing certain things, or doing intersections/differences, but those only apply to arrays of primitives, and even in those cases the utility of the builtins completely depends on the use case, and those builtins still have nothing to do with syntax.
- artikae 1y ago> those only apply to arrays of primitives I guess you've not written much python, or just not used any custom types in lists if you have. class Thing: def __init__(self, a, b): self.a = a; self.b = b def __eq__(me, them): return me.a == them.a and me.b == them.b >>>[1, 2, Thing(6, "Hi")] == [1, 2, Thing(6, "Hi")] True >>>[1, 2, Thing(6, "Hi")] == [1, 2, Thing(6, "Hello")] False In this case, the builtins are syntax, namely the `==` operator. There's a uniform syntax for comparing two objects for equality.
- cluckindan 1y agoSure, the language has a mechanism for overriding the equality operator for classes, just like Java has .equals(), but the code is overriding the builtin algorithm. The case of comparing mixed type arrays is not a usual case and seems contrived. In JS, you could do the same by extending Array and using that, or implementing a custom .equals() for your objects. I suppose Python is a bit more functional in that respect.