aspose file tools*
The moose likes Jython/Python and the fly likes Think Python - the right tool ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Jython/Python
Bookmark "Think Python - the right tool ?" Watch "Think Python - the right tool ?" New topic
Author

Think Python - the right tool ?

paul nisset
Ranch Hand

Joined: May 13, 2009
Posts: 177
Hi Allen,
I was wondering if Python lent itself to certain types of tasks more than others ?
In terms of the right tool for the right job ,when would you use Python as opposed to another language like Java or PHP?
Thanks,
Paul
Allen Downey
Author
Greenhorn

Joined: Sep 07, 2012
Posts: 25

Hi Paul,

I don't know enough about PHP to give an intelligent answer for that particular choice.

But compared to Java I would say that the big advantage of Python is development time. And the biggest drawback is (the lack of) compile-time error-checking.

Allen

All of my books are available from http://greenteapress.com
paul nisset
Ranch Hand

Joined: May 13, 2009
Posts: 177
Thanks Allen.
Speed of development makes it definitely worth looking into.
Java can be a heavyweight solution .
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1846
    
  16

Anything you can do in PHP will be possible in Python, plus Python has loads of excellent high quality libraries. Python code is purely OO, and is far cleaner and more elegant than PHP, and thus more maintainable. Unless you have to integrate your code with an existing PHP system (a CMS for example), or you have a team of PHP developers who do not want to learn anything new, I cannot think of any reason to choose PHP over Python.


No more Blub for me, thank you, Vicar.
paul nisset
Ranch Hand

Joined: May 13, 2009
Posts: 177
chris webster wrote:Anything you can do in PHP will be possible in Python, plus Python has loads of excellent high quality libraries. Python code is purely OO, and is far cleaner and more elegant than PHP, and thus more maintainable.


Thanks for your input Chris.
I agree PHP can get messy depending on whose code you inherited. I've not been super impressed with it's object oriented features or some of it's MVC libraries .
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1846
    
  16

paul nisset wrote:I've not been super impressed with it's object oriented features ...

The problem is that PHP was not originally an OO langauge, so the OO features had to be grafted on over the years. Python is OO from the ground up, and it shows.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16233
    
  21

Allen Downey wrote:Hi Paul,

I don't know enough about PHP to give an intelligent answer for that particular choice.

But compared to Java I would say that the big advantage of Python is development time. And the biggest drawback is (the lack of) compile-time error-checking.

Allen


I have sad news, I'm afraid.

There's really no magic language that can create solid software faster.

I learned this a long time ago when I noticed that languages with strong front-end checking such as compile-time error detection require a lot of "up front" work, but paid for it by having fewer problems when the app was actually run. Conversely, the "code-and-go" languages shortened the coding time at the expense of a lot of runtime debugging. You can change what development phase you spend most of your time in, but for the same quality and security level, the overall time is mostly independent of the language choice. With the possible exception of the assembly languages, where the sheer number of lines of code come into play, since it takes roughly 10 lines of assembler to do the same thing as 1 line in a high-level language, depending on the processor and the task.

Scripting-style languages are all the rage right now because managers see screens coming online quicker, but that's because loosely-typed languages don't bog you down in getting the details right before they'll display anything at all. But after that, you either have to continue to spend time long after the product is "done" (which looks unproductive), or you end up with a buggy product.

I use both PHP and Python. PHP, for all its OO deficiencies - and its lack of good MVC capabilities is about the fastest way to hack out simple pages there is. Python is more general-purpose and harder to set up for web use, although if you're willing the invest the effort (remember what I said about "where you spend your time!"), then Django can make for a very nice compromise between the Quick/Dirty PHP and the more labor-intensive J2EE, when you don't need Java's security or scalability features or its compile-time error checking.


Customer surveys are for companies who didn't pay proper attention to begin with.
Richard Tookey
Ranch Hand

Joined: Aug 27, 2012
Posts: 1083
    
  10

Tim Holloway wrote:
I have sad news, I'm afraid.

There's really no magic language that can create solid software faster.


++
g Peshone
Ranch Hand

Joined: Oct 20, 2008
Posts: 44
You guys don’t seem to know much about languages! PHP, Java, C++, NET are OO oriented and toward WEB development.
Python has NOTHING to do with OO at all. Just because you put “class” in front of a function does not makes it OO!
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1846
    
  16

g Peshone wrote:You guys don’t seem to know much about languages! PHP, Java, C++, NET are OO oriented and toward WEB development.
Python has NOTHING to do with OO at all. Just because you put “class” in front of a function does not makes it OO!

Well, the General Python FAQ page on the Python 3 website says "Python is an interpreted, interactive, object-oriented programming language". Meanwhile, Wesley Chun (who wrote "Core Python" and certainly knows a lot more than I do about Python) describes it as "an object-oriented (OO) language, all the way down to its core". (Core Python, 2nd edition, p.7). You may have a different view, but I'm inclined to go along with the Python folks on this one.
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4462
    
    8

g Peshone wrote:Python has NOTHING to do with OO at all. Just because you put “class” in front of a function does not makes it OO!


So which of the fundamental properties of an object-oriented language (e.g. encapsulation, inheritance, polymorphism) do you think it lacks?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16233
    
  21

g Peshone wrote:Just because you put “class” in front of a function does not makes it OO!


Actually, I believe that both C++ AND PHP did exactly that. C++ was in fact, originally named "C with classes". When I created the product that was to become Lattice (SAS) C++ for the Amiga, I even exploited that feature.

PHP was very modular, but not in the least bit object-oriented when it was first created, and I've suffered the consequences.

Also, neither Java nor C++ were originally targeted towards web development. In fact, the web as we know it didn't exist in 1986, which was when I did my work.

I will, however, retain reservations about Python being OO all the way to its core. I've seen too much procedure-oriented python code.
g Peshone
Ranch Hand

Joined: Oct 20, 2008
Posts: 44
So far I’ve seen too many files in python miles long something that does not much commence to OO very well. Also, maybe it’s the lack of documentation but the import function does not budge much under windows. It is the PHP the most user friendly IDE that gets you going fast with the least learning curve.
True, in Python you can do:
>>> 2 + 2
4
That’s great!
I need to work with files and despite the Python docs it does not help much. (windows env.)
g Peshone
Ranch Hand

Joined: Oct 20, 2008
Posts: 44
Seriously, if python would be into OO it would have a documentation referring to it and providing the internal workings BUT it does not! And that's on Linux as well, not just on windows. NOWHERE it is documented how to use that preposterous “import”! I am talking about file to file interaction using type class. Despite the glory of whoever it just conflicts.
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1846
    
  16

g Peshone wrote:So far I've seen too many files in python miles long...

Do you mean modules containing multiple class definitions, which is just Python's way of organising things, and is perhaps a matter of taste (I'm not sure if long module files are intrinsically better/worse than folders containing hundreds of 10-line Java classes, for example)? Or do you mean long scripts of spaghetti-code, which can be achieved in any language and is the responsibility of the developer?
g Peshone wrote: the import function does not budge much under windows...

What does this mean, and where do you find Python's "preposterous" import is worse than Java's import, for example?
g Peshone wrote: It is the PHP the most user friendly IDE that gets you going fast with the least learning curve.

PHP is a language, not an IDE (Eclipse or Zend Studio are IDEs for example). PHP has its merits, especially for hacking out code that nobody else has to maintain. But I'd say it gets you started "quick and dirty", while Python gets you started "quick and clean", and part of that brief learning curve is learning how to do OO programming properly. But if you like PHP, that's great.
g Peshone wrote:I need to work with files and despite the Python docs it does not help much. (windows env.)

What do you need to do that you can't achieve with Python's massive range of file functionality?
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1846
    
  16

g Peshone,
Your post was moved to a new topic.
This is really a separate topic from the original discussion
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Think Python - the right tool ?