this post was submitted on 30 Jun 2024
553 points (98.1% liked)

Programmer Humor

19817 readers
98 users here now

Welcome to Programmer Humor!

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

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 

Meme transcription:

Panel 1: Bilbo Baggins ponders, “After all… why should I care about the difference between int and String?

Panel 2: Bilbo Baggins is revealed to be an API developer. He continues, “JSON is always String, anyways…”

you are viewing a single comment's thread
view the rest of the comments
[–] docAvid@midwest.social 2 points 5 months ago (1 children)

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@sopuli.xyz 2 points 5 months ago (1 children)

PHP and Node definitely do.

Node doesn’t.

> parseInt('077')
77
  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).

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt

[–] docAvid@midwest.social 2 points 5 months ago (1 children)

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@sopuli.xyz 1 points 5 months ago

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”.