PDA

View Full Version : r Beginning...A Nonprogrammer’s Review on Python: Why Python is the Ideal Langu...



yuvlevental
August 30th, 2007, 01:26 AM
Out of the many languages in the world of computers, there is one that stands out. This language is called Python. It is very simple and easy to learn. It is very portable, having been ported to many different platforms. It is also very extensible, with many modules. These are the reasons that Python is the ideal language for beginning programmers.

First, Python is very simple and easy to learn, as opposed to other languages. Comparing the C++ and Python “Hello World!” programs, Python stands out as the easier one, with C++ being:

#include <iostream.h>

main()
{
cout << "Hello World!";
return 0;
}

and Python being:

print 'Hello World!'

Reading a good Python program is a lot like reading English. There are many good Python tutorials on the web, such as A Byte of Python and A Nonprogrammer’s Tutorial for Python Programmers.

Then, Python is very portable. It runs on Windows, Mac, and Linux. It even runs on Java with Jython libraries. Python also can run on the .NET platform with IronPython.

Finally, Python is very extensible. It creates GUI’s such as Tkinter. It can be used to create games with engines such as pyGame. It can also be used for web programming with tools like Django.

In conclusion, Python is the ideal language for beginning programmers. It is very english-like and easy to learn. It is also crossplatform, having been ported to many different platforms. Many modules exist for Python with a wide range of purposes. Finally, Python is the premiere language, being both easy and powerful.

Original Article is here (http://python-tutorials.com/?p=29).

triptoe
August 30th, 2007, 04:27 AM
And thats the reason why I will be supporting and writing in moonlight/mono in the future... because it is the only way to create RIA's with the language of your choice!

pmasiar
August 30th, 2007, 04:52 AM
it is the only way to create RIA's with the language of your choice!

It is **my** choice or **your** choice? Because **my** choice is Python :-)

