Golang : Experimental emojis or emoticons icons programming language
So, after I published my experimental Jawi programming language code on Facebook, someone asked me if it is possible to code in any other human languages such as Kristang or emojis/emotion icons? The answer is YES. Below is an adaptation of the previous code but with a slightly different dictionary.
In the dictionary, the Golang's reserved words are mapped to some randomly selected emojis for this demo. You can replace the [bikini-icon], [shit-icon], etc with proper emojis before running this code below or copy the code at https://play.golang.org/p/GLlL8v_XdQa
Here you go!
package main
import (
"fmt"
"strings"
"text/scanner"
)
func main() {
emojisGolang := map[string]string{}
dictionary := `var,[bikini-icon]
Println,[ghost-icon]
const,[devil-icon]
package,[briefcase-icon]
import,[smiley-icon]
main,[shit-icon]
func,[candy-icon]`
lines := strings.Split(dictionary, "\n")
// build the dictionary
for _, line := range lines {
if len(line) > 0 {
split := strings.Split(line, ",")
golang := split[0]
emojis := split[1]
emojisGolang[emojis] = golang
}
}
//test
emojisCode := `
[briefcase-icon] [shit-icon]
[smiley-icon] (
"fmt"
)
[bikini-icon] txt = "هاي دنيا ! 世界汝好 ! Hello World ! "
[candy-icon] [shit-icon]() {
fmt.[ghost-icon](txt)
}`
codeReader := strings.NewReader(emojisCode)
var scn scanner.Scanner
scn.Init(codeReader)
scn.Whitespace ^= 1<<'\t' | 1<<'\n' | 1<<'\r' | 1<<' ' // don't skip tabs and new lines
for tok := scn.Scan(); tok != scanner.EOF; tok = scn.Scan() {
switch tok {
case '\n':
fmt.Println()
case '\t':
fmt.Print(" ")
default:
if emojisGolang[scn.TokenText()] != "" {
fmt.Print(emojisGolang[scn.TokenText()])
} else {
fmt.Print(scn.TokenText())
}
}
}
fmt.Println()
}
You can run the code at : https://play.golang.org/p/GLlL8v_XdQa
Reference :
https://socketloop.com/tutorials/golang-experimental-jawi-programming-language
See also : Golang : Experimental Jawi programming language
By Adam Ng(黃武俊)
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+13.1k Golang : Linear algebra and matrix calculation example
+12.3k Golang : Exit, terminating or aborting a program
+6.8k Javascript : How to get JSON data from another website with JQuery or Ajax ?
+78.5k Golang : How to return HTTP status code?
+26.5k Golang : Find files by extension
+5.2k Golang : Intercept, inject and replay HTTP traffics from web server
+4.4k JavaScript : Rounding number to decimal formats to display currency
+6.7k Golang : Calculate BMI and risk category
+34.8k Golang : Upload and download file to/from AWS S3
+6.3k Grep : How to grep for strings inside binary data