Some middle-aged guy on the Internet. Seen a lot of it, occasionally regurgitating it, trying to be amusing and informative.

Lurked Digg until v4. Commented on Reddit (same username) until it went full Musk.

Was on kbin.social (dying/dead) and kbin.run (mysteriously vanished). Now here on fedia.io.

Really hoping he hasn’t brought the jinx with him.

Other Adjectives: Neurodivergent; Nerd; Broken; British; Ally; Leftish

  • 0 Posts
  • 16 Comments
Joined 3 months ago
cake
Cake day: August 13th, 2024

help-circle
  • Find yourself a language that allows negative indices to count back from the end of an array.

    In those languages, index 0 is usually the first element, but if you’re particularly perverse and negate your indexing, you can start at 1, or rather -1, at the other end and work backwards.

    0-indexing originally comes from needing to add to the array’s base memory address to locate elements. If you have an array at memory address 1234, you might expect to find the first element at that address, which would be 1234+0, and the next at 1234+1, etc.

    1-indexing started as either a deliberate abstraction from that idea, and/or else there’s something else stored at 1234 that the array data type needs and the real elements start at 1234+1.

    All that said, there’s at least one language that insists the indices of an array be of a subtype of some Integer type that must have a limited range. Then you can start and end wherever you like, and the whole 1 vs 0 business is meaningless (except to whoever writes the compilers for that language anyway).








  • There was that one bash.org quote where a script kiddie was given 127.0.0.1 as part of an “oh yeah I dare you” taunt after he said he could hack anyone, and he fell for it hook line and sinker. He was posting things like “Hahaha your K drive is being deleted! Now your H drive! [connection reset by peer]” and right after that the challenger was like “I don’t even have a K drive.”

    (RIP bash.org though. I would have tried to link it otherwise)


  • 95% of all “Introduction to <whatever programming language>” books tend to dedicate the first couple of chapters to the fundamentals but with a specific bias towards the language in question. Seek out a few of those at a library or online equivalent and you’ll start to see patterns cropping up.

    Anything that doesn’t have that bias is likely to use pseudocode which looks like a programming language anyway.

    Object orientation works around the concept that things in the program “know” things about themselves and how to do things for themselves rather than have some other part of the program do things to them. Commonly you’ll see things like doSomethingWith(someObject) being the non-OO way and someObject.doSomething being the OO way. That is, in the latter someObject contains the knowledge of how to doSomething, and the dot notation urges it to do whatever it is.

    For a silly but more concrete example, x ← 2 + 2 is non-OO, but x ← 2.add(2) is at least partially OO because the first 2 is expected to know how to add another 2 to itself and give out the correct answer. Presumably in whatever language that is, someone has created a method for numbers to know what to do when told to add. The other 2 doesn’t really get a say in things. We might also have, say, elephant.putOn(hat), but it might not be possible to hat.putOn(elephant) because no-one thought to teach the hat how to wear things, let alone elephants.






  • That’s a thorny question: Do comments need to be in the base standard, or can that be offloaded to those building on it? It doesn’t look like it would be hard to have (comment "foo bar baz") in an expression and have a re-parser throw that out.

    Is the complaint that no two groups of people will use the same comment standard if left to their own devices? It’s not like the other data from different sources will always match up. What’s one extra, and fairly easy to handle SNAFU?

    That said, yes, I think I’d be more comfortable knowing there was an accepted comment format. The aesthetic seems to be Lisp-like, and I notice that the Lisp comment marker, the semicolon, is currently a reserved character, that is, it’s illegal to use it unquoted. Maybe they’re thinking of adding that at some point.