There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

programmer_humor

This magazine is from a federated server and may be incomplete. Browse more on the original instance.

veganpizza69 , in Surely "1337" is the same as 1337, right?
@veganpizza69@lemmy.world avatar

It’s the API’s job to validate it either way. As it does that job, it may as well parse the string as an integer.

JordanZ ,

deleted_by_author

  • Loading...
  • bleistift2 OP ,

    Or even funnier: It gets parsed in octal, which does yield a valid zip code. Good luck finding that.

    xthexder ,
    @xthexder@l.sw0.com avatar

    Well shit, my zip code starts with a 9.

    bleistift2 OP ,

    I’m not sure if you’re getting it, so I’ll explain just in case.

    In computer science a few conventions have emerged on how numbers should be interpreted, depending on how they start:

    • decimal (the usual system with digits from 0 to 9): no prefix
    • binary (digits 0 and 1): prefix 0b, so 0b1001110
    • octal (digits 0 through 7): prefix 0, so 0116
    • hexadecimal (digits 0 through 9 and then A through E): prefix 0x, so 0x8E

    If your zip code starts with 9, it won’t be interpreted as octal. You’re fine.

    xthexder ,
    @xthexder@l.sw0.com avatar

    Well, you’re right. I wasn’t getting it, but I’ve also never seen any piece of software that would treat a single leading zero as octal. That’s just a recipe for disaster, and it should use 0o116 to be unambiguous

    (I am a software engineer, but was assuming you meant it was hardcoded to parse as octal, not some weird auto-detect)

    docAvid ,

    It’s been a long time, but I’m pretty sure C treats a leading zero as octal in source code. PHP and Node definitely do. Yes, it’s a bad convention. It’s much worse if that’s being done by a runtime function that parses user input, though. I’m pretty sure I’ve seen that somewhere in the past, but no idea where. Doesn’t seem likely to be common.

    bleistift2 OP ,

    PHP and Node definitely do.

    Node doesn’t.

    
    <span style="color:#323232;">> parseInt('077')
    </span><span style="color:#323232;">77
    </span>
    
    1. If the input string, with leading whitespace and possible +/- signs removed, begins with 0x or 0X (a zero, followed by lowercase or uppercase X), radix is assumed to be 16 and the rest of the string is parsed as a hexadecimal number.
    2. If the input string begins with any other value, the radix is 10 (decimal).

    developer.mozilla.org/en-US/docs/Web/…/parseInt

    docAvid ,

    You seem to have missed the important phrase “in source code”, as well as the entire second part of my comment discussing that runtime functions that parse user input are different.

    bleistift2 OP ,

    You seem to have missed the important phrase “in source code”

    I read that, but I thought it was a useless qualifier, because everything is source code. You probably meant “in a literal”.

    bleistift2 OP ,

    I’ve also never seen any piece of software that would treat a single leading zero as octal

    I thought JavaScript did that, but it turns out it doesn’t. I thought Java did that, but it turns out it doesn’t. Python did it until version 2.7: docs.python.org/2.7/library/functions.html#int. C still does it: en.cppreference.com/w/c/string/byte/strtol

    xthexder ,
    @xthexder@l.sw0.com avatar

    Interesting that strtol in C does that. I’ve always explicitly passed in base 10 or 16, but I didn’t know it would auto-detect if you passed 0. TIL.

    kamen ,

    Oof.

    I guess this is one of the reasons that some linters now scream if you don’t provide base when parsing numbers. But then again good luck finding it if it happens internally. Still, I feel like a ZIP should be treated as a string even if it looks like a number.

    bitfucker ,

    Yep. Much like we don’t treat phone numbers like a number. The rule of thumb is that if you don’t do any arithmetic with it, it is not a “number” but numeric.

    sukhmel , (edited )

    Well, we don’t, but every electonic tables software out in the wild on the other hand…

    /jYes, I know that you can force it to become text by prepending to the phone, choose an appropriate format for the cells, etc, etc The point is that this often requires meddling after the phone gets displayed as something like 3e10

    raman_klogius ,

    Who tf decided that a 0 prefix means base 8 in the first place? If a time machine was invented somehow I’m going to cap that man, after the guy that created JavaScript.

    JackbyDev ,

    Should be like 0o777 to mimic hex 0xFF

    bleistift2 OP ,

    I refuse to validate data that comes from the backend I specifically develop against.

    Thcdenton ,
    conorab , in Please stop

    Mentoning Iceweasel in 2024?! Where did you find this meme?! Debian stable?!

    Tangent5280 ,

    debian nightly release

    NaoPb ,

    We don’t talk about what happens in the night.

    maxinstuff , in Surely "1337" is the same as 1337, right?
    @maxinstuff@lemmy.world avatar

    I’ll have you know all of my code is stringly typed.

    Agent641 ,

    All my binary code is stringy too.

    r1veRRR , in Please stop

    I have never had a good experience with a Debian server. Every single time I had to add unstable or third party repos to get anything remotely current to run. What’s the point if you have to add unstable shit anyway?

    Johanno ,

    That sounds like a skill issue.

    muntedcrocodile , in Please stop
    @muntedcrocodile@lemm.ee avatar

    It makes a great headless server

    dan , in Please stop
    @dan@upvote.au avatar

    Debian gives you a choice though. If you want stability, install the stable release. If you want newer packages, install the testing release. Just be sure to get security updates from unstable (sid) if you do that.

    “stable” in this context means that stuff doesn’t change often. It doesn’t mean “stable” as in reliable / never crashes, although Debian is good at that too.

    MeDuViNoX , in Please stop
    @MeDuViNoX@sh.itjust.works avatar
    notanaltaccount , in Please stop

    The packages in Debian are really old. It’s awful.

    I was looking at my xzutils package the other month. “So outdated,” I thought, envying the cool hip trendy Arch users.

    RustyShackleford , in Please stop
    @RustyShackleford@programming.dev avatar

    Getthefuckouttamyfacewiththisridiculousbullshit.

    avidamoeba , in Please stop
    @avidamoeba@lemmy.ca avatar

    SOFTWARE WAS NOT SUPPOSED TO BE STABLE

    Someone with a case of brain rot.

    Sonotsugipaa ,
    @Sonotsugipaa@lemmy.dbzer0.com avatar

    Me, because I cannot understand how people can miss the facetiousness of this meme template with such confidence

    avidamoeba ,
    @avidamoeba@lemmy.ca avatar

    🪦

    Appoxo ,
    @Appoxo@lemmy.dbzer0.com avatar

    When even the skull is more alive

    jubilationtcornpone ,

    Ah, I see you’ve met the product owner.

    OneCardboardBox , in Trying to understand JSON…
    bleistift2 OP ,

    I’m sad that there are people who call themselves developers who need to be told this.

    ooterness , in Surely "1337" is the same as 1337, right?

    CBOR for life, down with JSON.

    0x0 ,

    If there are no humans in the loop, sure, like for data transfer. But for, e.g., configuration files, i’d prefer a text-based solution instead of a binary one, JSON is a nice fit.

    MonkderDritte ,

    What, no! Use TOML or something for config files.

    0x0 ,

    TOML

    Interesting… me likes it.

    frezik ,

    What I’d like for a configuration language is a parser that can handle in-place editing while maintaining whitespace, comments, etc. That way, automatic updates don’t clobber stuff the user put there, or (alternatively) have sections of ### AUTOMATIC GENERATION DO NOT CHANGE###.

    You need a parser that handles changes on its own while maintaining an internal representation. Something like XML DOM (though not necessarily that exact API). There’s a handful out there, but they’re not widespread, and not on every language.

    bitfucker ,

    JSON5

    frezik ,

    Is a very good idea providing much needed fixes to the JSON spec, but isn’t really what I’m getting at. Handling automatic updates in place is a software issue, and could be done on the older spec.

    bitfucker ,

    Hmm, maybe I am missing the point. What exactly do you mean by handling automatic updates in place? Like, the program that requires and parses the config file is watching for changes to the config file?

    frezik ,

    As an example, Klipper (for running 3d printers) can update its configuration file directly when doing certain automatic calibration processes. The z-offset for between a BLtouch bed sensor and the head, for example. If you were to save it, you might end up with something like this:

    
    <span style="color:#323232;">[bltouch]
    </span><span style="color:#323232;">z_offset: 3.020
    </span><span style="color:#323232;">...
    </span><span style="color:#323232;">#*# <---------------------- SAVE_CONFIG ---------------------->
    </span><span style="color:#323232;">#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
    </span><span style="color:#323232;">#*#
    </span><span style="color:#323232;">[bltouch]
    </span><span style="color:#323232;">z_offset: 2.950
    </span>
    

    Thus overriding the value that had been set before, but now you have two entries for the same thing. (IIRC, Klipper does comment out the original value, as well.)

    What I’d want is an interface where you can modify in place without these silly save blocks. For example:

    
    <span style="color:#323232;">let conf = get_config()
    </span><span style="color:#323232;">conf.set( 'bltouch.z_offset', 2.950 )
    </span><span style="color:#323232;">conf.add_comment_after( 'bltouch.z_offset', 'Automatically generated' )
    </span><span style="color:#323232;">conf.save_config()
    </span>
    

    Since we’re declaratively telling the library what to modify, it can maintain the AST of the original with whitespace and comments. Only the new value changes when it’s written out again, with a comment for that specific line.

    Binary config formats, like the Windows Registry, almost have to use an interface like this. It’s their one advantage over text file configs, but it doesn’t have to be. We’re just too lazy to bother.

    bitfucker ,

    Ahh, then the modification must be done on the AST level not the in-memory representation since anyway you do it, you must retain the original.

    frezik ,

    Right.

    Michal ,

    Yaml is more human readable/editable, and it’s a superset of json!

    bob_lemon ,

    Yaml is just arcane bullshit to actually write as a human. Nor is it intuitively clear how yaml serializes.

    Aux ,

    Yaml is cancer.

    JackbyDev ,

    It’s entirely disingenuous because who the hell is throwing JSON into YAML without converting it? Oh wow, I changed the file extension and it still works. I’m so glad we changed to YAML!

    bitfucker ,

    Until someone cannot tell the difference between tab and space when configuring or you miss one indentation. Seriously, whoever thinks indentation should have semantic meaning for computers should burn in hell. Indentation is for us, humans, not computers. You can write a JSON with or without indentation if you want. Also, use JSON5 to have comments and other good stuff for a config file.

    themusicman ,

    If you’re moving away from text formats, might as well use a proper serialisation tool like protobuf…

    wtfrank ,

    Yaml?

    JackbyDev ,

    For the love of all things pure, holy, and just, please do not use YAML in your APIs…

    wtfrank ,

    Fine, and if you don’t use json in your API because of the deficiency highlighted in the meme, what format do you use in your API?

    JackbyDev ,

    I use JSON. I have used Avro for things in Kafka but I’m not sure the benefits outweigh the negatives. Avro is much more complicated than people think and most folks don’t really have a strong desire to learn how it should be used and do stuff incorrectly. Everybody knows JSON and it works with everything though. (Example: so many people just hear that Avro schemas can be backwards compatible but have zero idea that you still need the schema that wrote the message even if you want to read it into a newer one.)

    Interestingly, I take the meme as saying a dev is using the wrong types in their serialization format (using strings to store integers) which was my biggest problem with Avro. Mostly from people not using logical types or preferring to use ISO 8601 datetime strings instead of the built-in timestamp-millis type.

    bleistift2 OP ,

    Hell, no. If I wanted to save bytes, I’d use a binary format, or just fucking zip the JSON. Looking at a request-response pair and quickly understanding the transferred data is invaluable.

    chicken , in Surely "1337" is the same as 1337, right?

    Explicit types are just laziness, you should be catching exceptions anyways.

    fapforce5 ,

    I do. I return an error.

    otter , in Alcohol is my way to turn myself on and off again

    Oh, we do have a !talesfromtechsupport community (link). Looks like the mod is inactive and the community doesn’t have that many subscribers

    Maybe we can try making a new one here on programming.dev

    graphito OP ,
    @graphito@beehaw.org avatar

    Touche, I get your point, indeed there’s a lot of tech supporty posts however narrowing the community is only good when it has enough content

    How about we wait out on fragmentation for flagship community of the instance until it starts to get at least 5 posts/day (30 posts/week)?


    For lurkers hoarding high quality content for this community, this is your sign to press the button “New post”

    otter ,

    Oh I don’t mind it, I like the post :)

    I was thinking that there might be a lot of Lemmy users working in such roles, without a place (that I know of) to share those stories

    Lightfire228 ,

    For lurkers hoarding high quality content for this community, this is your sign to press the button “New post”

    I’ve never really had good ideas to post

    Even on reddit

    graphito OP ,
    @graphito@beehaw.org avatar

    if your coworker shared smt or you see smt online that made you chuckle, it’s good enough to repost it on lemmy. Dont’ overthink it

    https://media1.tenor.com/m/YmYYTz-cW7sAAAAC/memes-just-do-it.gif

    bleistift2 ,

    I wouldn’t have thought that content suitable for talesfromtechsupport would be acceptable here. As the description says,

    This is a place where you can post jokes, memes, humor, etc. related to programming!

    Customer support is not usually related to programming.

    bitchkat , in Junior dev VS FAANMG dev

    My experience is exactly the opposite. I don’t work for a FAANG but I’ve been around the block a bit. Its always the junior devs that try and add new warnings etc to the code base. I always require warnings to be cleaned up even if that means disabling specific instances (but not the whole rule) because the rule is flagging a false negative.

    bleistift2 ,

    the rule is flagging a false negative

    false positive?

    bitchkat ,

    Warnings and errors are negatives not positive. So if it generates a warning that is OK, it’s a false negative.

    pantyhosewimp ,

    Just so you know, if your doctor calls and tells you that your HIV test is positive, you probably shouldn’t run out and celebrate.

    bitchkat ,

    That’s why I said false negative. The medical test is testing for the presence of a disease. So if they find the disease is considered a positive test (it found what it was looking for). For static analysis on code, its the opposite. Its testing if your code is free of issues that it can detect. If it finds no issues, then the test was positive. If does find issues, the test failed and each issue is a negative that contributed to the test failing.

    overcast5348 ,

    You could say “A static analysis tool is testing for the for the presence of defects” or “a medical test is testing if your body is free of diseases that it can detect” to change how you’re looking at either of the tests in the previous comment.

    bitchkat ,

    By your logic it would be a positive for your code to have errors/warnings. And on the latter, that would appropriate if there was a test that determined if you are free from all known diseases (or at least those that it can detect).

    overcast5348 ,

    Is it a positive to have pathogens that cause dengue/malaria in your blood? Yet we still say that someone tested positive for dengue if they have the virus.

    Static analysis tools don’t test for all known issues either, no?

    It’s all just semantics dude. :)

    pantyhosewimp ,

    I’m not debating. It is not a matter of opinion. I’m doing you the courtesy of informing you how the entire rest of the world uses the term.

    If action A looks for thing X, and it finds thing X, then the test is positive. If action A fails to find thing X, then the test is negative.

    If action A claims to find thing X, but later confirmation determines that thing X is not really there, then this situation is called “false positive”.

    If action A claims fails to find thing X, but later confirmation determines that thing X is actually there, then this situation is called “false negative”.

    That thing X may subjectively be considered an unwanted outcome has **nothing ** to do with the terms used.

    gravitas_deficiency ,

    It boils down to desensitization/normalization. Warnings (and errors, of course, but tests as well) exist for a reason. If you don’t care about these gauge constructs are telling you, then they have no real diagnostic value. Getting into a place where you’re not looking at how your systems are actually running is generally a bad idea, especially in the long run.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines