最近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 standard GUI toolkit (the community goes round and round about this but never seems to settle on anything). The evolution of tools and methods to distribute and install Python apps and libraries has been, well, rocky. (Although lately this seems to be moving closer to getting fixed.) CPython is still slow as interpreters go (although PyPy is looking pretty good these days, if it becomes the "standard" Python this problem goes away). You can't subclass built-in classes (e.g., list and dict) without overriding a lot of methods, even if all you want to do is a simple hook into an event (e.g., to hook into an item being added to or removed from the list, you need to override delitem, append, extend, insert, pop, and remove--there's no subclassable "change" event notification, nor any "protected" methods that factor out common code used by all the above methods). Up until virtualenv was invented, keeping separate Python environments for different purposes on one machine was a real pain.

其他回答

不得不假设我们有语言。我们做什么?

按最讨厌到最不讨厌的顺序排列。

1.) Backwards compatibility police. Yes backcompat is a strength but Perl 5 takes it too far. Now we don't really even get new features in our language without having to enable them explicitly. I'm much prefer the inverse, if a new feature causes a problem let me disable it or enforce old behavior. e.g. perl 5.10 added say I'd rather have no feature 'say' if I have my own say implemented than have to put use feature 'say'; or use 5.010; also if 5.8 worked but 5.10 didn't. I'd rather have use 5.008; to restrict my code to only use features available up to and including 5.8 if no use version; was defined then it should be defaulted to whatever version you're running, and a recommended practice of not to restrict it unless you have to.

2)。过度的样板。

#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use autodie;
use English '-no_match_vars';
use 5.010;
package Package::Name;

BEGIN {
    Package::Name::VERSION = 0.1;
}

sub somesub {
    my $self = shift;
    my ( $param1, $param2 ) = @_;
}
1;

现在你可以开始编码了。这不会因为第一条而改变。当然也有一些捷径,比如使用common::sense;或者使用modern::perl;这将缩短上面的内容,你可能需要一些稍微不同的模块或pragma。但因为第一条,我们永远无法把它降低到。

#!/usr/bin/perl
package Package::Name 0.01;

sub somesub ( $param1, $param2 ) {
}

一些模块正在帮助这一点,在5.0.12中有新的包版本,它完全允许这种语法,尽管我认为它需要使用5.012;首先,和Method::签名,但它永远不会完全解决,(在语言)。

3)。糟糕的变量选择

吸吸文件

#!/usr/bin/perl
use strict;
use warnings;
open my $fh, "< foo" or die $!;
local $/; # enable localized slurp mode
my $content = <$fh>;
close $fh;

WTF是$!和美元/ ?重写为易读。

#!/usr/bin/perl
use strict;
use warnings;
use English '-no_match_vars';
open my $fh, "< foo" or die $ERRNO;
local $INPUT_RECORD_SEPARATOR; # enable localized slurp mode
my $content = <$fh>;
close $fh;

不要忘记,如果您不想受到性能影响,'-no_match_vars'必须存在。

不直接创建匿名标量怎么样?

#!/usr/bin/perl
my $scalar_ref = \do{ my $anon_scalar };

他们就不能想出点什么办法吗?

#!/usr/bin/perl
my $scalar_ref = <>;

哦,perl是线程不友好的,因为所有的变量(包括特殊的变量)默认是全局的。至少现在你可以使用我的$_;对其词法作用域,并对其他词使用local。

4.)非常难看的语法

MooseX::Declare是一个更好的语法。我也希望->被替换为。(个人喜好不太重要)

5)。太多的TIMTOWTDI或太多的最佳实践似乎你必须读3-5本书才能弄清楚你应该如何做事情。

6)。以前的(不再适用)。Un-sane版本。5.10.0有新功能5.10.1的新功能没有设定时间,直到下一个版本。现在是每年一次的特性发布,每季度更新一次。

7)。象牙塔视角。社区问题,似乎是许多开发者想要设置更高的准入门槛,并认为可以不尊重n00b(或任何不同意他们的人)。

8)。疯狂的版本号/字符串Perl有浮点版本号,它们很难看。开发人员不知道并不是所有的下游处理版本比较的方式都是一样的。不是语言问题

0.012 # simple
5.012001 # semantic 
4.101900 # time based + version (for multiple versions in a day)
0.035_002 # prerelease

所有有效版本的perl..我们就不能用…

0.12 # simple
5.12.1 # semantic
20100713 # time based (just use the date and be careful not to need to release more than 1 a day)
0.35-beta2 # prerelease

除了

9)。升级后没有明显的方法重新安装所有XS模块

我对特尔斐的5分:

Procedures and functions aren't necessarily distinguished from variables if not parameterized (eg, I can have statement such as x := GetPositionOnScreen; instead of x := GetPositionOnScreen();) Try/Finally and Try/Except needs to be nested (stated once before, but it's still one of mine as well). Not case sensitive. Can have a multiple objects (functions, global variables, local variables) named the same and Delphi will happily try to figure out what you mean. names should be unique. Odd if condition rules. a single conditional check doesn't require a () around it, but if I do multiple checks, I need a () around each one, and sometimes multiple nested sets for bigger checks. No inherited includes. If I need to reference functionality from the Windows unit in a base and an inherited form, I have to include Windows in both.

第一个帖子,所以对我放松点:)…很棒的社区网站,顺便说一句!

我试着阅读其他所有的c#回复,这样我的回复就不会重叠了

c#……排名不分先后:

1) switch语句中的case没有fallthrough。如果没有转机……为什么必须显式的类型中断;呢?这只是弱智和令人困惑,因为它意味着没有休息的能力;!!

2)不能在子作用域中声明同名变量,但可以声明与类变量同名的变量?要么都允许,要么都不允许。否则,就没有意义了。

3)函数中没有可选/默认参数

4) finally{}中的异常应该隐式地捕捉每一行。或者至少,只有NullReferenceException异常。例如,在访问数据库后,应该总是清理。所以,finally块应该看起来像这样:

finally
{
  if(par1 != null)
    par1.Dispose();
  if(comm != null)
    comm.Dispose();
  if(conn != null)
    conn.Dispose();
}

如果可以写成这样,就会简洁得多:

finally
{
    par1.Dispose();
    comm.Dispose();
    conn.Dispose();
}

但是,不……你必须检查你是否正在访问一个空对象,否则它可能会从finally块抛出一个NullReferenceException。谁真的需要finally块中的异常呢?

5)泛型:你可以指定new()来实例化你的泛型对象,但是这个对象需要有一个默认构造函数。为什么不能指定一个签名,这样就不需要在还没有空构造函数的情况下创建空构造函数,而只使用已有的构造函数。

Lua:

元表是如此令人困惑,直到他们“点击” 缺少像a += 20这样的赋值操作符是一种痛苦 没有集成的面向对象的解决方案意味着每个人和他的狗都使用自己的口味 用于注释(——)的语法排除了加/减前后操作符的可能性 不入侵C端就不可能有任何先发制人的多任务系统