java 5 could like python?

Discussion in 'Python' started by vegetax, Jan 12, 2005.

  1. vegetax

    vegetax Guest

    I was a java developer one year ago ,before i moved to python i realy liked
    it at the beggining, but i got very disapointed lately since my
    previus two python proyects where relatively big,and python didnt feel
    well suited for the task.

    The reasons are mainly due to the standard library,the language
    performance was aceptable, but the library, in my opinion has several grave
    issues:

    -No naming convention. The speech of "it fits in my head" is no longer valid
    when i use a lot of functionality,modules,classes in a large proyect.

    For example if i remember a function i want ie:get attribute, i dont
    remember if the module implementer coded it as
    getAttribute,GetAttribute,get_attribute, then i have to go and check the
    doc, every time,which is a waste of time.

    -library Organization,we have modules that can have 20 classes(I imagine
    that is because of the commodity of having all in one file) which makes
    reading the doc horribly painfull and is very hard to find the stuff
    coupled with the "pool" of modules that is the python installation
    directory,all throwed away at the installation directory without a
    categorization.

    -Is python library half object oriented? half functional oriented? I can
    understand that python allows some functional programing components when
    they are necesary,but there are libraries that totaly ignore object
    orientation which makes them problematic to use.for example,Whats with the
    os.path module and files? why do i have to say os.path.getfilesize(f.name)
    all the time? why cant i say f.size? Why does urlparse returns a tuple of 7
    items instead of an URL object? why there isnt an URL object? and so on..

    I havent figured out a way to overcome those factors,the delaying and lost
    of focus that is having to check the docs all the time,every 5 seconds and
    having to make object oriented wrapers for several libraries or having to
    go and read the source code to know what the heck a function returns or
    what are its arguments makes coding unpleasant an very slow , i often have
    15 pydocs windows open at the same time. What should i do?

    -Realying on ides is imposible due to python dinamic nature,very litle(next
    to nothing) assistance can be espected from them.

    -Memorazing all the function names,parameters,return values,conventions of
    the modules i use doesnt look like a good solution.

    Join it with poor and outdated documention and we have a very unpleasant
    standard library.

    In the other hand, with the recent changes in java 5 i can pythonize
    java,And take advantage of a well designed library that coupled with the
    "apache commons" libraries has no match,not even .Net.

    for example with the static import feature i can say:

    import static mylib.Toolbox.print;
    import static mylib.Console.run;
    // or import static mylib.Toolbox.*;

    class C{
    public void func(){
    print("hello world"); // instead of System.out.println("hello world");
    print(run("ls /tmp"));
    }
    }

    Same for almost all python builtin functions.

    The new for statement :

    for (int i : mylist)
    print(i);

    I guess i could use a cleaver hack to also include the map,filter and other
    nice functional components python has.

    Also there is the generics support and so on..

    But for some reason i dont know,the switch back feels wrong =( ,would it be
    posible to imitate python's behavior with the new java features and some
    hacks? would be worth the effort? If not what can i do to use efficiently
    python modules and libraries? I recall, i didnt had this problem when doing
    small applications with a small set of modules.

    Sorry for my bad english.
    vegetax, Jan 12, 2005
    #1
    1. Advertising

  2. vegetax wrote:

    > previus two python proyects where relatively big,and python didnt feel
    > well suited for the task.


    One typical problem that others might talk about in more detail
    is that you might be writing java code in python. That means
    using Java style class hierarchies, methods and overall
    organization. That does not work well in python.

    > -No naming convention.


    That is result of open source model that evolved over a
    long time.

    > getAttribute,GetAttribute,get_attribute, then i have to go and check the
    > doc, every time,which is a waste of time.


    Create a simple wrapper that does exactly what you want. For
    example it would take just a few minutes to create a URL class
    that you wanted. Then you have to figure it out only once.

    > -Is python library half object oriented? half functional oriented?


    Yes. As should most solutions be.


    Istvan.
    Istvan Albert, Jan 12, 2005
    #2
    1. Advertising

  3. vegetax wrote :
    > I was a java developer one year ago ,before i moved to python i realy liked
    > it at the beggining, but i got very disapointed lately since my
    > previus two python proyects where relatively big,and python didnt feel
    > well suited for the task.
    >
    > The reasons are mainly due to the standard library,the language
    > performance was aceptable, but the library, in my opinion has several grave
    > issues:
    >
    > -No naming convention. The speech of "it fits in my head" is no longer valid
    > when i use a lot of functionality,modules,classes in a large proyect.
    >
    > For example if i remember a function i want ie:get attribute, i dont
    > remember if the module implementer coded it as
    > getAttribute,GetAttribute,get_attribute, then i have to go and check the
    > doc, every time,which is a waste of time.


    I believe this is a rather ill-suited example. People will react.

    >
    > -library Organization,we have modules that can have 20 classes(I imagine
    > that is because of the commodity of having all in one file)


    I challenge you to comparative statistics with Java.

    > which makes
    > reading the doc horribly painfull and is very hard to find the stuff
    > coupled with the "pool" of modules that is the python installation
    > directory,all throwed away at the installation directory without a
    > categorization.


    Well, for the soothing it can provide, I often feel nostalgic of the
    python documentation when I use javadoc.

    >
    > -Is python library half object oriented? half functional oriented? I can
    > understand that python allows some functional programing components when
    > they are necesary,but there are libraries that totaly ignore object
    > orientation which makes them problematic to use.for example,Whats with the
    > os.path module and files? why do i have to say os.path.getfilesize(f.name)
    > all the time? why cant i say f.size? Why does urlparse returns a tuple of 7
    > items instead of an URL object? why there isnt an URL object? and so on..
    >
    > I havent figured out a way to overcome those factors,the delaying and lost
    > of focus that is having to check the docs all the time,every 5 seconds and
    > having to make object oriented wrapers for several libraries or having to
    > go and read the source code to know what the heck a function returns or
    > what are its arguments makes coding unpleasant an very slow , i often have
    > 15 pydocs windows open at the same time. What should i do?


    First, you should believe the newsgroup when you get told that reading
    the source code "to know what the heck a function returns" is a not a
    need the python documentation leaves most pythoneers with.

    > -Realying on ides is imposible due to python dinamic nature,very litle(next
    > to nothing) assistance can be espected from them.
    >
    > -Memorazing all the function names,parameters,return values,conventions of
    > the modules i use doesnt look like a good solution.
    >
    > Join it with poor and outdated documention and we have a very unpleasant
    > standard library.


    You would be much closer to the mark, imho, by admitting that the main
    issue with "knowing a programming language" is knowing its standard
    library while feeling at home with the documentation thereof; *and* then
    admitting that changing languages generally implies the unpleasant
    experience of loosing touch with the content and style of one's beloved
    standard library and docs.

    >
    > In the other hand, with the recent changes in java 5 i can pythonize
    > java,And take advantage of a well designed library that coupled with the
    > "apache commons" libraries has no match,not even .Net.
    >
    > for example with the static import feature i can say:
    >
    > import static mylib.Toolbox.print;
    > import static mylib.Console.run;
    > // or import static mylib.Toolbox.*;
    >
    > class C{
    > public void func(){
    > print("hello world"); // instead of System.out.println("hello world");
    > print(run("ls /tmp"));
    > }
    > }


    Well you should provide the complete python equivalent, and I anticipate
    that you will be hard pressed to find someone on clp who will share your
    feeling that this java version is evidently better.

    Regards.
    more i squawed, Jan 12, 2005
    #3
  4. vegetax

    F. GEIGER Guest

    "vegetax" <> schrieb im Newsbeitrag
    news:...
    > I was a java developer one year ago ,before i moved to python i realy

    liked
    > it at the beggining, but i got very disapointed lately since my
    > previus two python proyects where relatively big,and python didnt feel
    > well suited for the task.
    >
    > The reasons are mainly due to the standard library,the language
    > performance was aceptable, but the library, in my opinion has several

    grave
    > issues:
    >
    > -No naming convention. The speech of "it fits in my head" is no longer

    valid
    > when i use a lot of functionality,modules,classes in a large proyect.
    >
    > For example if i remember a function i want ie:get attribute, i dont
    > remember if the module implementer coded it as
    > getAttribute,GetAttribute,get_attribute, then i have to go and check the
    > doc, every time,which is a waste of time.


    Too many getters indicate bad design. But, ok, that's not the point here.
    I ask myself all the time, how people can dev software in *any* language w/o
    an IDE offering Intellisense (besides a decent clas browser, of course). You
    simply type "myObj.get" and the IDE looks the proper names up for you. Then
    you choose the right one and you are done with. WingIDE is such an IDE, and
    Kommodo too, I think.

    HTH
    Franz GEIGER
    F. GEIGER, Jan 13, 2005
    #4
  5. vegetax

    Arthur Guest

    On Wed, 12 Jan 2005 11:18:17 -0500, Istvan Albert
    <> wrote:

    >vegetax wrote:
    >
    >> previus two python proyects where relatively big,and python didnt feel
    >> well suited for the task.

    >
    >One typical problem that others might talk about in more detail
    >is that you might be writing java code in python. That means
    >using Java style class hierarchies, methods and overall
    >organization. That does not work well in python.


    On the other hand in could be argued that the language seems to be
    evolving in a direction in which this is too possible - the
    distinctive "voice" of Python being muffled in static and class
    methods, type declarations and the like.

    Perhaps Python is forced in this direction as an appropriate admission
    of the advantages of the architecture encouraged by the Java/C# class
    of langauge. And is being courageous in these admission.

    Or perhpas it is an unfortunate result of trying to find acceptance
    and establish some compatibility in an atmosphere in which these
    language approaches dominate the current mainstream. And trying too
    hard to avoid a LISPish fate.

    Or else everything is just as it should be.

    I honestly don't pretend to know.

    But am a little confused about the lack of the discussion here about
    the developments in this direction.

    Art
    Arthur, Jan 13, 2005
    #5
  6. In article <>,
    vegetax <> wrote:
    .
    .
    .
    >For example if i remember a function i want ie:get attribute, i dont
    >remember if the module implementer coded it as
    >getAttribute,GetAttribute,get_attribute, then i have to go and check the
    >doc, every time,which is a waste of time.

    .
    .
    .
    Are you comfortable using the base interpreter's built-in
    interactive facilities, such as help()? I strongly urge
    you to exercise these for at least a few minutes.
    Cameron Laird, Jan 15, 2005
    #6
  7. vegetax

    Roy Smith Guest

    vegetax <> wrote:
    > -No naming convention. The speech of "it fits in my head" is no longer valid
    > when i use a lot of functionality,modules,classes in a large proyect.
    >
    > For example if i remember a function i want ie:get attribute, i dont
    > remember if the module implementer coded it as
    > getAttribute,GetAttribute,get_attribute, then i have to go and check the
    > doc, every time,which is a waste of time.


    It is indeed unfortunate that the standard library doesn't use a more
    consistent naming convention. Perhaps in Python-3000 this will get
    fixed. In the meantime, if I know what I'm looking for, but just can't
    remember the exact name, I usually find it's pretty quick to pop into an
    interactive session, create an object, and see what attributes it has
    with dir():

    >>> l = []
    >>> dir (l)

    ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__',
    '__delslice__', '__doc__', '__eq__', '__ge__', '__getattribute__',
    '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__',
    '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__',
    '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__',
    '__repr__', '__rmul__', '__setattr__', '__setitem__', '__setslice__',
    '__str__', 'append', 'count', 'extend', 'index', 'insert', 'pop',
    'remove', 'reverse', 'sort']

    > -Is python library half object oriented? half functional oriented? I can
    > understand that python allows some functional programing components when
    > they are necesary,but there are libraries that totaly ignore object
    > orientation which makes them problematic to use.for example,Whats with the
    > os.path module and files? why do i have to say os.path.getfilesize(f.name)
    > all the time? why cant i say f.size? Why does urlparse returns a tuple of 7
    > items instead of an URL object? why there isnt an URL object? and so on..


    Again, you are correct that things are not as consistent as they might
    be. The newer bits of the library tend to be more OO than the older
    bits, and those parts of the library which are thin wrappers around
    classic unix functions (like much of the os module) tend to be more
    procedural. Things are not perfect.

    I think the real message is that while you can certainly find lots of
    places where there are imperfections and inconsistencies, overall it's a
    very easy to use system. Java may be much more consistent, but I find I
    get bogged down in details like re-exporting exceptions, declaring (and
    casting) variable types. To each their own.
    Roy Smith, Jan 15, 2005
    #7
  8. vegetax

    Doug Holton Guest

    vegetax wrote:
    > In the other hand, with the recent changes in java 5 i can pythonize
    > java,


    Have you seen Jython? http://www.jython.org/
    It may be the best option for you. It will run just as fast as a
    regular java program. Also there is groovy: http://groovy.codehaus.org/
    Doug Holton, Jan 15, 2005
    #8
  9. On Sat, 15 Jan 2005 15:08:05 GMT, (Cameron Laird) wrote:

    >In article <>,
    >vegetax <> wrote:
    > .
    > .
    > .
    >>For example if i remember a function i want ie:get attribute, i dont
    >>remember if the module implementer coded it as
    >>getAttribute,GetAttribute,get_attribute, then i have to go and check the
    >>doc, every time,which is a waste of time.

    > .
    > .
    > .
    >Are you comfortable using the base interpreter's built-in
    >interactive facilities, such as help()? I strongly urge
    >you to exercise these for at least a few minutes.


    This triggers a thought: Some are more passive about exploring than others,
    and think there's nothing to be seen except what's pointed at. Sad for them,
    but they need help too. One hopes the tutorial stuff will reawaken natural
    pleasure in finding out neat stuff. After all, they came to the right place :)
    But back to my point (it's coming ;-) [1] ...

    >>> help

    Type help() for interactive help, or help(object) for help about object.

    Ok, will do ;-)

    >>> help(object)

    Help on class object in module __builtin__:

    class object
    | The most base type

    Taking the 'object' lesson a little too literally, perhaps ;-)

    >>> help(my_object)

    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    NameError: name 'my_object' is not defined

    Ok, why wasn't I told to expect that in the help() intro?
    Or that that the following might get me further info?

    >>> help('my_object')

    no Python documentation found for 'my_object'

    [1] Ok, here's the idea that triggered this post:

    What if help(something) didn't immediately give up with that last message?
    If instead it looked for helpex.py on the path, and invoked helpex(something) if found?
    That way, people could easily experiment with site-specific help extensions. ISTR a shell in the
    deep past sometime that would look for a custom extension before giving up with a parsing error,
    so I'm not inventing anything new (unless I misremember ;-)

    That's all. A simple hook could also do it, and site.py could hook it on if desired. E.g.,

    def helpex(*a,**kw):
    return "helpex doesn't exist yet, but it was called with %r and %r ;-)" %(a, kw)

    help.helpex = helpex

    You could get fancy and make that a property or properties of the base help,
    and have it chain multiple hookings at front or back for priority etc.
    Maybe we can invent a standard help extension methodology for temporary app stuff
    as as well as quasi-permanent site-specific stuff. ...
    just noodling variations on a theme ;-)

    For reference:

    >>> help()


    Welcome to Python 2.4! This is the online help utility.

    If this is your first time using Python, you should definitely check out
    the tutorial on the Internet at http://www.python.org/doc/tut/.

    Enter the name of any module, keyword, or topic to get help on writing
    Python programs and using Python modules. To quit this help utility and
    return to the interpreter, just type "quit".

    To get a list of available modules, keywords, or topics, type "modules",
    "keywords", or "topics". Each module also comes with a one-line summary
    of what it does; to list the modules whose summaries contain a given word
    such as "spam", type "modules spam".

    Regards,
    Bengt Richter
    Bengt Richter, Jan 15, 2005
    #9
  10. In article <>, Bengt Richter <> wrote:
    .
    .
    .
    >This triggers a thought: Some are more passive about exploring than others,
    >and think there's nothing to be seen except what's pointed at. Sad for them,
    >but they need help too. One hopes the tutorial stuff will reawaken natural
    >pleasure in finding out neat stuff. After all, they came to the right place :)
    >But back to my point (it's coming ;-) [1] ...

    .
    .
    .
    >What if help(something) didn't immediately give up with that last message?
    >If instead it looked for helpex.py on the path, and invoked
    >helpex(something) if found?
    >That way, people could easily experiment with site-specific help
    >extensions. ISTR a shell in the

    .
    .
    .
    I wonder if your proposal is better targeted at IPython
    (for example) than base Python.
    Cameron Laird, Jan 16, 2005
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stephen Horne
    Replies:
    37
    Views:
    880
    Stephen Horne
    Sep 13, 2003
  2. Patrick Kowalzick
    Replies:
    5
    Views:
    461
    Patrick Kowalzick
    Mar 14, 2006
  3. Alexander
    Replies:
    620
    Views:
    7,879
    Seebs
    Nov 9, 2010
  4. Alexander
    Replies:
    68
    Views:
    1,488
  5. Alexander
    Replies:
    60
    Views:
    1,378
    Thomas G. Marshall
    Nov 4, 2010
Loading...

Share This Page