News for hackers. Stuff that matters.
Re:A core Python committer's (very shallow) thoughts on Dart by masklinn on Monday May 14, 2012 @04:29AM (#3970033)
> Maybe it's my Java background coming through, but I like the idea of Factory constructors.

Better languages don't special-case the constructor instead (no `new` operator), the constructor is just a class method. Bam, "factory method" constructors out of the box and problem solved.

Re:A core Python committer's (very shallow) thoughts on Dart by nl on Monday May 14, 2012 @11:10AM (#3971364)
Better is pretty subjective here.

Factories aren't common in Python, but they are used in exactly the same cases where they are used in Java (eg [1],[2],[3]). If you need to decide at runtime what object from an object hierarchy to create you use a factory. There's nothing inherently bad about that.

[1] http://www.linuxtopia.org/online_books/programming_books/pyt...

[2] http://stackoverflow.com/questions/8129018/factory-method-in...

[3] http://eikke.com/python-factory-like-type-instances/ (though I prefer the version in the comments here)

Re:A core Python committer's (very shallow) thoughts on Dart by masklinn on Monday May 14, 2012 @01:23PM (#3972052)
> Factories aren't common in Python

Factories are everywhere in Python because the default construction workflow goes through a bloody factory method.

> There's nothing inherently bad about that.

You may want to read my comment instead of inventing things I never wrote, because the comment you replied to didn't even remotely hint at factories being bad.

Oh, and the first two examples you provide are absolutely horrendous, it's not surprising they are used "in exactly the same cases where they are used in Java", because what you show there really is java code translated to Python.

Whereas the third one is something you can't do in Java: it factorizes the creation of a class through customization of the metaclass's standard creation protocol. The version in the comments overrides the creation of the instance (through, again, a completely standard override of Python's built in construction protocol), which is less efficient but doesn't require understanding metaobjects.

Re:A core Python committer's (very shallow) thoughts on Dart by MartinMond on Monday May 14, 2012 @07:56AM (#3970580)
cough Ruby cough

Does Python do that too?

Re:A core Python committer's (very shallow) thoughts on Dart by masklinn on Monday May 14, 2012 @08:09AM (#3970639)
It does.