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.

BoastfulDaedra , in no.. just no

I haven’t been this pissed off since LINQ started allowing syntax switches in random-ass places.

SaltyIceteaMaker , in no.. just no
@SaltyIceteaMaker@iusearchlinux.fyi avatar

got no clue abot sql. what is wrong and how is it supposed to look like?

Daxtron2 ,

this basically xml being made to look like SQL. It’s gross and that’s why it’s funny

ILikeBoobies ,

Different language

traches ,

SQL is run on the server to communicate with a database. The screenshot is jsx, which is a front-end, UI templating language. Writing SQL this way is cursed

schnurrito ,

SQL is supposed to look like this: SELECT status, name FROM some_table LIMIT 5

httpjames , in no.. just no
@httpjames@sh.itjust.works avatar

Joins must be a pain in the ass with hooks

merc , in 4 billion if statements

I like this bit at the end:

As a side note, the program is amazingly performant. For small numbers the results are instantaneous and for the large number close to the 2^32 limit the result is still returned in around 10 seconds.

caellian ,

Really makes you question your sanity when optimizing jumps in code without benchmarks.

merc ,

For a long time I’ve been of the opinion that you should only ever optimize for the next sucker colleague who might need to read and edit your code. If you ever optimize for speed, it needs to be done with massive benchmarking / profiling support to ensure that the changes you make are worth it. This is especially true with modern compilers / interpreters that try to use clever techniques to optimize your code either on the fly, or before making the executable.

Klear ,

The first rule of optimization: Don’t do it
The second rule of optimization: Don’t do it yet (experts only)

Ephera ,

I’m absolutely on-board …in application code.

I do feel like it’s good, though, when libraries optimize. Ideally, they don’t have much else to do than one thing really well anyways.

And with how many libraries modern applications pull in, you do eventually notice whether you’re in the Python ecosystem, where most libraries don’t care, or in the Rust ecosystem, where many libraries definitely overdo it. Because well, they also kind of don’t overdo it, since as a user of the library, you don’t see any of it, except the culmulative performance benefits.

merc ,

Libraries are also written and maintained by humans.

It’s fine to optimize if you can truly justify it, but that’s going to be even harder in libraries that are going to be used on multiple different architectures, etc.

blusterydayve26 ,

I’m still mad he didn’t use the size of the number to tell the system which block to read first. I feel like that would be a great use for division or maybe modulus?

merc ,

I just like how he used “% 2” in the Python code he used to generate the C++ code.

GreatBlueHeron , in 4 billion if statements

I’m not a good reader - I skim most articles and often miss most of the meaning. I read, and enjoyed, every word of that!

librecat ,
@librecat@lemmy.basedcount.com avatar

Thanks, I totally would’ve skipped it without this comment.

Aatube , in 4 billion if statements
@Aatube@kbin.social avatar

@programming_horror , anyone? We have an in production version of this used in Wikipedia

isildun ,

Instance friendly link: !programming_horror

DrDeadCrash ,

Thank you!

Aatube ,
@Aatube@kbin.social avatar

I'm pretty sure that my link also works regardless of instance. It works when I visit it on your instance.

onlinepersona , in 4 billion if statements

I honestly thought this was going to be about AI 😅

CC BY-NC-SA 4.0

MxM111 ,

No, this is about NS. Natural Stupidity.

DarkGamer , in 4 billion if statements
@DarkGamer@kbin.social avatar

This is why every programmer needs to understand the modulo operator.

MxM111 ,

I would divide by two (floating point) and check the fractional part.

sus ,

turns out that 2^53 + 1 is an even number

iknowitwheniseeit ,

The article only covers unsigned 32-bit numbers, so floating point division would be fine.

ThrowawayPermanente , in 4 billion if statements

Let’s be real though, everything is IF statements all the way down

Th4tGuyII ,
@Th4tGuyII@kbin.social avatar

There's not a single thing in this universe that cannot be accomplished with enough IF statements... as long as you've got infinite time to wait

firecat ,

The problem with if is the answer comes from user. There’s no mathematical reason or scientific explanation, only programmer who thinks the answer should include the subject.

Th4tGuyII ,
@Th4tGuyII@kbin.social avatar

True...

But even on a more metaphorical level, every single thing that has or will happen in this universe, down to even the smallest quantum fluctuations could be encapsulated into IF statements as long as you had enough of them.

Hotzilla , in 4 billion if statements

Could be easily made 50% space saving by only iffin all odds and return even on else. Maybe one if before to handle overflow to avoid wrong even if over the last if.

Deebster ,
@Deebster@programming.dev avatar

Well yeah, if you allow cheating!

bjorney ,

Yeah but then ALL even numbers would be slow to compute because you would have to chain through every odd before you know that 2 is even.

Depends on the expected distribution of input values

coloredgrayscale ,

Heuristic: keep it until 512, afterwards powers of 2, and numbers like 1000, 2000,…, 10000, 20000,… (regex: [0-9]000+)

Ephera , in 4 billion if statements

Now we just need to someone to package it and upload it to NPM.

NovaPrime , in 4 billion if statements
@NovaPrime@lemmy.ml avatar

Andreas is a maniac

Sanchokan , (edited ) in The Holy Trinity of JavaScript

A few years back I came to the conclusion that the holy trinity in Christianity are three levels of abstraction: the son => God walks on earth and tangible, the father => God in heaven untangible but still reachable by speech, holy spirit => God in who knows where.

Then I thought that as a way of imparting the thought that any level of abstraction of the universe would also be inhabitated by God, those which we can sense, and those where our senses can't reach. The idea that omniprescense is not only limited to our dimension.

I'm not sure if that is the original meaning but is a way of seeing it that I can relate to, since I've always been akeen to a more abstract idea of God, and not so much to a figure that praises itself of thought, which is a human attribute.

yannic ,
CanadaPlus ,

As far as I can tell, the doctrine of the trinity served political rather than logical purposes back when it was put in writing in late antiquity, and since then it’s just been the doctrine. If you want to believe, you just have to believe and not think about it too hard, like the video says.

expr , in no.. just no

Not only is this really gross, it’s also straight up wrong. It’s missing a from clause, and it makes no sense for a where clause to be nested under the select. The select list selects columns from rows that have already been filtered by the where clause. Same for the limit.

Also just gonna go ahead and assume the JSX parser will happily allow SQL injection attacks…

nephs ,

Booooo

CanadaPlus ,

I like the format, though.

adhocfungus , in no.. just no
  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines