Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

What language? is python good?

  1. Jan 8, 2007 #1
    Im in my last year of high school and for about two years now ive wanted to learn to program, but i havnt really gotten into it.

    Basically I am going to study electrical engineering in a bit over a year (military service comes first) and I would like to learn a language that is useful for that purpose.

    I dont want it to be limited to programing robots or circuits though. I want to be able to use it to make for example: applications that interact with websites, like getting prices off ebay or something.

    What is a good language for this. Ive heared that Python is a good all around language. Then again ive heared others recommend delphi because apparently its more hardware interactive than other languages. What do you guys think?
     
  2. jcsd
  3. Jan 8, 2007 #2

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Python is an excellent general-purpose programming language, and it even does a very good job of some specialized tasks like scientific computing.

    If this is your first programming language, Python is an excellent choice. You will be essentially forced to learn C at some point in your career though, simply because it is so ubiquitous.

    - Warren
     
  4. Jan 9, 2007 #3
    thanx a lot. Can you recommend any book? or should i start out with the tutorials on the python website, then byte of python, then dive into python?
     
  5. Jan 9, 2007 #4
    Start with a hello world tutorial like this: http://www.penzilla.net/tutorials/python/intro/ and build your way up.

    Once you are fairly comfortable with python try some other languages out and get a feel for them and why they are different etc... you might not want to stick to python, I know a lot of people dislike its special treatment of white-space, and other non-standard programming language features. At the same time though others don't care.
     
  6. Jan 9, 2007 #5
    Check out the official Python website:
    http://www.python.org/about/gettingstarted/

    Also, beginner's guides at:
    http://wiki.python.org/moin/BeginnersGuide/Programmers

    Python was designed as a language to teach programming. It is wonderfully consistent. It has very little "it works like this except on Tuesday" for such a powerful language. C++ is a nghtmare in this regard.

    Since you mention it, there is a site called "Dive into Python", but it's really for more experienced programmers http://diveintopython.org/
     
  7. Jan 9, 2007 #6
    As far as I know, Java is the most widly spread and popular language in the world having more active developers than any other language (and jobs aswell)

    http://www.tiobe.com/tpci.htm

    it is also the language of choice for teaching programming at numerous universities across the globe.

    I have had 2 programming lessons at my university both of them consisted of Java and the second one of C aswell.

    If I got to learn programming by myself, I would start with C, just to get the basic of procedural programming (loops, if statements,etc) compilation and then when it would be time for pointers I would switch to Java and learn OOP(Object Oriented Pradigm - the most popular paradigm and IMHO the most useful).
     
  8. Jan 9, 2007 #7
    Thanx, im trying those tutorials, im on the second page though and my IDLE isnt giving me the response it should:

    Code (Text):
    >>> inta = 100
    >>> fact = [COLOR="DarkOrange"]def [/COLOR]factorial (n):
       
    SyntaxError: invalid syntax
    PS: the the orange def is supposed to be highlighted not coloured

    Im prety sure im typing everything thats on the website in the yellow box:

    http://www.penzilla.net/tutorials/python/datatypes/
     
  9. Jan 9, 2007 #8

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    foges,

    That tutorial is bad! It definitely contains code that will not run in modern Python interpreters.

    You can change the code to this:

    Code (Text):
    inta = 100
    def factorial (n):
        if n == 0:
            return 1
        else:
            return n * factorial(n-1)

    fact = factorial
    intb = fact(100) # 100! is pretty damned big, notice python doesn't choke.
    There's no real reason at all to use the 'fact' identifier to mean the factorial function, though. Why not just do it this way?

    Code (Text):

    inta = 100
    def factorial (n):
        if n == 0:
            return 1
        else:
            return n * factorial(n-1)

    intb = factorial (100) # 100! is pretty damned big, notice python doesn't choke.
    - Warren
     
  10. Jan 9, 2007 #9

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    I can guarantee you that this will not be true indefinitely. Java has already crested its peak popularity, and will eventually decline into obscurity (where it belongs).

    - Warren
     
  11. Jan 9, 2007 #10
    I am curious as to why you have made this comment. Can you be more specific?
     
  12. Jan 9, 2007 #11

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    From the same data source given by haki:

    http://www.tiobe.com/tpci.htm

    You can see for yourself the trend that Java's popularity is declining. This is important to me, because Java is, in my opinion, a bloated, extremely verbose, unnecessarily rigid and syntactically painful language. The only advantage it has is that it has a very large standard library, though the libraries available for other languages like Python are really almost as complete.

    - Warren
     
  13. Jan 9, 2007 #12
    I myself have never used Python. I'm sure I'm going to draw ire of many stating my preference is C# at this time. I have used Java (JSP & Beans) to some extent but have had little exposure to their Server Faces. I was just curious as to whether Python had the same control extensability as Java and C#. I'm not nearly the purist I use to be and find myself doing more customizing than building core web logic (state management for example) as I use to. I am interested in your take because as you have stated the buzz around Java has for the most part has faded.
     
  14. Jan 9, 2007 #13

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    I don't exactly know what you mean by "control extensibility," but I have never found anything that I can do in Java or its cousin C# (or even distant languages like Perl and shell scripts!) that I could not do more easily in Python. Your mileage may vary, but I believe Python is the coolest language on the planet at the moment. Sure, some people think it's a bit weird that the tab character is a meaningful component of the language's syntax, but, once you get over the bias and begin using the language, you quickly realize just how nice it is after all.

    - Warren
     
  15. Jan 9, 2007 #14
    I'm no cheerleader for any language. I am curious to how Python works when implimenting web logic such as state maintainance. How hard is it to do a simple select from a DB and render a table or XML to the browser. I'm looking at it from a standpoint of how hard is it to port existing code from another language to Python.
     
  16. Jan 9, 2007 #15

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    I'm sure it's as competent as any other language. It has DB modules, CGI modules, and XML modules included in the default install. I'm not a web programmer, though, so I can't give you specific examples. Google "python cgi" for all the examples you could ever want.

    - Warren
     
  17. Jan 9, 2007 #16
    I believe I have hijacked this thread long enough. Chroot, I appreciate you take. I have played around with Linux as a web platform and have used Apache w/ Tomcat for JSP and servelets. I knew you had done some work on this forum so I was just curious as to your opinion. Thanks for your replies.
     
  18. Jan 10, 2007 #17
    That is ofcorse your opinion in mine you shouldn't have commented on something you do not understand. I haven't programmed in Python soo I will not comment on it, if you haven't done any serious work in Java please do the same.
     
  19. Jan 10, 2007 #18
    If you put your mind to it, or choose a sufficiently difficult problem with sufficiently stringent constraints you are essentially forced to use C++ or assembler or to invent a similarly tight language. For instance a while ago myself and a small group of devs I was working with were looking for a scripting language to incorporate into a interactive 3d renderer. Python was not sufficient (at that time anyway, I understand that there are now quite a few compilers which generate code in memory from Python, where as at the time all we could find was the slow and clunky interpreter), although in its favour no major script on the market was sufficient for our needs either, also Python was far and away the best script we toyed with.
     
    Last edited: Jan 10, 2007
  20. Jan 10, 2007 #19

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Well, let's see here, haki...

    I began programming in Java in 1996, and taught classes on the language to high-school seniors in 1997. I have written literally dozens of major applications in the language, including this one that I wrote for National Semiconductor in 2002. This program included some 200 classes, for a total of some 50,000 lines of Java. It did everything from communicating with hardware via USB, to mathematical analyses on data, to image processing -- and, of course, had a quite nice user interface.

    Here's a screenshot of it:

    [​IMG]

    It's still available from National Semiconductor:

    http://www.national.com/appinfo/adc/wv4.html

    I know Python literally as well as I know Java. I have written enterprise-wide applications that allow our design engineers to analyze analog waveforms from simulations, store them in databases, and perform regression analyses with a number of different waveform viewers. If you don't believe me, I'd be happy to take some screenshots of it.

    Now, what was that you said about me commenting about something that I "don't understand?"

    - Warren
     
  21. Jan 10, 2007 #20
    ooooo ... pwnt.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?