flashgnash,

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”

nothacking, (edited )

This just prints:


<span style="color:#323232;">💩
</span><span style="color:#323232;">🍊
</span><span style="color:#323232;">🍉
</span><span style="color:#323232;">🍉
</span><span style="color:#323232;">🍍
</span><span style="color:#323232;">🍎
</span>

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)

sznio,

Surprisingly more readable than standard C++

S3verin,

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

ICastFist,
@ICastFist@programming.dev avatar

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

balance_sheet,

I unironically love return 👎

Zuberi,
@Zuberi@lemmy.dbzer0.com avatar

Genius honestly

dylanTheDeveloper,
@dylanTheDeveloper@lemmy.world avatar

Can you string match emojis

original_reader,

This… this… this is… GENIUS.

Utter madness, sure. Genius nonetheless.

jecxjo,
@jecxjo@midwest.social avatar

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

ArtisinalBS,

Is 👀 even defined?

CaptainJack42,

Yes, line 28 defines 🍴which defines 👀 and all the structs inherit from 🍴

jasondj,

Brand new sentence.

erogenouswarzone, (edited )
@erogenouswarzone@lemmy.ml avatar

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

aard,
@aard@kyu.de avatar

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

erogenouswarzone,
@erogenouswarzone@lemmy.ml avatar

Sorry, I meant ECMAScript

SubArcticTundra,

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

erogenouswarzone,
@erogenouswarzone@lemmy.ml avatar

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

hxd,
@hxd@mastodon.sdf.org avatar
jimmux,

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.

xigoi,
@xigoi@lemmy.sdf.org avatar
balance_sheet,

Conceptually Bright (on their website)

What?

Neon,

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

exoplanetary,
@exoplanetary@lemmy.world avatar

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,

that actually makes sense. thanks for that explanation.

SouthernCanadian,

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

zib,
@zib@kbin.social avatar

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

pwalker,

it’s hard to believe…

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • uselessserver093
  • Food
  • aaaaaaacccccccce
  • [email protected]
  • test
  • CafeMeta
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • Socialism
  • KbinCafe
  • TheResearchGuardian
  • oklahoma
  • feritale
  • SuperSentai
  • KamenRider
  • All magazines