746
War Crimes (lemmy.world)
all 40 comments
sorted by: hot top controversial new old
[-] fri@compuverse.uk 91 points 1 year ago* (last edited 1 year ago)

Looks like it creates a few emoji printers in a vector, then prints them all. The output is all emoji, of course. The main function exits with a random return value just to be more quirky.

I'm not sure what the purpose of the 😎 function is. In main that first predicate is always true, so it prints the poop emoji. I don't know why it's behind an if.

Also, there's a copy-paste error on line 31. Wrong emoji is used.

[-] randomuser38529@lemmy.world 30 points 1 year ago

This guy emotes ᕦ(Γ²_Γ³Λ‡)α•€

[-] SouthernCanadian@sh.itjust.works 50 points 1 year ago

Wow that's horrible. They're using c++.

[-] zib@kbin.social 33 points 1 year ago

If you really need some nightmare fuel, some of us use c++ every day and even enjoy it.

[-] pwalker@discuss.tchncs.de 2 points 1 year ago

it's hard to believe...

[-] erogenouswarzone@lemmy.ml 37 points 1 year ago* (last edited 1 year ago)

It would be great to use some emojis in coding.

Imagine how much more readable it would be if you could break a loop with πŸ’€ or return true with πŸ‘. Or use ❓for ifs, or ↔️ for switch (the emoji didn't work for that one). Or use an emoji to represent a custom object?

Maybe the ECMA should get on that!

Edit: I guess you can use emojis for custom objects in js.

Edit 2: ➑ for console.log

[-] SubArcticTundra@lemmy.ml 8 points 1 year ago

You'd still be left with the brackets and braces though. It might make more sense in a whitespace-based language pike Python

[-] erogenouswarzone@lemmy.ml 5 points 1 year ago

I see your point. Personally, I like the brackets and braces, they help organize. Or maybe that's just what I'm used to.

[-] aard@kyu.de 2 points 1 year ago

emacs lisp already lets you use the full range of unicode.

[-] erogenouswarzone@lemmy.ml 1 points 1 year ago
[-] jimmux@programming.dev 2 points 1 year ago

Programming typefaces with ligatures are a step in this direction.

I would try this in something like Haskell, where some of the more exotic character sequences get tricky to recognise.

Unison might be the best language to test this in. Having identifiers separate from the actual definitions, you can call anything whatever you want.

[-] magic_lobster_party@kbin.social 18 points 1 year ago* (last edited 1 year ago)

πŸ’©
🍊
πŸ‰
πŸ‰
🍍
🍎

[-] sznio@lemmy.world 17 points 1 year ago

Surprisingly more readable than standard C++

[-] RagnarokOnline@reddthat.com 15 points 1 year ago

I didn’t bother trying to see what an output would be, but this is a nightmare.

[-] Rai@lemmy.dbzer0.com 2 points 1 year ago

Oh no, now I’m going to notice you in, like, every thread!

[-] RagnarokOnline@reddthat.com 2 points 1 year ago

Hahaha, I’m inevitable! The nostalgia is too powerful!

[-] nothacking@discuss.tchncs.de 11 points 1 year ago* (last edited 1 year ago)

This just prints:

πŸ’©
🍊
πŸ‰
πŸ‰
🍍
🍎

Line 38 and 39 just check if a function that always returns false is false and if so, prints "πŸ’©\n". (C++ uses the bit shift operator for file IO for some reason)

Line 41 creates a vector of shared pointers to an abstract class, or in other words, an array of functions. Each function prints the emoji, mostly the same as the name, but not always. ( πŸ’ is the exception, it prints "πŸ‰\n")

43 and 44 just loop over the array and call every function inside, printing a bunch of emoji.

Line 46 returns the result of std::rand(), but because the programer forgot to call srand, the result is always the same (1804289383 for me).

(There are also a few missing includes, but I doubt this is intentional)

[-] ArtisinalBS@lemm.ee 11 points 1 year ago
[-] CaptainJack42@discuss.tchncs.de 15 points 1 year ago

Yes, line 28 defines 🍴which defines πŸ‘€ and all the structs inherit from 🍴

[-] jasondj@ttrpg.network 10 points 1 year ago

Brand new sentence.

[-] Zuberi@lemmy.dbzer0.com 10 points 1 year ago

Genius honestly

[-] kspatlas@artemis.camp 10 points 1 year ago
[-] flashgnash@lemm.ee 9 points 1 year ago

Now imagine the poor sod who gets this as an interview question

"Please extend the following code in the same code style to sort [πŸ˜€,πŸ˜ƒ,πŸ˜„,😁,πŸ˜†] using bubble sort"

[-] xigoi@lemmy.sdf.org 7 points 1 year ago
[-] SpeakinTelnet@sh.itjust.works 6 points 1 year ago

Mojo prepared me for this with their filename extension .πŸ”₯

[-] heimchen@discuss.tchncs.de 4 points 1 year ago

Assembly but the commands are emojies🀯

[-] S3verin@slrpnk.net 4 points 1 year ago

Ive written a transpiler for JS that allows emojis. I call it emojs: https://github.com/f-kirchhoff/emojs

[-] db2@sopuli.xyz 4 points 1 year ago
[-] Neon@kbin.social 3 points 1 year ago* (last edited 1 year ago)

i'm not used to c++ but...
int main() ?

[-] exoplanetary@lemmy.world 13 points 1 year ago

Yep, main returns an int in C++. It’s for the return code - if it returns 0, that indicates the program ran ok, if it returns anything else some sort of error occurred.

[-] Neon@kbin.social 3 points 1 year ago

that actually makes sense. thanks for that explanation.

[-] jecxjo@midwest.social 3 points 1 year ago

Haha did the same thing years ago to make the code look like free flowing text.

[-] original_reader@lemm.ee 3 points 1 year ago

This... this... this is... GENIUS.

Utter madness, sure. Genius nonetheless.

[-] ICastFist@programming.dev 3 points 1 year ago

I think you could pull a similar breach of geneva conventions quite easily with Nim, probably even beyond what you can with C++

No, I'm not intelligent, nor crazy enough to try that

[-] dylanTheDeveloper@lemmy.world 2 points 1 year ago

Can you string match emojis

this post was submitted on 15 Aug 2023
746 points (97.1% liked)

Programmer Humor

31749 readers
147 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS