|
Octal literals were a frequent enough source of bugs to warrant being fixed in Python 3:Python code:
|
# ? Aug 8, 2014 14:33 |
|
|
# ? Jun 8, 2024 07:50 |
|
hobbesmaster posted:Compilers these days will have a warning like "Did you really want an assignment in an if statement?" But I got in that habit when writing embedded code with a terrible compiler... Embedded work, there is a coding horror that starts with the compilers being from the mid 90's.
|
# ? Aug 8, 2014 14:41 |
|
To me the disappointing part is how many languages support octal literals- which hardly anyone uses on purpose- but don't support binary literals. If you're doing any kind of bitmasking with fields that aren't nybble-aligned a binary literal is a hell of a lot more clear than any other choice of base.
|
# ? Aug 8, 2014 14:44 |
|
Lysidas posted:When dropping support for plain octal literals, I see two options: remove special handling of leading zeros to interpret them as base 10 (as was apparently attempted in Javascript) No. JavaScript supports octals (in that format, when not in strict mode). The behavior that illegal octals fall back to decimal is a historical bug that can't be fixed due to backwards compatibility concerns. If you use strict mode, then the statement gives an error.
|
# ? Aug 8, 2014 15:28 |
|
We already have binary literals. They start with 0x. If you can't convert hexadecimal into binary into your head, I mean, if you don't have neural circuitry that does that automatically and subconsciously for you, I don't know what to say, it's an essential life skill.
|
# ? Aug 8, 2014 16:55 |
|
Volmarias posted:Outside of Unix style file permissions, when would you realistically use octal? I recently had a use for octal constants, when defining the settings for a device register with two 3-bit fields. But that's perhaps the second time in a 20+ year career that I've found them useful.
|
# ? Aug 8, 2014 17:11 |
|
shrughes posted:We already have binary literals. They start with 0x. If you can't convert hexadecimal into binary into your head, I mean, if you don't have neural circuitry that does that automatically and subconsciously for you, I don't know what to say, it's an essential life skill. I did alright counting hex on my fingers before I started breathing them. Still helps for masking after shifts.
|
# ? Aug 8, 2014 17:57 |
|
shrughes posted:We already have binary literals. They start with 0x. If you can't convert hexadecimal into binary into your head, I mean, if you don't have neural circuitry that does that automatically and subconsciously for you, I don't know what to say, it's an essential life skill. same, OP or should I say, 0xCAFEBABE
|
# ? Aug 8, 2014 18:02 |
|
I think at this point it's safe to say that 18-bit and 36-bit processors are deader than disco and if you're doing cute little bit manipulation operations in security-critical code, just loving stop now.
|
# ? Aug 8, 2014 19:36 |
|
shrughes posted:We already have binary literals. They start with 0x. If you can't convert hexadecimal into binary into your head, I mean, if you don't have neural circuitry that does that automatically and subconsciously for you, I don't know what to say, it's an essential life skill.
|
# ? Aug 8, 2014 19:58 |
|
Apparently C was the first language with octal literals. Thanks a lot you old farts. I had to write a literal parser a few weeks ago and I found that it's trivial to support any base at all, so I allowed base 2, 8, 10 and 16. Octal looks like 0o777. You could also do something like: "<base>:number" to allow the programmer to specify any base directly. Base64 literals.
|
# ? Aug 8, 2014 20:24 |
|
Spatial posted:You could also do something like: "<base>:number" to allow the programmer to specify any base directly. Base64 literals. Erlang lets you do this, specifying any radix up 36 I believe. code:
|
# ? Aug 8, 2014 20:41 |
|
code:
|
# ? Aug 8, 2014 20:49 |
|
C++ code:
|
# ? Aug 8, 2014 23:08 |
|
mjau posted:
|
# ? Aug 9, 2014 00:20 |
|
The Laplace Demon posted:Oh wait that's not supposed to be a horror Haha, it kinda is though . I was curious if it could be done in c++11, and.. that's what i came up with It'd be nice if the template<char...> operator"" syntax was supported for string literals though. Then you could check if the input is within the valid range and static_assert if it's not, instead of silently generating invalid values like that thing does. But the template syntax is only available for numbers, and i don't think they fixed that for c++14.
|
# ? Aug 9, 2014 01:26 |
|
code:
|
# ? Aug 9, 2014 09:17 |
|
Internet Janitor posted:
Yeah, but in forth you can also do things like code:
|
# ? Aug 9, 2014 10:55 |
|
Why would you define a word named "4" if you didn't want it to do that?
|
# ? Aug 10, 2014 06:25 |
|
HFX posted:Embedded work, there is a coding horror that starts with the compilers being from the mid 90's. Real men know not to ever trust the compiler. Also I write var == condition instead of condition == var. edit* Snapchat A Titty posted:same, OP 0xDEADBEEF
|
# ? Aug 11, 2014 04:13 |
|
ratbert90 posted:0xDEADBEEF My favorite hex constants to use are 0xABADCAFE and 0xDEFEC8ED. Maybe 0xBADFECE5. I have a juvenile sense of humor.
|
# ? Aug 11, 2014 06:23 |
|
My fav is definitely 0xD15EA5E (it's a flag on the Gamecube/Wii) because it looks the least like any other. Most use "BAD" and "BEEF" and "CAFE" and such way too much.
|
# ? Aug 11, 2014 11:18 |
|
My favorite is: https://lkml.org/lkml/2012/7/13/154
|
# ? Aug 11, 2014 11:36 |
|
Shinku ABOOKEN posted:My favorite is: I see poo poo like this in the kernel all the time. Swear words are common, uninitialized variables are common. The kernel seriously needs a lint party something fierce; it is the coding horror that can make you cry.
|
# ? Aug 11, 2014 15:56 |
|
ratbert90 posted:Swear words are common, uninitialized variables are common. This is the idiomatic way to write C though
|
# ? Aug 11, 2014 18:11 |
|
ratbert90 posted:I see poo poo like this in the kernel all the time. Swear words are common, uninitialized variables are common. The kernel seriously needs a lint party something fierce; it is the coding horror that can make you cry. Of course cleaning that up and you can't play well with Microsoft Hyper-V any longer. Since that's the identifier Microsoft uses to indicate the guest ID. (Hint: it's poo poo from Microsoft in this case.)
|
# ? Aug 11, 2014 18:29 |
|
Hughlander posted:Of course cleaning that up and you can't play well with Microsoft Hyper-V any longer. Since that's the identifier Microsoft uses to indicate the guest ID. (Hint: it's poo poo from Microsoft in this case.) Is that really the part of the API? It wasn't clear to me from the thread whether it was key or value.
|
# ? Aug 11, 2014 19:45 |
|
Shinku ABOOKEN posted:My favorite is: 0xABAD1DEA
|
# ? Aug 12, 2014 00:10 |
|
Suspicious Dish posted:0xABAD1DEA Ah, I see you've hashed a certain codebase I've worked on before. Volmarias fucked around with this message at 00:49 on Aug 12, 2014 |
# ? Aug 12, 2014 00:42 |
|
Volmarias posted:Ah, I see you've hashed a certain codebase I've worked on before. You contribute to our open-source project?
|
# ? Aug 12, 2014 01:18 |
|
Suspicious Dish posted:You contribute to our open-source project? ... No? Edit: I am the horror in this thread Volmarias fucked around with this message at 03:57 on Aug 12, 2014 |
# ? Aug 12, 2014 03:47 |
|
0zABADJOKE
|
# ? Aug 12, 2014 03:49 |
|
Shut up, you 0xBA57AA4D5.
|
# ? Aug 12, 2014 06:40 |
|
code:
|
# ? Aug 12, 2014 22:48 |
|
My horror for today: just got harassed by an ex-employee of a company I was at in 2013. Our industry really sucks sometimes. (not so much a coding horror as it is a coder horror, I suppose)
|
# ? Aug 13, 2014 06:14 |
|
Dick people exist everywhere and in every industry. Just learn to deal with them as best you can.
|
# ? Aug 13, 2014 16:02 |
|
edit: n/m
kitten smoothie fucked around with this message at 16:14 on Aug 13, 2014 |
# ? Aug 13, 2014 16:06 |
|
Suspicious Dish posted:Dick people exist everywhere and in every industry. Just learn to deal with them as best you can. quote:First let me say that I don't really appreciate this sort of correspondence. I think even less of pestering third parties about my current whereabouts. If <crappy company> is looking for a paid consultant, I will be happy to discuss my hourly rate; otherwise, please do not contact me again.
|
# ? Aug 13, 2014 22:40 |
|
Ah coder horrors eh?code:
I created a website scraper to pull every bit of content and created a new instance of the website on my server. The scraper apparently crashed his server and somehow deleted everything on it (I used throttling ). He threatened to sue but it's not like I had a dollar to my name (first computer job and it paid only $12/hr part time). He didn't have any backups. Karma is a bitch. Still making $75/mo off this client for web hosting.
|
# ? Aug 13, 2014 23:10 |
|
|
# ? Jun 8, 2024 07:50 |
|
How is it possible that any amount of load on his server could ever cause deletion of data? Alright, assuming some things are in memory and waiting to be written to whatever data store, that might be a problem in certain cases, but everything??!
|
# ? Aug 14, 2014 02:10 |