"是先有了 Unicode 支持再有了中文、日文编程的需求"?

2018-12-22 16:07:36 +08:00
 xuanwu

出自这条回复: https://www.v2ex.com/t/518915#r_6628068

现在觉得也许这种看法的不在少数. 为此, 节选十一年前Python3 选择支持非 ASCII 码标识符的缘由:

Rationale(依据)一节开篇明义, 指出用母语命名标识符对代码清晰度和可维护性的提高.

Python code is written by many people in the world who are not familiar with the English language, or even well-acquainted with the Latin writing system. Such developers often desire to define classes and functions with names in their native languages, rather than having to come up with an (often incorrect) English translation of the concept they want to name. By using identifiers in their native language, code clarity and maintainability of the code among speakers of that language improves.

下面列出了一些质疑和回应. 其中:

People claim that they will not be able to use a library if to do so they have to use characters they cannot type on their keyboards. However, it is the choice of the designer of the library to decide on various constraints for using the library: people may not be able to use the library because they cannot get physical access to the source code (because it is not published), or because licensing prohibits usage, or because the documentation is in a language they cannot understand. A developer wishing to make a library widely available needs to make a number of explicit choices (such as publication, licensing, language of documentation, and language of identifiers). It should always be the choice of the author to make these decisions - not the choice of the language designers.

不用翻译吧

5526 次点击
所在节点    程序员
57 条回复
jimchen9999
2018-12-22 19:31:39 +08:00
MMP 的天天刷个没完了
inframe
2018-12-22 21:58:18 +08:00
祥林嫂似的了
mchong
2018-12-22 22:19:34 +08:00
talk is cheap, show me the code.
xuanwu
2018-12-22 23:22:52 +08:00
@d3vil
@UIXX
@mchong "中文编程"知乎专栏有各种语言中文命名的实例 java python js ts kotlin erlang scheme scala 等等
niubee1
2018-12-23 00:18:57 +08:00
@saluton emoji 编程, 赞

一般来说, 老折腾这个话题的, 要么就是没搞清楚编程的本质问题, 要么就是别有用心
pexcn
2018-12-23 00:26:30 +08:00
想起了这张图 XD
xuanwu
2018-12-23 01:01:56 +08:00
@Remember
@niubee1 此贴仅为指出, python 社区的非英语母语开发者在十一年前就已经发现了"用母语命名标识符对代码清晰度和可维护性的提高". 各位乐意用什么语言命名当然是各自自由.
JCZ2MkKb5S8ZX9pq
2018-12-23 01:17:55 +08:00
@UIXX 之前看过他的 github,唉,一言难尽。要不是自称背景挺牛逼的,纯看代码真的满脸民科。
KasuganoSoras
2018-12-23 01:23:35 +08:00
咱先不扯这么多,你试试用中文来重构我这个项目: https://github.com/ZeroDream-CN/PHPMC7
重构完对比一下,看看哪个更容易理解,更清晰,看的更舒服
Talk is cheap, show me the code.
sola97
2018-12-23 01:28:25 +08:00
输入法切换就够烦的了,还有 Linux 下没装输入法的时候
imn1
2018-12-23 01:39:18 +08:00
@AntiGameZ
难道是敌 /对势力在挑起我们人\民内部矛盾?
xxgirl2
2018-12-23 02:01:07 +08:00
负面营销。骂的人多了,也就出名了,目的也就达到了。
xuanwu
2018-12-23 03:40:24 +08:00
@KasuganoSoras 如果只想切磋可读性(不打算实用中文命名), 不妨新开帖子, 挑一段有代表性的, 我尽量试试(肯定需要对代码本身学习一下, PHP 用的很少. 如有问题还请指点). 之前类似的一帖在: https://www.v2ex.com/t/519903

如果打算实用, 不妨移步 github 深入探讨(清静一些), 个人倾向于先添加中文版的 API(方法 /参数名), 这样至少对用户也可能有用(原英文 API 不变).
xuanwu
2018-12-23 05:01:12 +08:00
@KasuganoSoras 之前刚开始对 vue 的命名中文化: https://www.v2ex.com/t/510996#
xlui
2018-12-23 08:32:43 +08:00
你在原文列了那么多语言,结果给出的引用就只有 Python 而且是在我问了之后才去查的吧。如果是在我问了之后去查的那原文那句话还真的是臆测,如果不是当我没说。

我承认我对 Unicode 标识符的理解不够,Python 支持 Unicode 原来是为了支持母语标识符。但是其他呢,我还是会认为 Unicode 标识符只是语言支持 Unicode 顺带的,除非你甩给我参考链接。

“多数现代编程语言都支持 Unicode 命名的事实,说明了这一需求的切实存在。”

这句话前半部分是事实,但是前后之间却没有必然的因果关系,也就是说前者是后者的充分不必要条件,除非有更多的参考链接来佐证。当然我也不是故意刁难,要你去找参考链接。但是只用一篇链接就否定我的观点,自我胜利,太狡猾了吧。

所以我还和之前的想法一样,如果你只是凭空捏造些论点来和别人争论那跟你讨论真的是浪费时间。作为一个布道者却满嘴可能、极大、是可以预见的,说实话有点烦。
xuanwu
2018-12-23 08:49:04 +08:00
@xlui 上文是去年写的. 你觉得还要哪些语言支持 Unicode 标识符的缘由? 站里也许有能人会比我更早挖到相应 issue/thread
xlui
2018-12-23 08:51:24 +08:00
@xuanwu #36 讨论的不是同一个问题,就此打住,勿回。
www5070504
2018-12-23 08:59:43 +08:00
怎么一直在吵吵这个 能不能先写点项目
viator42
2018-12-23 10:39:50 +08:00
有的小众的编辑器连中文都输不进去,还妄想拿中文编程。对了我说的是 Arduino ide
开发用的这些工具都是英语国家的人开发的,他们可不一定有闲心测试中文兼容
你这玩意儿除了让代码好看一点再加了一些兼容性隐患以外没解决任何问题
cyspy
2018-12-23 10:48:11 +08:00
请翻译以下段落:

final class LazyList[+A] private(private[this] var lazyState: () => LazyList.State[A]) extends AbstractSeq[A] with LinearSeq[A] with LinearSeqOps[A, LazyList, LazyList[A]]

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/520017

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX