News for hackers. Stuff that matters.
Re:Write More Classes by loup-vaillant on Tuesday February 12, 2013 @09:16AM (#5206858)
The question is, what classes do that module systems don't? The answer is generally inheritance, and through it, class polymorphism.

With first class function, you hardly need class polymorphism. Just pass the function as argument already, don't bother with writing a whole new class just to override one method.

The other use for inheritance is plain code reuse. This is bad most of the time because it promotes thick interfaces, and function calls are great at code reuse anyway.

Re:Write More Classes by nessus42 on Tuesday February 12, 2013 @12:41PM (#5208199)
> With first class function, you hardly need class polymorphism. Just pass the function as argument already, don't bother with writing a whole new class just to override one method.

Here, here! After returning to functional programming after a 30 year hiatus, I am beginning to realize just how detrimental the OO orthodoxy has been, and just how impoverished the world has been without first class functions. If only Scheme had caught on in the mainstream when it was invented, the programming world would be a much happier and safer place.

Re:Write More Classes by lutusp on Tuesday February 12, 2013 @12:48PM (#5208250)
> Here, here!

Where, where? ITYM "Hear! Hear!"

http://en.wikipedia.org/wiki/Hear,_hear

"Hear, hear is an expression used as a short, repeated form of hear him, hear him. It represents a listener's agreement with the point being made by a speaker."

Re:Write More Classes by nessus42 on Tuesday February 12, 2013 @01:13PM (#5208426)
Yes, I know, but it's not nice to mess with the lysdexics.
Re:Write More Classes by lutusp on Tuesday February 12, 2013 @01:35PM (#5208593)
:) I would have let it go, but a lot of young people read HN and I didn't want them to think the expression really was "Here! Here!" Once these things get started ...
Re:Write More Classes by CodeMage on Tuesday February 12, 2013 @09:29AM (#5206969)
The question is, what classes do that module systems don't?

Modules (at least in Python) are singletons.

Re:Write More Classes by loup-vaillant on Tuesday February 12, 2013 @10:18AM (#5207290)
Doesn't count. When you define a single data structure in a module, (along with functions to manipulate it) you can instantiate it just like you would a class.
Re:Write More Classes by CodeMage on Tuesday February 12, 2013 @03:19PM (#5209230)
Ugh. That's like saying that high-level programming languages "don't count" because you can do that stuff in assembler.
Re:Write More Classes by loup-vaillant on Tuesday February 12, 2013 @05:27PM (#5210028)
I'm not arguing Turing completeness here. I'm arguing trivial one to one mapping. Syntax sugar. Compare:

  struct foo {
    int   bar;
    float baz;
  };
  int   get_bar(foo);
  float get_baz(foo);
Which would emulate this:

  class foo {
  public:
    int   get_bar();
    float get_baz();
  private:
    int   bar;
    float baz;
  };
If you're interested, I wrote more about that here: http://loup-vaillant.fr/articles/classes-as-syntactic-sugar