最近Stack Overflow上有一群讨厌perl的人,所以我想我应该把我的“关于你最喜欢的语言你讨厌的五件事”的问题带到Stack Overflow上。拿你最喜欢的语言来说,告诉我你讨厌它的五件事。这些可能只是让你烦恼的事情,承认的设计缺陷,公认的性能问题,或任何其他类别。你只需要讨厌它,它必须是你最喜欢的语言。

不要拿它和其他语言比较,也不要谈论你已经讨厌的语言。不要用你最喜欢的语言谈论你喜欢的事情。我只是想听到你讨厌但能容忍的东西,这样你就可以使用所有其他的东西,我想听到你希望别人使用的语言。

每当有人试图把他们最喜欢的语言强加给我时,我就会问这个问题,有时是面试问题。如果有人找不出他最喜欢的工具的5个缺点,那他对它还不够了解,不能提倡它,也不能利用它赚大钱。他还没有在足够多的不同情况下使用它来充分探索它。他把它作为一种文化或宗教来倡导,这意味着如果我不选择他最喜欢的技术,我就错了。

我不在乎你用什么语言。不想使用特定的语言?那就不要。你通过尽职调查做出了明智的选择,但仍然没有使用它?好吧。有时正确的答案是“你有一个强大的编程团队,有良好的实践和丰富的Bar经验。改成Foo是愚蠢的。”


This is a good question for code reviews too. People who really know a codebase will have all sorts of suggestions for it, and those who don't know it so well have non-specific complaints. I ask things like "If you could start over on this project, what would you do differently?" In this fantasy land, users and programmers get to complain about anything and everything they don't like. "I want a better interface", "I want to separate the model from the view", "I'd use this module instead of this other one", "I'd rename this set of methods", or whatever they really don't like about the current situation. That's how I get a handle on how much a particular developer knows about the codebase. It's also a clue about how much of the programmer's ego is tied up in what he's telling me.

憎恨并不是衡量人们了解多少的唯一尺度,但我发现它是一个相当不错的尺度。他们讨厌的事情也让我知道他们对这个话题的思考有多好。


当前回答

Lua

If you do foo.bar(1,2) then 'self' is nil inside the bar method. You must remember to do foo:bar(1,2) instead. I'd rather have that switched ('self' should be defined by default unless you use the ':' operator, or you call a function that isn't a method). Variables are global by default. I'd rather ditch the 'local' keyword and have a 'global' one instead. Undeclared variables are assigned the nil. I'd rather receive an error message. You can sidestep this by manipulating the global env's metatable, but I'd rather have it implemented by default and be able to deactivate it. Multiple returned values on parameters are not handled very nicely. Say you have a function foo() that returns 1,2,3 (three values) and bar() returns 4,5 (two values). If you do print(foo(),bar()) you will get "1,4,5" ... only the "last" tuple is expanded on calls. The # (table length) operator only works in tables indexed with continuous integers. If your table isn't like that and you want to know how many elements does it have, you need to either parse it with a loop, or update a counter each time you insert/remove an element from it.

其他回答

Emacs Lisp

目前还没有足够的商业市场让人们全职用elisp编码 GNU Emacs vs XEmacs不兼容 Scheme中的嵌套函数很整洁,我希望elisp有[1]的概念 用于简单遍历列表的do循环或其他一些工具不是标准的(当然,您现在可以使用lambda进行映射)[1] (function (lambda(…)))[1]应该有一个简写

当然,Lisp的一个美妙之处在于,用一行代码在你自己的代码中修复这些问题并不难。但这并不是与生俱来的,这让我很恼火。

好的问题;我有点不好意思,因为我想不出更好的东西来恨,但说实话,法官大人,没什么好恨的。

C#

泛型参数是不变的,c# 4.0为泛型类型引入了协方差和逆变性 可覆盖的类成员必须显式地标记为virtual

Java

缺少无符号数字数据类型 基本数据类型不是对象

再给c++投一票…仍然是我最喜欢的语言,有几个亲密的追随者——C和Python。以下是我目前最讨厌的名单,排名不分先后:

Plethora of integer types inherited from C - way too many problems caused by signed vs. unsigned mistakes Copy constructors and assignment operators - why can't the compiler create one from the other automatically? Variable argument madness - va_list just doesn't work with objects and I'm so sick of problems created with sprintf(), snprintf(), vsnprintf(), and all of their relatives. Template implementation is required to be fully visible at compile time - I'm thinking of the lack of "export" implementations or at least usable ones Lack of support for properties - I want to have a read-only member like "a.x" that can be read publicly and only assigned internally. I really hate the "val=obj.getX()" and "obj.setX(val)". I really want properties with access control and a consistent syntax.

但这只是因为VB6毒害了整整一代程序员

我在一个曾经是VB6商店的VB . net商店工作,而在这里工作的每一个曾经是VB6开发人员的人都顽固地拒绝学习任何关于. net的知识。他们编写的代码就像VB6一样,他们的应用程序就像VB6应用程序一样糟糕。我的老板非常不鼓励使用LINQ,因为她担心其他人很难理解,这是事实,因为没有人想要理解它。

我认为如果微软只使用c#,我们会过得更好,这让我很难受,因为我认为花括号远不如VB的冗长结束语句。

Python:

我仍然是python的一般用户,所以我的抱怨可能只是知识的锁或误用。欢迎提出意见。我很喜欢这门语言。

Poor thread support and GIL. If you'd like to take use of multicore platform, most of the python programmers would probably recommend multiprocessing or some sort, don't use threading. It wouldn't give you the performance you are expecting. property only for instance variable. _class_var = property(classmethod(some_method)) just wouldn't work. How can I get a property wrapped class variable? no access control. All access controls are syntax mangling. Like private is __private, protect is _protected, etc... And hope that everyone programs python follows the naming convention. Come on, we can do better than that. I agree the python philosophy of being simple and clear syntax but some simple and clear syntax not being supported seems lock of good judgement, in my opinion. Such as, a++, ++a, a-- and --a, self-de/increment, what's wrong with those? foo = (a > b ? a : b) unary operation, what's wrong with those? (I know py2.6 has something similar introduced, but given the massive support of almost every other language for those simple syntax, why reinventing the wheel? why not just follow the best practice? Shouldn't a good thing just keep in its good "form"?) Program to interface. Python has no interface or abstract class concept (py3k has something called abc), everything is concrete. Providing an "interface" or "abstract" keyword to build class skeleton and guard class inheritance and extension wouldn't be a bad idea I think. It helps on top-down design. Currently, I just have to fill the each of methods with NotImplementedError, quite a tedious job. I have to add this. version less than 3.x has str and unicode types. This is a true nightmare. It makes ascii and non-ascii/unicode mixing most likely to fail (bad, bad)

我看到人们抱怨速度。我不明白。它是一种解释语言,代码直到运行时才编译成机器代码,这就是它的本质。你不能比较解释语言和编译语言的速度。据我所知,在解释/脚本语言中,python并不慢。