最近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.

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


当前回答

经过一些思考后重写了这篇文章…

虽然我喜欢PHP,但我讨厌它的五个方面(排名不分先后):

内置函数中的命名和参数顺序不一致。 面向对象的数组方法多亏了SPL,但遗憾的是还没有字符串。 PHP本身没有真正的并发,只有通过托管web服务器的多处理 没有像JavaScript那样的异步调用 只能通过扩展进行操作码缓存。不是很糟糕,只是有点烦人。

这些是令我烦恼的语言特性(或缺乏),但更大的问题是这些与人/社区相关的东西:

事实上,很多使用PHP的人,对编程和良好实践一无所知,从而产生了非常混乱的代码。JavaScript也有同样的问题。 大量的教程/书籍传授了非常糟糕的做法和风格。这可能是第三条的主要原因。 它的坏名声主要是因为第三条和第四条。

其他回答

我不敢相信,我最讨厌的Python竟然还没被提到:

(Prior to 3.x) Relative imports look like absolute imports. import foo Does this import foo from the directory you're standing in or from the sys.path? Zipped eggs, leading to a sys.path full of shite. Zipped eggs means you can't use grep and find (to among other things debug problem 1)! Fortunately, there's pip. Use pip. Some of the included batteries are unpythonic. It grates to use them. Might be the fault of distro's and packagers, but still: sourcefile-encoding set to fscking ASCII on install/compile. WTF? Means I have to put the "# coding: UTF-8"-stuff in every single .py I ever make.

Py3k解决了我的其他几个讨厌的问题,例如坚持字符串是unicode的,8位的东西是不同的……

C#

我对c#非常满意,但这两个真的让我很恼火:

Constructor-based initialization for immutable classes is less convenient, less intuitive (when you read the code you don't understand what you assign to what), has less IDE backing than inline object initialization. This makes you lean towards mutable classes inevitably. I know this has been mentioned before, but I strictly have problems with initialization syntax for immutable classes. switch is too verbose. Whenever I see a situation where a switch would be proper, I'm really inclined to use an if..else if.. just because it's more terse (~30% less typing). I think there should be no fallthrough for switch, break should be implied, and case should allow comma separated list of values.

SAS

从不有自己的想法(一切都是借来的)。 贪婪于庞大的数据集。 使用Java,但从未学习过什么是对象。 窃取Perl,但将其隐藏在其数据步骤中。 统计学家总是撒谎!

Erlang

没有静态推断 就像在哈斯凯尔发现的一样。这 会导致运行时错误和一个 有认真写代码还是使用 透析器(1)发现 差异。动态类型是 慢的:也被认为是慢的; 与C、Java等语言相比,它几乎是未知的; 的lists(3)模块有时相当精简 我缺少用于列表处理的有用函数 (就像在数据。例如Haskell中的List); 让我在每句话的结尾都加上 在从句中,和。最后是后者。

帕斯卡对象:

There's a lot of jumping back and forth in the file you're editing since the interface and implementation are split into two parts but still jammed into the same file. Dynamic indexing of arrays, strings start at 1, you specify the starting index when declaring fixed arrays and dynamically allocated arrays always start at 0. Classes and objects (not to speak of interfaces) are bolted on top of the language and among other things can't be stack allocated like records can. When calling functions without parameters the () are optional, leading to a lot of pain when you are dealing with function pointers or trying to refer to the result of a function using the function name. Parameter lists can't handle fixed array types or function pointer types without external type definitions.

这仅仅是一种语言,一个标准库的遗憾借口,而脆弱的IDE应该有自己的列表。