Qu, a derivative of Go's syntax, using Kanji for keywords, special identifiers, and common package names
github.com/gavingroovygrover/quPosted Apr 11, 2016, 11:15 PM UTC
Posted Apr 11, 2016, 11:15 PM UTC
Why say "kanji" instead of "hanzi" if all the examples are Chinese, not Japanese? Is "kanji" an English word now? :-)
In English, I'd say "Chinese characters", or "Kanji" to mean Chinese characters as used in Japan. I wouldn't say "Hanzi" in English.
Ideally, the aliases in Qu would be from the subset of Hanzi/Kanji common to both Chinese and Japanese.
I can read Japanese. Several of the characters in Qu are simplified in the mainland style. You could allow both variants though.
Finding out the Japanese versions of the characters is tasked for the next version!
I find this project very interesting, especially given the popularity of Go on the mainland.
On the other hand, removing those characters from being valid variable/function names could be problematic.
I did not think about that. In my brief time working in China, never saw anyone name things in Chinese, but that was a pretty English-centered team.
In virtually all programming books sold in China, Chinese is only used in string contents and comments. The actual code uses the same pseudo-English names as used anywhere else.
The only change Qu makes to Go is to disallow Hanzi/Kanji in identifier names. Everything else works just like in Go, so I don't forsee anything being problematic.
This particular project (Qu) may not be adopted, but if it inspires some one else to create a Go-based language using Hanzi/Kanji, and those Hanzi/Kanji become defacto standard aliases for the keywords, special identifiers, and some package names in Go, then I'd be quite happy.
RIP readability
Readability depends on what the reader is used to. Some people find regex notation, used by various languages including Go, difficult to read. Qu is translated to standard Go syntax anyway, by building the AST, then running gofmt on it.
So Qu is intended as a programmers own choice, whereas the generated Go syntax is intended for sharing source with others.
Why would anyone want to write code using a syntax that they need to transpile for others to be able to read it? Isn't the point of transpilers generally the opposite?
I'd like to be able to write short programs 包正;功正{形println(“你好,世界!“)} on a Qu command line prompt instead of needing to compile a source file for such short programs.
As for your comment about 整64 translating to int 64, there's parser support for those few exceptions, which are workarounds for Go. (I need to reply to that comment here because of a golang subreddit timeout restriction.)
The fact that int64 is 整64 is odd. On the one hand, it makes sense if 整 is int. On the other hand, you mention that all Kanji have an implied space before and after, but int 64 isn't valid Go.
As a full-time Go programmer and long-time student of 中文 I think this is a charming and fun project. My only criticism is that it is a one-way only translation. A better solution would be to allow lossless conversion in either direction between .go and .qu files, then programmers could choose which version to work in. If the project helped to make Go more pleasant to use for Chinese/Japanese speakers that would be worthwhile. However further tooling support and editor add-in support for .qu files would be required for adoption to take-off.
The next direction I intend going with Qu is letting Kanji denote macros. The macros would be written in Go, but called in Qu where lowercase-initial identifiers aren't available (because they always translate to underscore-initial identifiers), so the Go code could use them to ensure hygiene. Of course, macros would make two-way lossless conversion far more difficult because the macro definition code would be manipulating the AST.
why ? just why ?
Spaceless programming. And I don't like remembering which names are keywords. We also have to remember which names are special identifiers too, so we don't write valid Go code like:
Using kanji for those 64 names means we can use any lowercase-initial name as an identifier.
no offence. Looks like a clusterf***. But I guess that's the beauty of Open source
Can't tell if you're talking about
printing
or my solution to it.
Where does the desire for that come from? Space, Tab, and Enter are some of the most convenient-to-hit keys.
As opposed to having to remember which characters are special identifiers and then switching character sets to type them?
But they take up more room on the screen when reading the code. That's important for smartphone and notepad screens, and keyboards on smartphones don't have convenient-to-hit keys.
It's obvious what special identifiers are -- builtin types (e.g. int), and routines that take them as a parameter (e.g. make). Go introduced a lexical division between public identifiers (i.e. first character uppercase) and private identifiers to make them more obvious in the code. Qu introduces a third lexically-obvious category: Kanji represent keywords, and what should have been keywords (i.e. special identifiers).
I say "should be" because
true,int, etc are keywords in C, Java, C#, etc. Go reduced the number of keywords down to 25 by turningtrueinto something I can assignfalseto, which isn't good.I switch between ascii and kanji by hitting Ctrl-Shift on my keyboard. I thinking of making the version of Qu accept Hanzi/Kanji variations of ascii (e.g.
(for(,;for;) so we can stay in Kanji mode to type everything if we want to.I guess I'm just confused what the target audience for this is. How many people often try to write (Go) code on smartphones? How many people can easily switch between character sets while writing code, while also remembering the meanings of the keywords? Seems like a nightmare for code review and collaboration.
Edit: I've also never met a developer who thinks whitespace is anything but good for readability. At least, the sort of consistent whitespace you get from gofmt.