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

Lurked Digg until v4.

Commented on Reddit (same name… at the moment) until it went full Musk.

Now I’m here.

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

  • 0 Posts
  • 34 Comments
Joined 1 year ago
cake
Cake day: June 12th, 2023

help-circle
  • The last I saw, AI models were very good at explaining what code did at a very superficial level, but not why it’s doing that or why it’s written that way.

    I assume it’s gotten better at that since then. (?)

    e.g. They’d be able to write comments for x = 0 along the lines of “set variable x to 0” but not why it’s being done or even why it might be a good idea.

    Deeper question: What can AIs do with obfuscated code? Can they pick that apart and explain it? What if it’s regular code with misleading function names?



  • Perl had $[ (yes, just those two characters) to allow setting of the first array index, but it’s a fatal error to put anything but 0 into it now.

    Of course, since Perl arrays can be negative subscripted from the last element, you can stand on your head and index the array negatively from the wrong end. -1, -2, -3 etc. Use unshift to put things on the beginning (logical “end”) of what you’re doing rather than the usual push. Presto, a 1-based array (up to sign, anyway).

    You may wish to file this under “stupid, but it works”.

    People with more time / more need for something that looks professional, would probably be better off writing something that uses tie instead. (Or, yes, yes, a different language entirely, hush now.)


  • There is at least one case of parents, told at a very early stage that they’re expecting twins, deciding to remove and freeze one of the embryos for later reimplantation, so even with actual identical twins, they can be different ages.

    But yes, transferring minds is not something we can do. I’m not sure it’s something we’ll ever be able to do.

    Should it actually become possible, I assume that certain parties would even advocate for the unique life/lives of the clone(s). The argument would be that the clones’ chance at life shouldn’t be overwritten by other being’s attempts at extension of life.

    “Ethical minefield” doesn’t even begin to cover it!



  • Where possible, get things in writing. Even if you have to do most of the writing yourself.

    “Dear boss, please confirm that, as discussed this <time>, warnings A, B, C, etc. are not to be considered important and that we’re pushing ahead.” CC everyone on the team and maybe another boss or two if you dare. Wording it better than I have here is undoubtedly possible.

    Then you can perhaps stall and work on other things until you get a response one way or the other.

    And if that results in shitty boss behaviour or employment jeopardy you have a timestamped e-mail that you can point to as the beginning of the end.

    Of course, if you really need the job and can’t put yourself in that situation, instead document things for later. You can fire shots and warn customers on the way out rather than rocking the boat there and then.</time>



  • If you want the historical reason, you need to look at ASCII and its teletype forerunners. America, for better or worse, were the ones who laid down the bases for a lot of the standards we still use today. UTF-8 covers the gamut of Unicode, but its first 95 printable characters from 32 (space) onwards? Identical to 1967 ASCII.

    And since ASCII ended up as the default, most programming languages only allowed symbols from those original 95.

    In some really bad cases, in order to support keyboards with even fewer symbols, things like digraphs and trigraphs were kludged into some languages. (C, for example, is only just planning on getting rid of support for them this year.)

    Those systems tended to be completely alien to ASCII or descended from the 6-bit teletype code where there are only 60-some usable characters. (Two character cases at the same time? Luxury! And what the heck is a curly brace?)

    Now that UTF-8 is gaining a foothold, some languages are daring to use Unicode, so we might soon see more and more interesting characters being allowed in the base syntax of languages. (See Raku, for example. Or don’t. You may go blind.)

    On the other hand, there’s APL, which has been doing its own thing with weird symbols since 1966 and giving not a bit of interest to ASCII or anything else.


  • There’s deeper subtlety here. There are declared variables, uninitialised variables and variables that will at some point be declared, uninitialised or not, that don’t exist in the logic of the program flow yet. Compilers / interpreters may or may not make distinctions between these, especially if memory is (perhaps only considered to be) in short supply.

    What specific languages do in these cases is wide and varied. Some automatically give all variables a safe, but identifiably undefined value the moment they’re declared, which may or may not be equivalent to the language’s interpretation of null. Or is equivalent in some senses but not others. Looking at you, Javascript.

    In the toilet paper example, the holder might actually still exist but the middle bar might be missing for “identifiably undefined”, and the blank wall is that variable you have literally no idea about.

    Maybe in trying to access it you amaze yourself by finding that you’ve punched through the wall and managed to grab some toilet paper from a neighbouring bathroom cubicle.

    Maybe you instead discover your hand goes through a mincing machine and the pain, oh god why the pain nothing will ever be the same, is that my hard drive churning? No way to tell. Now that’s undefined behaviour.


  • What freaks me out is that sometimes getting the error message more than once can reset parts of the programmer’s brain enough to be able to see the error that “wasn’t there” before. And what’s equally freaky is how often the programmer then forgets what the error even was once it’s fixed.

    This is personal experience of course. For me, being introspective about this is kind of like remembering Dr Who’s The Silence exist when they’re not right there, but somehow it can be done.



  • For my own amusement I’m going to pretend you were using something like Perl where determining what’s a comment and what’s code can be context sensitive.

    i.e. stripping from # to the end of the line can be a very wrong thing to do in a language where the comment marker can actually be used in other niche ways.

    Strip the wrong “comment” and your code won’t compile. Or worse, do something unexpected.





  • In Perl, eval can do similar things, but symbolic references are “better” (I’m fairly sure it’s where PHP got the idea, and the syntax, from.) e.g.

    $foo = "bar";
    $$foo = "potatoes"; # $$foo = access the variable named in $foo, i.e. $bar
    print $bar; # prints potatoes
    
    

    Reading other responses, it seems like Python’s globals object is not entirely dissimilar, especially if you know how Perl deals with symbolic references under the hood.

    But just because you can doesn’t mean you should. If you use strict; in Perl, it will fail to compile most of this nonsense. Use a hash / associative array / dictionary / whatever your language (natural and/or programming) calls them instead.

    And I’m pretty sure that even without strict, local variables can’t be accessed at all the symbolic way, which is probably for the best. (NB: local is a subtle thing in Perl. By “local” here, I mean the so-called my variables that aren’t accessible outside their scope. local variables are actually localised globals. Enjoy that thought.)




  • Yeah, I was thinking of old 8-bit computers that did the same ignore-after-second-char thing. Most people didn’t bother typing the extra characters though because 1) those characters took up valuable memory and 2) if you accidentally put a keyword in the middle of your longer name, the tokeniser would see it and assume it was a keyword.

    e.g. Calling your variable FORGET seemed like a good idea until you got a syntax error because FOR and GET are both keywords. FO it is, then. Or just F.

    COLOR was cursed too; OR is usually a keyword, even if COLOR itself isn’t. British English COLOUR might save you here, but you’re still losing those four extra bytes.