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)
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.
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.
If the input string begins with any other value, the radix is 10 (decimal).
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.
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.
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.
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
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.
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?
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.
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.
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.
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.
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?
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:
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.
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!
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.
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.
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.
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.
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.
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.
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).
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?
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.
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.
programmer_humor
Newest
This magazine is from a federated server and may be incomplete. Browse more on the original instance.