Will Python Be Good For This Type Of Project?

H

Hal Vaughan

I'm self taught and most of what I've been working on for the past several
years has been entirely in Perl and Java. I've noticed that I can code
about 5 times faster in Perl than Java, in part because I feel like
whenever I want to do something in Java, I have to create an object, do a
few preperatory things, then do what I need, but in Perl, I just call the
routine.

Java, however, does much better at cross platform apps, especially if I need
a GUI (I find Swing easy to use). I need to write a setting editor which
basically consists of a GUI with a lot of checkboxes, radio buttons, and
option select lists. I originally had something to do this in Javascript,
but Javascript was not strong enough to let me create data structures to
keep track of the data. I had to store it in 3d arrays, which was hard to
keep up with.

I was planning on writing the new setting editor in Java for several
reasons, including the ability to create my own objects to store groups of
settings. I also can write it so it'll run on a computer by itself, or as
an applet with very little extra work. That's a benefit, since it means it
can be run from anywhere through a Java enabled browser and a username and
password. It can also be run on a system where it's been installed without
using a browser (either way, it reads and writes the settings from a URL).

Someone on a mailing list I'm on has suggested that I look into Python, and
use Jython to compile it. I see that I can write applications and applets
in Python (but I haven't seen references to being able to write one
application just once and have it work as both). I also know Python is a
higher level than Java (a few people I know say it's almost like writing
pseudo code).

At this time I don't know Python (I've looked at some sample code and I'm
still getting used to loops and if statements without closing braces!).
What I'm trying to determine is 1) if it's relatively easy to write a
program to work as an application AND an applet (depending on how it's
called), 2) If it'll handle the networking to read what amounts to web
pages full of setting info and write that back in POST statements without
problems from the user's point of view and easily from the programmer's
point of view, 3) What coding time and difficulty is like in Python
compared to, most specifically, Java and Perl, 4) Is it easy for me to
interface Java and Python classes seamlessly, and 5) (I realize only I can
answer this for sure, but opinions and experience of others would be a
help!) Is Python easy enough and fast enough to code in that it'd be worth
me taking time to learn it and doing the project Python instead of Java?

Any help, thoughts, comments, and such are appreciated!

Thank you!

Hal
 
S

Steve Holden

Hal said:
I'm self taught and most of what I've been working on for the past several
years has been entirely in Perl and Java. I've noticed that I can code
about 5 times faster in Perl than Java, in part because I feel like
whenever I want to do something in Java, I have to create an object, do a
few preperatory things, then do what I need, but in Perl, I just call the
routine.

Java, however, does much better at cross platform apps, especially if I need
a GUI (I find Swing easy to use). I need to write a setting editor which
basically consists of a GUI with a lot of checkboxes, radio buttons, and
option select lists. I originally had something to do this in Javascript,
but Javascript was not strong enough to let me create data structures to
keep track of the data. I had to store it in 3d arrays, which was hard to
keep up with.
If you find Swing interfaces easy to build ans use then Jython should be
a natural: you can do all the GUI stuff in Java and control it from
Jython, thereby neatly avoiding yet another potential "What's the best
GUI toolkit" [answer: same place as the world's best hamburger].
I was planning on writing the new setting editor in Java for several
reasons, including the ability to create my own objects to store groups of
settings. I also can write it so it'll run on a computer by itself, or as
an applet with very little extra work. That's a benefit, since it means it
can be run from anywhere through a Java enabled browser and a username and
password. It can also be run on a system where it's been installed without
using a browser (either way, it reads and writes the settings from a URL).
Java does have the advantage when it comes to dynamic clients right now,
given that the Python virtual machine can't be assumed to be available
in the browser environment.
Someone on a mailing list I'm on has suggested that I look into Python, and
use Jython to compile it. I see that I can write applications and applets
in Python (but I haven't seen references to being able to write one
application just once and have it work as both). I also know Python is a
higher level than Java (a few people I know say it's almost like writing
pseudo code).
I have been known to provoke people by calling Java "object-oriented
COBOL", but if you're happy with Java you might find Python a bit terse,
and be a bit nervous about it's apparently happy-go-lucky attitude to
namespace protection.

