Hacker News new | comments | show | ask | jobs | submit login
Python isn't just Java without the compile (bitworking.org)
12 points by rams on July 15, 2008 | hide | past | web | favorite | 5 comments

"In some ways it makes the problem easier when you can assume the user is a good programmer. Language designers often find themselves worrying about the mess users might make if they were allowed to do such-and-such. Once you assume the user is a good programmer, you automatically have the answer to any such question: let the user do whatever he wants."

- pg

"About 12 years ago, Python aquired lambda, reduce(), filter() and map(), courtesy of (I believe) a Lisp hacker who missed them and submitted working patches. But, despite of the PR value, I think these features should be cut from Python 3000."

- gvr

Remember: Python's not broken, you are.

The example given in the articles entirely fails to describe functions as being first-class citizens. Python also lacks full continuations, unless the article is referring to Stackless Python. What is described in the article as continuations are actually generators. Finally, the meta-programming described in the article, while valid, really only scratches the surface of what's possible with meta classes in Python.

This article is a poorly done "look how smart I am". First, the title makes little sense. If you were going to compare and contrast Python to Java, this first thing to come to mind would be static typing, not a compile step. Second, I was going to complain about the first-class functions as well. By his example, PHP has first class functions as well because you can define a function out side of a class. But we all know PHP does not, in fact, have first class functions because you cannot pass a function as an argument or return a function as a value from another function in PHP. I think you can get the point across better with this example...

def fun_factory(scale):

    def inner_func(arg1,arg2):

        return scale * ( arg1 + arg2)

    return inner_func
class myclass(object):

    def __init__(self,scale_func):

        self.better_example = scale_func
if __name__ == "__main__":

    print fun_factory(10)(5,5)

    myinst = myclass(fun_factory(10))

    print myinst.better_example(5,5)

Try that in Java:

class NullReceiver(object):

    class SimpleCallable(object):

        def __call__(self, *args):

    def __getattr__(self, name):

        print 'unhandled method "%s" called' % name

        return nullReceiver.SimpleCallable()

Or that (this one is in Ruby):

s = 'a'

class String

  def rghize

    return self + 'rgh'


puts s.rghize

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact