473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

java 5 could like python?

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.
Jul 18 '05 #1
9 1785
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.
Jul 18 '05 #2
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.
Jul 18 '05 #3

"vegetax" <ve******@gmail.com> schrieb im Newsbeitrag
news:ma**************************************@pyth on.org...
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

Jul 18 '05 #4
On Wed, 12 Jan 2005 11:18:17 -0500, Istvan Albert
<ia*****@mailblocks.com> 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
Jul 18 '05 #5
In article <ma**************************************@python.o rg>,
vegetax <ve******@gmail.com> wrote:
Jul 18 '05 #6
vegetax <ve******@gmail.com> 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.
Jul 18 '05 #7
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/
Jul 18 '05 #8
On Sat, 15 Jan 2005 15:08:05 GMT, cl****@lairds.us (Cameron Laird) wrote:
In article <ma**************************************@python.o rg>,
vegetax <ve******@gmail.com> 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
Jul 18 '05 #9
In article <41****************@news.oz.net>, Bengt Richter <bo**@oz.net> wrote:
Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: bezeee | last post by:
At my work we are in the process of building a tool to test an XML based API. Basically, XML in and XML out over http. Currently, there are two engines that do all of the schema validations, xml...
14
by: Wolfgang Keller | last post by:
Hello, as a non-developer I am currently participating in an industrial "research" project to develop a so-called "web application". This application serves at the same time as middleware to...
4
by: Luis P. Mendes | last post by:
Hi, I have a Python program that needs to interact with Java as follows: 1- A website supplied me java code that is able to perform some web services; 2- my Python program triggers some...
13
by: Ajay | last post by:
hi! can you call a Python application from a Java program? does this require any additional package to be installed? thanks cheers
9
by: F. GEIGER | last post by:
I've dev'ed a Python prototype of an app, that besides the internals making it up has a gui. While test-driven dev'ing the app's internals in Python is fun as usual, dev'ing the GUI is not so...
114
by: Maurice LING | last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic typing, is there any other real reasons that Python is slower than Java? maurice
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
25
by: redefined.horizons | last post by:
I've traditionally been a Java developer, although I play around with LISP. I recently migrated to Linux and I was exploring Mono as an option for development on Linux. However, I've had some...
29
by: s0suk3 | last post by:
Hello, I was hoping to get some opinions on a subject. I've been programming Python for almost two years now. Recently I learned Perl, but frankly I'm not very comfortable with it. Now I want to...
4
by: Quill_Patricia | last post by:
I have a Python script which is used to load data into a database. Up to now this script has been run by customers from the Windows command prompt using "python edg_loader.pyc". Any error messages...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.