Lisp Programming Language in Chinese

I was reading about the history of programming languages based on Chinese characters when I had an idea. With a Lisp implementation that supports Unicode, it should be possible to create Chinese aliases of Lisp special forms using Lisp macros. Here's a Chinese programming language I made using Racket:

#lang racket
;;;; 華文编程语言。

;;; 巨集。
(define-syntax  (make-rename-transformer #'define))
(define-syntax  (make-rename-transformer #'if))
(define-syntax 條件 (make-rename-transformer #'cond))
(define-syntax  (make-rename-transformer #'list))
(define-syntax  (make-rename-transformer #'cons))
(define-syntax  (make-rename-transformer #'car))
(define-syntax  (make-rename-transformer #'cadr))
(define-syntax  (make-rename-transformer #'caddr))
(define-syntax  (make-rename-transformer #'cdr))
(define-syntax  (make-rename-transformer #'display))
(define-syntax 出行 (make-rename-transformer #'displayln))
(define-syntax 新行 (make-rename-transformer #'newline))
(define-syntax  (make-rename-transformer #'true))
(define-syntax  (make-rename-transformer #'false))
(define-syntax  (make-rename-transformer #'and))
(define-syntax  (make-rename-transformer #'or))
(define-syntax  (make-rename-transformer #'not))

;;; 開始!

;;; 一。
( "我叫小明。")
(出行 "我今年八歲。")

;;; 二。
(  ( 1 2 3 4 5))
( )  ; 1
( )  ; 2
( )  ; 3
( )  ; '(4 5)

( ( "龍" "鳳"))  ; "龍"

;;; 三。
( (乘二 )
  (* 2 ))

( (乘四 )
  (乘二 (乘二 )))

( 號碼 5)

( (= 號碼 1)
  (出行 "號碼是一。")
  (出行 "號碼不是一。"))

(條件 ((> 號碼 0)
       (出行 "號碼比零大。"))
      ((< 號碼 0)
       (出行 "號碼比零小。"))
       (出行 "號碼是零。")))

( "乘了四侯: ")
(出行 (乘四 號碼))

;;; 四。
(  )
( ( ) ( ))

Note that some of these keywords may have been translated incorrectly into Chinese because of my limited Chinese.

Interesting Observations

  • One immediately notices that most of the keywords have the same length. This is unlike English programming languages where keywords have greater differences in lengths (e.g. cons, display vs. ). I do not think this will be a serious readability problem, because even without syntax highlighting, the code above looks very clear to me. This is probably going to be a matter of personal taste.

  • The code is compact, as the keywords are one or two characters long.

  • I am unable to judge the efficiency of typing out the Chinese characters relative to English letters, because I only started typing Chinese recently.

  • When typing out the code above, I did not have the help of autocomplete suggestions that I normally have when writing code. Notice that since most keywords are one character long, there is nothing left to complete after the first character is entered. I'm not exactly sure how Chinese keyword completions are going to work in the future. Perhaps Chinese autosuggestions can show a list of suggestions before anything is typed.

  • The code above is written in traditional Chinese characters. Small font sizes make it difficult to discern the strokes of the characters. Also, it's possible to mix up two characters that look almost the same. Solution: increase the font size, or use simplified characters. Maybe I'm just overthinking this problem.


The example above could conceivably be turned into a toy Racket language (e.g. #lang chinese or even #lang 華文) that others can use to program using Chinese keywords. At the moment, my knowledge of Scheme, Racket, and Chinese are too limited implement this idea. Is there anyone who's up for the challenge of creating a Chinese Lisp language for Racket?