• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Murach's Python Programming: why not shell?

 
Ranch Hand
Posts: 572
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I was wondering why people use Python instead of shell scripting or other programming languages(for applications) and does your book discuss use cases?

thank you,
Paul
 
Author
Posts: 142
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul,

I don't know too much about shell scripting, but here are a few thoughts. From what I've read, shell scripting is better at some things and Python is better at others. In general, as scripts grow longer and begin to deal with complex data structures, they might start to become unwieldy and difficult to maintain. At that point, you might want to consider Python. Also, Python works with all operating systems. So, if you find yourself in a situation where you need to write scripts that work on Linux and/or Windows, you might want to use Python.

Joel
 
Joel Murach
Author
Posts: 142
13
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi again Paul,

As for the second part of your question, the same goes for developing applications. Python has its pros and its cons when compared to other languages.

Compared to Java, it's refreshing in that it's loosely typed, so it doesn't require declaring data types everywhere. Also, it doesn't have checked exceptions, so you don't need to handle exceptions unless they become a problem. Also, when working with classes, it's common to access fields directly instead of coding get and set methods. This saves a lot of coding that's typically not necessary. In general, this is all due to Python's philosophy, which is different than Java's philosophy. And this leads to Python being able to provide more functionality with less code. This doesn't make Python better than Java, but it does make it nice for certain situations.

Thanks!

Joel
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joel Murach wrote:Also, when working with classes, it's common to access fields directly instead of coding get and set methods. This saves a lot of coding that's typically not necessary.


To be fair, this is entirely possible with Java as well. It's simply a convention that fields are declared private and accessed through getters and setters.
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joel Murach wrote:. . . loosely typed, so it doesn't require declaring data types everywhere. . . . .

Does that increase the risk of a type error at runtime?
 
Joel Murach
Author
Posts: 142
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:

Joel Murach wrote:Also, when working with classes, it's common to access fields directly instead of coding get and set methods. This saves a lot of coding that's typically not necessary.


To be fair, this is entirely possible with Java as well. It's simply a convention that fields are declared private and accessed through getters and setters.



Yes, that's true. It's a simply a convention in Java, but it's pretty deeply ingrained into the Java culture, and it's necessary if you want to work with JavaBeans. In Python, it isn't a convention. It's the standard way of coding classes. Then, if you need to encapsulate the fields later, you can use properties (not methods) to do that.
 
Joel Murach
Author
Posts: 142
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:

Joel Murach wrote:. . . loosely typed, so it doesn't require declaring data types everywhere. . . . .

Does that increase the risk of a type error at runtime?



Yes, it does. But, these errors are usually easy to fix when you're testing your application. And there are several benefits to not declaring data types. The most obvious one is that it makes your code a lot more concise.
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you
 
He loves you so much! And I'm baking the cake! I'm going to put this tiny ad in the cake:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic