Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

By utilizing the potential tersity of CJK characters in the language syntax, English-speaking programmers could make their programs much shorter wrt lines of code.

Because there's thousands of CJK characters to choose from, why not just use 印 instead of 印出 for 'print', or 如 instead of 如果 for 'if'? By using bracketing syntax instead of Python's indentation, we can cut down lines of code.

Here's your example using a terser style (the strings and comments would still be in English):

#!/usr/bin/env zhpy

# 檔名: while.py

數= 23, 運= 真

當(運){

  猜= 整(輸入'Enter an integer: ')

  如(猜 == 數){

    印'Congratulations, you guessed it.'

    運= 假 # this causes the while loop to stop

  }否如(猜<數) 印'No, it is higher than that.'

  否 印'No, it is lower than that.'
}否 印'The while loop is over'

印'Done'



I think that's a good argument against using character count as a measure of program length. i.e. translating 印 to print does not improve the program in any way, so it shouldn't score better in any measure of complexity.


'print' is 5 characters long, 印 is 1 character long. Though in most fonts, CJK characters are twice as wide as Latin, so better make that 2 chars long. 5 chars vs 2 chars over an entire program adds up. In non-indentation languages, that can mean 3 lines can be put onto 1 line. Shorter programs are more readable, have less errors.


Shorter by token count, not byte count.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: