java 5 could like python?

V

vegetax

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.
 
I

Istvan Albert

vegetax said:
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.
 
M

more i squawed

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.
 
F

F. GEIGER

vegetax said:
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
 
A

Arthur

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
 
C

Cameron Laird

.
.
.
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.
 
R

Roy Smith

vegetax said:
-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():
['__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.
 
B

Bengt Richter

.
.
.
.
.
.
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] ...
Type help() for interactive help, or help(object) for help about object.

Ok, will do ;-)
Help on class object in module __builtin__:

class object
| The most base type

Taking the 'object' lesson a little too literally, perhaps ;-)
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?
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:

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
 
C

Cameron Laird

.
.
.
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top