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

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


当前回答

Python

No statements in lambdas. GRRRR foo( a for b in c if d ) feels wrong, it surprises me every time I get away with it. Shouldin't it be foo( (a for b in c if d) )? Can i have a dict comprehension? map and filter operators have special syntax in list comprehensions, how about something for reduce? or sort? Just by having a yield statement in it, a function is magically transformed into a generator, and its interface changes completely. Also, that generator cannot do any work before the first next(). at least, not without using a function that returns a generator.

JavaScript

No brief syntax for making modular code libraries. You have to call a function that returns a dictionary of public methods. And you have to edit that in (at least) two places every time you alter the interface of your module. Creating closures involves returning it from a function that returns a function from ('sup dog) yo' function. Clutter! for each ( foo ) syntax and behavior feels like an afterthought. Knowing when your code will actually run (and in what order) is more of a dark-art. The only way to get it right for sure is put everything (yes, that too) in one big file. and even then you still need to wait for a document.onload Am i missing something? is there no trivial way to get json serialized values without building them by hand? (yes jQuery can do this, sort of).

其他回答

VB。网

The behavior AndAlso / OrElse and And / Or seems backwards. Perhaps they should be switched. When can only be used for exception catching. The ability to do a When conditional would be nice for some other things. There is no friggin Refactoring in the VS IDE (not really the language's fault) like there is with C# Not <obj> Is Nothing. Yes, this has been remedied by IsNot, but for some reason I see the Not Is being used too often. (I see it much more frequently with devs who speak english as a second language, does it make better sense from that angle?) It doesn't require the () on ToString() and most functions. (Leads to sloppy coding habits) Having to do _ when breaking a line. It allows optional parameters. (Leads to sloppy coding habits) declaring an array is done by UpperBound and not by capacity. "Dim arr(2) as String" will actually hold 3 elements. Having = be a comparison and assignment operator.

Python:

没有分隔符表示块的结束会导致歧义,这样自动缩进就不能处理格式不佳的代码。 没有宏(修饰符不算) 没有像haskell的cabal或perl的CPAN那样的库自动获取 不能声明变量const(是的,可以自己定义变量,但是…) 元编程被削弱 差点忘了全局解释器锁

Lua:

I understand the reasons, but seriously. Variables should be local by default, with a global keyword, not vice versa. I'm in general not a huge fan of the do/end style semantics. I much prefer C-style braces. Dynamic typing. I know, some of you go "Huh?" but I've been entirely spoiled by knowing exactly what type of data will be in a given variable. Constant if (type(var) == "string") then stuff() end is a pain. Variables need not be defined before they're used. I would much rather be explicit about what I'm trying to do than risk a typo causing what I like to call "wacky beans".

PHP:

同样,动态类型。 缺少闭包。你可以用$function($arg);但这不算。 同样,变量可以在定义之前使用。我有一个个人策略,总是在使用任何变量之前显式地将其初始化为已知值,并且我将其扩展到我可以控制的任何最佳实践文档。

C / C + +:

头疼=脖子疼。 不支持闭包。(我对c++ 0x很兴奋,因为c++ 0x有这些功能。) 静态类型。“等等,”你说。“你刚才说你不喜欢动态类型!”是的,我确实这么说过。但是静态类型也会让人头疼。(如果有选择的话,我仍然会选择静态类型。)最理想的情况是,我希望语言默认是静态类型的,但也支持动态类型。(我还想要一匹小马,500亿美元,还有整个世界。)

c#(好吧,我猜一部分是VisualStudio IDE):

No covariance (yet), like Class<D> cannot be used in place of Class<B> even though type D derives from type B. Graphic designers don't support generic based inheritance (or inheritance from abstract classes), even though the inheritance itself works just fine if you work around the designer problems by adding extra inheritance levels just so designers always see concrete non-generic variants of your code. No constructor inheritance No constructors in where clauses of generic type parameters VisualStudio seems to have a tendency to mysteriously check out files (like project files and/or unit test definitions) when opening a solution, even though the files do not seem to actually get altered.

如果你明天再问我,可能会有不同的名单。即使协方差和设计师的麻烦将在我的前5名,直到他们被解决(随着方差添加到c# 4.0,这似乎已经发生了至少一个…)

我是在冒险,因为我不能全职使用它,但无论如何我会尝试一下!

Perl 6

func("frew") != func ("frew") It annoys me, but there is good reason for it. In Perl 5 print (5 + 6) * 10 still gets me every now and then It may be easier to parse than Perl 5 in a lot of places, but it still kills my editor sometimes It still has a lot of the line noise Perl 5 which scares a lot of people. That means it's harder to get them excited etc. There are no libraries yet. This will be a non issue if Perl 6 does indeed end up supporting Perl 5, but that may be a burden not worth bearing. There's no REPL, or what rubyists would call irb. A solid interactive Perl 6 with tab completion, color coding, etc, would make using and learning it so much nicer. Currently the documentation is basically the English spec. Not exactly an easy read. I know it's a stupid cliche, but it's not out yet! (I am allowed to complain because I am helping :-P)

前三点是语言;剩下的并不是语言本身,而是它还没有问世的事实。