Zdravko
August 30th, 2007, 08:40 AM
yuvlevental (http://ubuntuforums.org/member.php?u=319350), your comparison of the Hello world's programs is stupid. C++ and Python are different types of languages. You can't compare them in any way.

LaRoza
August 30th, 2007, 12:47 PM
yuvlevental (http://ubuntuforums.org/member.php?u=319350), your comparison of the Hello world's programs is stupid. C++ and Python are different types of languages. You can't compare them in any way.

To compare the languages, yes, that is not a good example. For a beginner, just learning, that is a strong argument to study Python first. To understand the Python program (or Perl, Ruby, Tcl), you only need to understand a single statement, before moving on.

In C/C++, you are exposed to functions, includes, and sometimes namespaces. This is essential knowledge, but can be a bit much for someone who starts out. They have to accept the "magic", or go into an in depth discussion about concepts they won't use untill several lessons later, usually after they study variables, control, and iteration.

Zdravko
August 30th, 2007, 12:58 PM
Hm, I might give it a try some day.

LaRoza
August 30th, 2007, 01:04 PM
Hm, I might give it a try some day.

For good Python resources, see my or pmasiar's wiki. (Mine links to his, and has other resources in the library)

pmasiar
August 30th, 2007, 01:50 PM
yuvlevental (http://ubuntuforums.org/member.php?u=319350), your comparison of the Hello world's programs is stupid. C++ and Python are different types of languages. You can't compare them in any way.

While I agree with Zdravko that comparing "Hello world" is stupid - maybe, better word would be nonessential or trivial - I disagree that we cannot compare them: because yes sure we can, and we did, and in many many threads. :-)

Yes, it is "stupid" to select language based on one trivial example, (with Python code, not even using a function - so we compare apples and oranges), **far better** example of any language facilities is canonical 99 bottles song: http://99-bottles-of-beer.net/

But yes, Python is substantially simpler than C, especially for beginner programmer, and 95% of people **who know Python** would agree with it. I found that many people who disagree that Python is best for beginner are people who don't know Python, but just one other language, and promote it.

For a record, I know many languages, and I wrote and debugged programs in more than dozen languages. And yes, I like Python most :-)

Zdravko
August 30th, 2007, 01:55 PM
5 years ago I studied Python at school. I had to prepare a small course project. It was disastrous. I received not an excellent mark, but a good one. How can you convince me that Python is good? I've done hundreds of C++ programs and all of them have served me well.

LaRoza
August 30th, 2007, 02:02 PM
5 years ago I studied Python at school. I had to prepare a small course project. It was disastrous. I received not an excellent mark, but a good one. How can you convince me that Python is good? I've done hundreds of C++ programs and all of them have served me well.

If C++ is better suited for the project, it should be used.

Python and every other programming language are just tools to be used by the programmer. It is important to use the right tool for the task. The more languages you know (assuming you know them well), the better you can choose the best language.

No one here is saying any language is better than any other, just that some are better for certain things.

pmasiar
August 30th, 2007, 02:32 PM
5 years ago I studied Python at school. I had to prepare a small course project. It was disastrous. I received not an excellent mark, but a good one. How can you convince me that Python is good? I've done hundreds of C++ programs and all of them have served me well.

I have no idea what your Python project was, quality of the teacher instruction, what were the problems, and no intention to convince you in anything. Use what you like - I have no idea what are your problems. I like Python, it serves me well for everything I do (mostly web based databases, with some file parsing). It is exactly as valid anecdote as yours.

I just disagree with you saying we cannot compare those languages, because yes we can.

samjh
August 30th, 2007, 02:38 PM
Python is a great little language for programmers who do not need/want to deal with safety-critical, system-level, or high-performance computing problems: ie. most programmers.


Yes, it is "stupid" to select language based on one trivial example, (with Python code, not even using a function - so we compare apples and oranges), **far better** example of any language facilities is canonical 99 bottles song: http://99-bottles-of-beer.net/
I still prefer my Hello Ubuntu in every programming language (http://ubuntuforums.org/showthread.php?t=497579) thread. Not biased... honest! ;)

LaRoza
August 30th, 2007, 02:42 PM
I still prefer my Hello Ubuntu in every programming language (http://ubuntuforums.org/showthread.php?t=497579) thread. Not biased... honest! ;)

That is a better example to compare the languages, but the http://99-bottles-of-beer.net/abc.html is better to show the features that can be used, look at the Perl example!

Wybiral
August 30th, 2007, 02:54 PM
I'm noticing a broken record trend on this forum where all of the regulars end up having to post "Use the right tool for the right job" and "Languages don't compare as simply better-than or worse-than, it depends on the job".

Python is a great language... But so are C and C++. Wait until you're working on a large 3d application and you need to implement massive amounts of custom matrix operations or texture animations that require tight loops... Then Python becomes useless. In these types of situations, execution speed is the goal, not development speed. C or C++ would be the right tools for that job.

Likewise, it would be retarded to shoot yourself in the foot trying to write a memory safe, generic, easily modifiable system in C if you can hack it out in a few minutes with Python.

Right tool, right job. Do what you have to do, but no more.

yuvlevental
August 30th, 2007, 05:25 PM
Well OK, maybe Python isn't as powerful as C++ or as extensive as Perl. But the article said that it's the ideal first language, not THE ideal language. When I was checking out languages, I discovered Python was very easy, and I saw that it was used to program memory-intensive apps such as CIV IV. I also saw that 3d games could be programmed, such as Slune (http://home.gna.org/oomadness/en/slune/). Also, about the "Hello World" example, I should have thought of something like Hello Ubuntu, but I could only think of the basic example. If I made any stupid mistakes in my essay, please be nice, as I don't know too much about programming.

Wybiral
August 30th, 2007, 06:08 PM
... I discovered Python was very easy, and I saw that it was used to program memory-intensive apps such as CIV IV ...

I don't think "CIV IV" was written in Python, I think it's just scriptable with Python.

And this makes sense... It's great to use Python to hold game objects together, but the core of any 3d game is best suited to be written in a compiled language since there will be lots of tight loops and number crunching required.

I'm in no way saying that Python isn't a great language, it is... But not for every programming task. No language has that status. As I said, you have to use the one thats right for the job at hand.

That's why it doesn't make sense to compare it to C or C++. All that does is spark flamewars.

pmasiar
August 30th, 2007, 06:13 PM
Please let's not start comparing which language is more powerfull, we did it couple times this week only. Enough is enough. And except tiptoe and Zdravko, everybody (95% of people who tried it according to some random poll) agrees with you that Python is good or excellent language for beginner.

We disagree with you only in one detail: that simple example like "hello world" is good basis to make opinion about a language.

Edit: This sentence is for yuvlevental only
Keep up learninig, instead of posting Python evangelization articles, post about what was not obvious to learn -- and then, don't forget the [ code] tags! :-)

LaRoza
August 30th, 2007, 06:33 PM
--edit--

pmasiar
August 30th, 2007, 07:04 PM
--- oops --

LaRoza
August 30th, 2007, 08:04 PM
Sorry that sentence was for yuvlevental only

Actually, I was confused over the typo, I thought I was missing something . I deleted my quote, so it doesn't follow you around. :D

slavik
August 30th, 2007, 10:36 PM
To compare the languages, yes, that is not a good example. For a beginner, just learning, that is a strong argument to study Python first. To understand the Python program (or Perl, Ruby, Tcl), you only need to understand a single statement, before moving on.

In C/C++, you are exposed to functions, includes, and sometimes namespaces. This is essential knowledge, but can be a bit much for someone who starts out. They have to accept the "magic", or go into an in depth discussion about concepts they won't use untill several lessons later, usually after they study variables, control, and iteration.

what is "print" ? is it not a function?

when you take a large data structure (class) and you try to break it up into smaller things (data + functions) and then break those up into smaller things (just stuff stored in memory + set of instructions), you need to find something that cannot be broken down anymore (for the purposes of teaching what you want to teach).

IMO, understanding what a function is is the most basic thing when teaching most languages (C, C++, Perl, Python, etc.) especially functional languages where you are allowed to call only 1 function:
scheme vs. C/python, etc.

add 5 numbers (1 + 2 + 3 + 4 +5)
scheme:


(+ 1 (+ 2 (+ 3 (+ 4 5))))


c/cpp/perl/python/java/etc.


1+2+3+4+5


note about scheme: the parser is very easy to make, the tradeoff is the huge amount of parenthesis :)

pmasiar
August 31st, 2007, 02:44 AM
what is "print" ? is it not a function?

No, print is a statement, decision which Guido regrets and print will be made function in Py3.0

> add 5 numbers (1 + 2 + 3 + 4 +5)

Forth:


1 2 3 4 5 + + + +

or (same thing):

1 2 + 3 + 4 + 5 +



note about Forth: the parser is super easy to make, code is very effective, **and** no need for parenthesis :)

yuvlevental
August 31st, 2007, 03:01 AM
No, print is a statement, decision which Guido regrets and print will be made function in Py3.0


What would be the advantage?

pmasiar
August 31st, 2007, 04:20 AM
What would be the advantage [of having print() function instead of print statement]?

Read whole Python 3000 Status Update (http://www.artima.com/weblogs/viewpost.jsp?thread=208549):



Printing and Formatting

Two more I/O-related features: the venerable print statement now becomes a print() function, and the quirky % string formatting operator will be replaced with a new format() method on string objects.

Turning print into a function usually makes some eyes roll. However, there are several advantages: it's a lot easier to refactor code using print() functions to use e.g. the logging package instead; and the print syntax was always a bit controversial, with its >>file and unique semantics for a trailing comma. Keyword arguments take over these roles, and all is well.


So as a result, syntax will become also little simpler. Python is the only language I know of, which with increasing version number makes syntax (in some parts) simpler, **less** special cases, not more.

Wybiral
August 31st, 2007, 04:28 AM
What would be the advantage?

Because it makes no sense for every other piece of a language to be used as "function(parameters)" and print to be used as "function parameters". It should be treated just as any other function.

It will also ease confusion with the C users who are used to "printf(parameters)".

slavik
August 31st, 2007, 04:42 AM
No, print is a statement, decision which Guido regrets and print will be made function in Py3.0

> add 5 numbers (1 + 2 + 3 + 4 +5)

Forth:


1 2 3 4 5 + + + +

or (same thing):

1 2 + 3 + 4 + 5 +



note about Forth: the parser is super easy to make, code is very effective, **and** no need for parenthesis :)
your code brings up a good point: prefix vs. infix vs. postfix :)

in many situations, operators work like functions. many but not all. :)

for example in perl, if you predefine a subroutine you can use it as an operator. :)

Wybiral
August 31st, 2007, 05:19 AM
your code brings up a good point: prefix vs. infix vs. postfix :)

Postfix is particularly interesting because of it's efficiency when solving expressions using a stack.

"1 2 +" would evaluate to "push 1; push 2; (pop a; pop b; push a+b") which is extremely efficient. This is why infix expressions are almost always converted to postfix before evaluating.

Prefix doesn't work well with a stack and the operator has to be stored when encountered until it's use.

slavik
August 31st, 2007, 06:01 AM
Postfix is particularly interesting because of it's efficiency when solving expressions using a stack.

"1 2 +" would evaluate to "push 1; push 2; (pop a; pop b; push a+b") which is extremely efficient. This is why infix expressions are almost always converted to postfix before evaluating.

Prefix doesn't work well with a stack and the operator has to be stored when encountered until it's use.

yes.

as a note and for those interested to mess around with stuff.

man bc and man dc. dc is a stack based calculator, and bc converts infix to postfix and uses dc (through pipes and popen) to do the actual calculations. 2 tiny pieces of program showing important things (infix to postfix conversion and pipes/popen use)

EDIT: little things like bc/dc make Linux awesome :)

Zdravko
August 31st, 2007, 08:56 AM
What is bc/dc?

pmasiar
August 31st, 2007, 01:02 PM
"1 2 +" would evaluate to "push 1; push 2; (pop a; pop b; push a+b") which is extremely efficient. This is why infix expressions are almost always converted to postfix before evaluating.
.

(pop a; pop b; push a+b) can be done in **single CPU instruction** with flexible CPU like PDP/11.

This is why Forth is so efficient. Author decided to stop pretending we don't use stack, and use it openly, all operations are postfix. This simplifies **a lot** whole system: parser, interpreter, argument passing. And it is not that hard to get used to it.

slavik
August 31st, 2007, 05:56 PM
What is bc/dc?

man bc and man dc

very nice tools.