# Python What language? is python good?

#### foges

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?

Related Programming and Computer Science News on Phys.org

#### chroot

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

#### foges

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?

#### Jheriko

Start with a hello world tutorial like this: http://www.penzilla.net/tutorials/python/intro/ [Broken] 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.

Last edited by a moderator:

#### nmtim

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?
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/

Last edited by a moderator:

#### haki

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).

#### foges

Start with a hello world tutorial like this: http://www.penzilla.net/tutorials/python/intro/ [Broken] 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.
Thanx, im trying those tutorials, im on the second page though and my IDLE isnt giving me the response it should:

Code:
>>> 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/ [Broken]

Last edited by a moderator:

#### chroot

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:
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:
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

#### chroot

Staff Emeritus
Science Advisor
Gold Member
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)
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

#### Ronnin

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
I am curious as to why you have made this comment. Can you be more specific?

#### chroot

Staff Emeritus
Science Advisor
Gold Member
I am curious as to why you have made this comment. Can you be more specific?
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

#### Ronnin

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.

#### chroot

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

#### Ronnin

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.

#### chroot

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

#### Ronnin

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.

#### haki

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
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.

#### Jheriko

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!)
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:

#### chroot

Staff Emeritus
Science Advisor
Gold Member
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.
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:

http://www.virtualcivilization.org/WaveVision-LowRes.jpg [Broken]

It's still available from National Semiconductor:

http://www.national.com/appinfo/adc/wv4.html [Broken]

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

Last edited by a moderator:

ooooo ... pwnt.

#### Crosson

To a high school student who plans to study Electrical Engineering, I would recommend starting with the Mathematica programming language.

#### Jheriko

To a high school student who plans to study Electrical Engineering, I would recommend starting with the Mathematica programming language.
Mathematica is not strictly a programming language, its more of a highly specialised script. You don't need to understand too many programming concepts to use it, so I'm not sure how good it would be for learning programming in general...

#### haki

As I recall from the Java Whitepaper[1], Java as a language was designed to be simple (very little syntactic suggars) and Robust (rigid and verbose) and a few more things. What you wrote as shortcomings are actually the design goals of Java.

But, I admit that pre Java 5.0 it wasn't that nice to program in Java as is now.

[1] http://java.sun.com/docs/white/langenv/

#### AlephZero

Science Advisor
Homework Helper
The problem with learning a first programming language is you need to learn at least 5 things at once: The specifics of that language, software design principles, (object orientation/modularity/information hiding/whatever is the fashionable buzzword this week), some basic algorithms, GUI design, and debugging techniques.

For the second language it gets easier, since you only have to relearn the first one.

In the long run I don't think it matters much what language you start with. I got paid to write my first program in about 1970, and I reckon I've learned a new language every 2 or 3 years since then. The only language I've used that has survived the whole time period was Fortran (and even then, Fortran 90 doesn't look much like good old Fortran II).

#### chroot

Staff Emeritus
Science Advisor
Gold Member
As I recall from the Java Whitepaper[1], Java as a language was designed to be simple (very little syntactic suggars) and Robust (rigid and verbose) and a few more things. What you wrote as shortcomings are actually the design goals of Java.
Regardless of whether its lousiness was a design goal or not, it's still lousy.

- Warren