Archives

Categories

Source Code With Emoji

The XKCD comic Code Quality [1] inspired me to test out emoji in source. I really should have done this years ago when that XKCD was first published.

The following code compiles in gcc and runs in the way that anyone who wants to write such code would want it to run. The hover text in the XKCD comic is correct. You could have a style guide for such programming, store error messages in the doctor and nurse emoji for example.

#include <stdio.h>

int main()
{
  int 😇 = 1, 😈 = 2;
  printf("😇=%d, 😈=%d\n", 😇, 😈);
  return 0;
}

To get this to display correctly in Debian you need to install the fonts-noto-color-emoji package (used by the KDE emoji picker that runs when you press Windows-. among other things) and restart programs that use emoji. The Konsole terminal emulator will probably need it’s profile settings changed to work with this if you ran Konsole before installing fonts-noto-color-emoji. The Kitty terminal emulator works if you restart it after installing fonts-noto-color-emoji.

This web page gives a list of HTML codes for emoji [2]. If I start writing real code with emoji variable names then I’ll have to update my source to HTML conversion script (which handles <>" and repeated spaces) to convert emoji.

I spent a couple of hours on this and I think it’s worth it. I have filed several Debian bug reports about improvements needed to issues related to emoji.

5 comments to Source Code With Emoji

  • Onan the Barbarian

    Wow, you took being a nerd to a higher level. (That is a compliment in case it wasn’t clear.)

  • LtWorf

    In haskell I used to define inline functions to be able to write expressions like: a ? b ? (x ? X).

    Nowadays I use more boring programming languages, so I’m just sticking to emoji in string literals, to display bus/tram/ferry in the terminal travel planner.

  • I suggest you pair this post with a terminal such as Kitty. Being Kitty scriptable, it is loaded with several “kittens”; I have a keybinding with Ctrl-Alt-U to trigger the “unicode-input” kitten, where you can easily search the Unicode character space by hex code or description, or choose from either your recorded favorite characters or the preset emoticons.

    My Unicode usage has spiked since I switched to Kitty ?

  • Onan: Thanks.

    LtWorf: Some of the systemd commands use emoji which gives the possibility of commands like:
    systemd-analyze security|grep ?

    Gunnar: I’m using Kitty now but haven’t adopted all it’s features. I’ll have to try that unicode-input kitten, thanks for the suggestion.

    I’ve also filed a Debian bug report about Konsole not handling the emoji font as well as Kitty.

  • … and my blog doesn’t take emoji comments the way I’d like.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>