Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

何不把代码本身中文化? #1

Closed
nobodxbodon opened this issue Aug 4, 2017 · 7 comments
Closed

何不把代码本身中文化? #1

nobodxbodon opened this issue Aug 4, 2017 · 7 comments

Comments

@nobodxbodon
Copy link

如果受众是中文为母语的开发者,

我.工作().晋升().成为('总经理').成为('CEO').娶('白富美').巅峰().激动()

相比

> i.work().promoted().become('总经理').become('CEO').merry('白富美').peak().excited()

应该更可读吧?

@twhy
Copy link
Member

twhy commented Aug 4, 2017

这个确实更可读,主要是考虑到学生实际工作还是要用英文写代码,我在对象那一节里面用了比较多中文变量名,主要是帮助学生理解。你的这个例子我也放进入去了,让学生自己实现一个中文的 I 类。

@twhy twhy closed this as completed Aug 4, 2017
@nobodxbodon
Copy link
Author

对于国内用英文写代码的普遍现状, 很难理解. 也许是站着说话不腰疼(在国外打工,工作用的全是英文). 国内的企业绝大多数应该都没有外籍雇员(不懂中文的)吧? 为什么还要使用英文编写代码呢?

@nobodxbodon
Copy link
Author

唯一能想到的一类企业是外包企业, 国外用户肯定要英文代码. 但其他企业呢?

@twhy
Copy link
Member

twhy commented Aug 4, 2017

以前端来说,只有一些最新的浏览器才支持中文变量名,如果完全不用考虑兼容性,而且团队也同意使用中文编程,那是没问题的。

@nobodxbodon
Copy link
Author

这个问题之前没考虑过, 搜了一下看到这里:

ECMAScript source text is represented as a sequence of characters in the Unicode character encoding, version 3.0 or later. [...] ECMAScript source text is assumed to be a sequence of 16-bit code units for the purposes of this specification. [...] If an actual source text is encoded in a form other than 16-bit code units, it must be processed as if it was first converted to UTF-16.

根据这里, ECMAScript 3.0 在2003年之前就已经成型了. 还是哪里理解错了?

@twhy
Copy link
Member

twhy commented Aug 4, 2017

你有没有在比如 IE8, 9 测试过?如果团队同意用中文是没啥问题啦。我实际操作下来觉得中文编程适合用来教学解释,感觉写代码的时候如果用中文变量,要经常切换输入法,不是特别方便。你们团队有试过整个项目用中文编程吗?

@nobodxbodon
Copy link
Author

还好手边有vista. IE9支持的.
到现在为止只发现了单人项目用中文代码编写的(我的几个实验性Java项目, 还有这个Python项目).
输入法用的搜狗, 中英文混输感觉还行(选上"中文下使用英文标点"). 个人感觉关键是代码可读性带来的维护成本下降, 毕竟开发一时, 维护一世.
现在刚开始汇集对中文开发有兴趣的开发者. 希望能够出一些开源项目.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants