Most programming languages are created to address some genuine need, but some are just an art statement. One such art statement is the Emojicode language - self-described as a "full-blown programming language consisting of emojis."
Hello World
Let's start by writing hello.đ
:
đđđžđ
đ đ
đ đ€đ·đŽđ»đ»đŸ, đ
đŸđ
đ»đłđ€âïž
đ
As you can see, usual keywords have been replaced by emoji:
- đ are comment lines
- đ đ ... đ is the main function
- đ€ is like quotes
- đ...âïž is like print
- in general, âïž ends argument list
The contents of the strings and comments don't have to be emoji, but I used my app for fancy text to spice them up as well.
Variables
We can put thing in variables by using âĄïž. Variables go on the right, which is fairly unconventional choice, but not completely unheard of. đ§Č does string interpolation:
đ đ
đ€ââ„ââĄâšâââđ€âĄïžwho
đ đ€đ·đŽđ»đ»đŸ, đ§Čwhođ§Čđ€âïž
đ
Lists and for loops
Lists are created by đż...đ
. I get the first emoji, not so sure about the second one.
You can loop with đ iterator list đ body đ
, which is a decent loop emoji:
đ đ
đż
đ€Pythonđ€
đ€JavaScriptđ€
đ€Rubyđ€
đ€Emojicodeđ€
đ€PHPđ€
đâĄïžlanguages
đ đ€Most important languages to learnđ€âïž
đ language languages đ
đ languageâïž
đ
đ
FizzBuzz
We need a few more things here.
-
đ variable đâ© start afterend step
is afor i in range(start, afterend, step)
loop. -
i đź 15 đ 0
isi % 15 == 0
- âȘïž, đ
ââȘïž, and đ
are
if
,else if
, andelse
And with that we can write a FizzBuzz, using fancy fonts for output as well:
đ đ
đ i đâ© 1 101 1 â đ
âȘïž i đź 15 đ 0 đ
đ đ€đœđđ«đ«đčđŠđ«đ«đ€ â
đ
đ
âȘïž i đź 3 đ 0 đ
đ đ€đœđđ«đ«đ€ â
đ
đ
âȘïž i đź 5 đ 0 đ
đ đ€đčđŠđ«đ«đ€ â
đđ
đ
đ đ€đ§Čiđ§Čđ€ â
đ
đ
đ
Doubling things
We need one more thing - functions.
Well, we're a bit lost. Documentation doesn't say anything about functions. It has closures so we'd think that this might work:
đ đ
đ i đąâĄïžđą
â©ïž iâi
đ âĄïž double
đ đ€đ§Čâïž double 21âđ§Čđ€â
đ
We need to declare types. đąâĄïžđą means takes an integer, and returns an integer. â©ïž is return. âïž...â is function call. Not too bad.
Y Combinator fail
Unfortunately these cannot be recursive, so this doesn't work at all!
đ đ
đ n đąâĄïžđą
âȘïž n âïž 3 đ
â©ïž 1
đđ
đ
đ Does not work
â©ïž âïž fib nâ1âââïž fib nâ2â
đ
đ âĄïž fib
đ đ€đ§Čâïž fib 5âđ§Čđ€â
đ
Well, I thought about doing the old Lisp trick, and pass fib closure as argument to fib, so it can call itself, but that only works if there are no stupid types getting in the way. It's possible for type system to support Y combinator if it supports recursive types, but I don't think Emojicode does.
Classes
The documentation doesn't say anything about functions, but it has classes. So let's define class đ€ with method đ that does fib:
đ đ€ đ
đđ
đ
âïž đ n đąâĄïžđą đ
âȘïž n âïž 3 đ
â©ïž 1
đđ
đ
â©ïž đđ nâ1ââđđ nâ2â
đ
đ
đ
đ đ
đđ€âïž âĄïž fib
đ i đâ© 1 31 1 â đ
đfib iâïž âĄïž x
đ đ€đ§Čxđ§Čđ€â
đ
đ
If you've been following along, this code shouldn't be too difficult to understand.
-
đđ€âïž âĄïž fib
- creates a new đ€ and assigns it tofib
variable -
đfib iâïž âĄïž x
- calls đ onfib
instance, calling our only method with argumenti
-
đ đ€ đ ... đ
- definition of a class with name đ€ (class names must be emoji) -
đđđ
- empty constructor, we need some constructor for every class, even if it doesn't do anything -
âïž đ n đąâĄïžđą đ...đ
- defining method đ...âïž that taken one integer argumentn
and returns an integer -
â©ïž đđ nâ1ââđđ nâ2â
- recursive call, đđ nâ1â isthis.đ(n-1)
in more usual language
Unicode
This language was of course created as an art statement (or as a joke if you prefer to put it that way), but it asks an important question. Throughout the history of programming, nearly every language (APL and Raku being the most notable exception, and don't worry - we'll surely cover both in this series) limited itself to just plain text with ASCII characters.
Even though ASCII symbols were clearly not enough, so symbols get reused to mean ten different things (try to list all syntactic meanings of {}
characters in JavaScript or actually in just about any language), and long strings of characters like !==
, **=
and such get used as fake extra characters.
So the question is - should programming languages keep limiting themselves to just ASCII, or is it finally time to embrace the whole Unicode? An interesting middle ground are ligature fonts like Fira Code - the source code would still say !==
, but in the editor you'd see âą
.
Code
All code examples for the series will be in this repository.
Top comments (2)
Thanks đ as a Programming Languages addictâŠthis is pure awesomeness đ€©
I'm impressed this actually exists đ