If you like to be able to easily mix procedural and object-oriented
approaches then I think you might want to give Python a try.
At this time I don't know Python (I've looked at some sample code and I'm
still getting used to loops and if statements without closing braces!).
What I'm trying to determine is 1) if it's relatively easy to write a
program to work as an application AND an applet (depending on how it's
called), 2) If it'll handle the networking to read what amounts to web
pages full of setting info and write that back in POST statements without
problems from the user's point of view and easily from the programmer's
point of view, 3) What coding time and difficulty is like in Python
compared to, most specifically, Java and Perl, 4) Is it easy for me to
interface Java and Python classes seamlessly, and 5) (I realize only I can
answer this for sure, but opinions and experience of others would be a
help!) Is Python easy enough and fast enough to code in that it'd be worth
me taking time to learn it and doing the project Python instead of Java?
1) You'll need advice about "applet" from someone more versed in Jython
than I.

2) Definitely no problems in the networking department

3) Not as terse as Perl, somewhat faster than Java would be my opinion,
but I'm only one data point. I found the verbiage of common Java idioms
irritating, there's nothing like that with Python.

4) Yes.

5) You should learn a new language now and then just to stay in practice
and get in touch with newer ideas. Python isn't that hard for a Java
programmer to learn, though naturally there are differences. The two
languages in combination should give everyone what they want (though of
course there are always some people who just want to complain about he
way things are).
Any help, thoughts, comments, and such are appreciated!

Thank you!

Hal

Some of each to get you going. I hope this has helped.

regards
Steve
 
?

=?ISO-8859-1?Q?Jean-Fran=E7ois_Doyon?=

What I'm trying to determine is 1) if it's relatively easy to write a
program to work as an application AND an applet (depending on how it's
called)

No. There is no such thing as "Python applets", unless the end user's
browser has third-party plug-ins that enable browsers to do so (A Python
equivalent to the Java Plug-In) ... I think those exist anyways :)

Or, if possible you could make your applet include Jython, and write
everything in Python, and have the client's JRE run the whole thing.
Seems like a big detour if you're already proficient in Java to be
honest. Not to mention a big download, and potential security problems?
2) If it'll handle the networking to read what amounts to web
pages full of setting info and write that back in POST statements without
problems from the user's point of view and easily from the programmer's
point of view

Not a problem, Python can do all that quite easily. Look here:

http://python.org/doc/2.4.2/lib/internet.html
3) What coding time and difficulty is like in Python
compared to, most specifically, Java and Perl,

Well, presumably you'd have a learning curve ... Ignoring that coding
time in Python is pretty much always fastest (I used to love Perl ...
until I found Python). One of my big points when promoting Python is
exectly this: less time coding, less time debugging, more time making
good code that works right the first time, and importantly, much easier
to maintain over time.
4) Is it easy for me to
interface Java and Python classes seamlessly,

I've never used it, but Jython supposedly gives you the ability to do
this quite well. It's a Python interpreter written in Java :)

http://www.jython.org/
and 5) (I realize only I can
answer this for sure, but opinions and experience of others would be a
help!) Is Python easy enough and fast enough to code in that it'd be worth
me taking time to learn it and doing the project Python instead of Java?

For this one project, it's hard to say. Overall I would say that
learning a whole language for writing one GUI app might be excessive. I
would suggest you look over Python as thoroughly as you can, and see if
maybe it's a language you would want to use not only for this project,
but others in the future as well.

Being self-taught myself, I expect you will switch to Python :) Only
masochists or hardcore purists that think statically typed languages are
"better" stick to Java. Well or because it's mandated by their
organisations and so on ...

Do note that in this case you would also need a GUI framework ...
wxPython would be my reocmmendation:

http://www.wxpython.org/

(This is another reason the whole "applet" thing might be problematic).

Python does not have a single GUI framework, but many. The Standard
Library support Tcl/Tk, which isn't very nice. wxPython is very nice
API, and well supported. There are bindings to GTK and QT as well.

Hope this helps!

J.F.
 

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

Forum statistics

Threads
473,981
Messages
2,570,187
Members
46,730
Latest member
AudryNolan

Latest Threads

Top