“This is the 27th day of my participation in the First Challenge 2022. For details: First Challenge 2022”
Most programming languages are created to satisfy some real need, but some are just artistic statements. One such artistic claim is the Emojicode language — which bills itself as “a full-fledged programming language made of Emojis”.
Hello World
Let’s start by writing Hello World:
๐ญ๐๐ธ๐
๐ ๐
๐ ๐ค๐ท๐ด๐ป๐ป๐พ, ๐
๐พ๐
๐ป๐ณ๐คโ๏ธ
๐
Copy the code
As you can see, the usual keywords have been replaced by emojis:
- ๐ญ is the comment line
- ๐ ๐… ๐ is the main function
- ๐ค is like quotation marks
- ๐… โ๏ธ is like printing
- Generally, โ๏ธ ends the parameter list
The contents of strings and annotations aren’t necessarily emoticons, but I also spice them up with my app to make fancy text.
variable
We can use โก๏ธ to put things into variables. The variable is on the right, which is a fairly unconventional choice, but not entirely unheard of. ๐งฒ for string interpolation:
๐ ๐ ๐ค โ โฅ โ โก โจ โ โ โ ๐ค โก ๏ธ who ๐ ๐ค ๐ท ๐ด ๐ป ๐ป ๐พ, ๐งฒ who ๐งฒ ๐ค โ ๏ธ ๐Copy the code
List and for loops
List by ๐ฟ… ๐. I got the first emoji and am not so sure about the second.
You can use the loop ๐ iterator list ๐ body ๐, which is a nice loop emoji:
๐ ๐ ๐ฟ ๐ค Python ๐ค ๐ค JavaScript ๐ค ๐ค Ruby ๐ค ๐ค Emojicode ๐ค ๐ค PHP ๐ค ๐ โก ๏ธ languages ๐ ๐ค Most important languages to Learn ๐คโ๏ธ ๐ language Languages ๐ ๐ languageโ๏ธCopy the code
FizzBuโโzz
We also need to prepare a few things in advance here.
๐ variable ๐โฉ start afterend step equivalent to (start, afterend, Step) range loop I ๐ฎ 15 ๐ 0 equivalent to I % 15 == 0 โช๏ธ, ๐ ๐ and ๐ equivalent to if, else if and else With it, we can either write a FizzBuzz or use fancy fonts for output:
๐ ๐ ๐ I ๐ service1 101 1 โ ๐
โช๏ธ i ๐ฎ 15 ๐ 0 ๐
๐ ๐ค๐ฝ๐๐ซ๐ซ๐น๐ฆ๐ซ๐ซ๐ค โ
๐
๐
โช๏ธ i ๐ฎ 3 ๐ 0 ๐
๐ ๐ค๐ฝ๐๐ซ๐ซ๐ค โ
๐
๐
โช๏ธ i ๐ฎ 5 ๐ 0๐ ๐ ๐ค ๐น ๐ฆ ๐ซ ๐ซ ๐ค โ ๐ ๐
๐ ๐ ๐ค ๐งฒ I ๐งฒ ๐ค โ ๐ ๐ ๐Copy the code
function
There’s one more thing we need to know — functions.
I’m a little confused, the documentation doesn’t say anything about the function. It has closures, so we think this might work:
๐ ๐ ๐ I ๐ข commit commit ๐ข โฉ๏ธ I archtadi๐ commit commit double ๐ข ๏ธ double21โ ๐งฒ ๐ค โ ๐Copy the code
We need to declare the type. ๐ขโก๏ธ๐ข accepts an integer and returns an integer. โฉ๏ธ is the payoff. โ ๏ธ… โ is a function call. Not bad.
Y combinator fails
Unfortunately these don’t recurse, so this doesn’t work at all!
๐ ๐ ๐ n ๐ข disk ๐ ๐ n ๐3๐ โฉ ๏ธ1๐๐
๐ ๐ญ Does not work ๐
๐
๏ธ fib n โ1โ โ โ ๏ธ fib n โ2โ ๐ ๐ โก๏ธ fib ๐ login time ๏ธ fib5โ ๐งฒ ๐ค โ ๐Copy the code
I’ve considered using the old Lisp trick and passing fib closures as arguments so that it can call itself, but this only works if there are no stupid types getting in the way. The type system might support the Y combinator if it supports recursive types, but I don’t think Emojicode does.
Classes
Its documentation doesn’t say anything about functions, but it does have classes. So let’s use the method ๐ to define the class ๐ค to do fib:
๐ ๐ค ๐ ๐๐ ๐ โ๏ธ ๐ n ๐ข ๐ข ๐ โช๏ธ n recruitment3๐ โฉ ๏ธ1๐ ๐
๐ โฉ ๏ธ ๐ ๐ n โ1โ โ ๐ ๐ n โ2โ ๐ ๐ ๐ ๐ ๐ ๐๐คโ๏ธ fib ๐ I ๐โฉ1 31 1โ ๐ ๐fib I โ๏ธ x ๐ ๐ค๐งฒx๐งฒ๐คโ ๐ ๐Copy the code
If you’ve done some research, this code shouldn’t be too difficult to understand.
- ๐๐คโ๏ธ port fib- Creates a new PORT OF X and assigns it to the fib variable
- ๐fib I โ๏ธ โก๏ธ x- Call the service fib on the instance, calling our unique method I with arguments
- ๐ ๐ค ๐… ๐- Define a class named ๐ค (the class name must be an emoji)
- ๐๐๐- Empty constructors, we need to create some constructors for each class, even if it doesn’t do anything
- โ๏ธ ๐ n ๐ข doctor โ… ๐- Define method ๐… โ๏ธ takes an integer argument n and returns an integer
- โฉ ๏ธ ๐ ๐ n โ 1 โ โ ๐ ๐ n โ โ – recursive calls, 2 ๐ ๐ n โ โ is this 1. ๐ (n – 1) is more commonly used language
A unified code
This language was certainly created as an artistic statement (or as a joke, if you prefer), but it raises an important question. Throughout the history of programming, almost all languages (APL and Raku are the most notable exceptions, don’t worry — we’ll definitely cover both in this series) have been limited to plain text with ASCII characters.
Even ASCII symbols are clearly not enough, so symbols are reused to represent ten different things (try to list all the syntactic meanings of characters in JavaScript or indeed almost any language), and long strings like {} are used to fake extra characters. ! * * = = =
So the question is – should programming languages continue to limit themselves to ASCII, or is it finally time to embrace Unicode as a whole? An interesting middle ground is hyphenated fonts like Fira Code – the source Code still says! ==, but in the editor you will see โข.
โจ is written at the end
Want to see what I’m doing? Check out my personal website and GitHub
Need a top-tier full-stack developer freelancer to eliminate your development dilemmas? Contact information can be obtained from the blogger’s nuggets homepage, remember to note nuggets ๐๐๐ juejin.cn/user/204034…