“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…