Re: [Tutor] How it is better than java

2011-09-23 Thread Alan Gauld

On 19/09/11 14:27, Ashish Gaonker wrote:

First, to address the question in your subject line, we need to agree a 
definition of better. In what respect? And by which benchmark?
And who claimed that either one was better anyway? No serious 
programmer would be likely to make such a vague comparison.



My obvious thinking is : Java being compiled language , must be faster
then a interpreted   language.


There have been many other answers that address this.
Suffice to say it is fallacious both factually and in principle.


I know couple of points : Development time is less + easy to learn +
python is expressive.


These are all different dimensions of betterness. Which aspect is 
important to you? There are no perfect languages.



Can you share some more especially as compared to Java / .net (two
primarily used languages in enterprise language  web based applications)


.Net is not a lanuage it is a programming environment which supports 
multiple languages, but all of them working on the compile to bytecode 
then run in an interpreter model that Python mostly uses.


Apart from trolling the list what do you hope to gain from this post?
Do you have some objective, such as persuading a boss to allow you use 
Python instead of Java/.Net? Are you looking for justification to 
yourself to learn Python? (In that case forget everything else and just 
learn it for the different approaches and constructs it takes - like any 
other new language. Learning new languages will always benefit your 
programming by exposing new idioms.)


HTH,
--
Alan G
Just back from an internet free vacation :-)

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How it is better than java

2011-09-23 Thread Steven D'Aprano

Alan Gauld wrote:


Apart from trolling the list what do you hope to gain from this post?



Be fair -- there's no evidence that Ashish Gaonker was insincere about 
his question or trying to stir up trouble. It is a very common 
misapprehension that language Foo is faster than language Bar, and in 
practice, Java programs often are faster than the equivalent Python 
program. That's a quality of implementation issue rather than a language 
issue: Python hasn't had the millions of dollars of development that 
Java has had. But I bet I could write a Java compiler that was slower 
than Python, easy! wink




--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How it is better than java

2011-09-22 Thread Steven D'Aprano

Mac Ryan wrote:

On Tue, 20 Sep 2011 10:27:12 +1000
Steven D'Aprano st...@pearwood.info wrote:



There are three misunderstandings with that statement.
[snip]
There's also JPype, which claims to give full access to Java
libraries in Python.


Now: this was one of the best write-ups on the subject I read. Concise,
clear, documented. Nice way to start the day! :o



I'm glad it was helpful and interesting. Thank you to everyone for the 
kind words.





--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How it is better than java

2011-09-20 Thread Mac Ryan
On Tue, 20 Sep 2011 10:27:12 +1000
Steven D'Aprano st...@pearwood.info wrote:


 There are three misunderstandings with that statement.
 [snip]
 There's also JPype, which claims to give full access to Java
 libraries in Python.

Now: this was one of the best write-ups on the subject I read. Concise,
clear, documented. Nice way to start the day! :o

/mac
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How it is better than java

2011-09-20 Thread Wayne Werner
On Tue, Sep 20, 2011 at 3:21 AM, Mac Ryan quasipe...@gmail.com wrote:

 On Tue, 20 Sep 2011 10:27:12 +1000
 Steven D'Aprano st...@pearwood.info wrote:


  There are three misunderstandings with that statement.
  [snip]
  There's also JPype, which claims to give full access to Java
  libraries in Python.

 Now: this was one of the best write-ups on the subject I read. Concise,
 clear, documented. Nice way to start the day! :o


Ditto - and as a slight aside, it's interesting to note that .NET languages
(VB, C# specifically) are also compiled into the MSIL which can't run
without the .NET runtime. To my understanding, this is quite similar (or the
same thing) as other interpreted languages.

-Wayne
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] How it is better than java

2011-09-19 Thread Ashish Gaonker
My obvious thinking is : Java being compiled language , must be faster then
a interpreted   language.

I know couple of points : Development time is less + easy to learn + python
is expressive.

Can you share some more especially as compared to Java / .net (two primarily
used languages in enterprise language  web based applications)

-- 
Thanks  Regards
Ashish Gaonker
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How it is better than java

2011-09-19 Thread Christian Witts

On 2011/09/19 03:27 PM, Ashish Gaonker wrote:
My obvious thinking is : Java being compiled language , must be faster 
then a interpreted   language.


I know couple of points : Development time is less + easy to learn + 
python is expressive.


Can you share some more especially as compared to Java / .net (two 
primarily used languages in enterprise language  web based applications)


--
Thanks  Regards
Ashish Gaonker


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
I would suggest reading `Python is not Java` [1] and `Java is not 
Python, either` [2], old but good reads.  And then ask what is your 
focus for development.  Better is extremely subjective and can be liable 
to induce flame-wars, although this list is quite friendly.


To me, I started using Python as a glue language, controlling process 
flows and the like, with still heavy uses of C and PL/SQL for what I 
do.  Over time Python has taken center-stage for my projects due to 
ease-of-use and rapid application development and only moving time 
critical work that needs to be faster to C but in most cases that is 
not needed for me anymore.


Add to that the great work on PyPy [3] which is extremely efficient, I 
hardly ever have to write in another language if I don't wish.


[1] http://dirtsimple.org/2004/12/python-is-not-java.html
[2] http://dirtsimple.org/2004/12/java-is-not-python-either.html
[3] http://pypy.org/
--

Christian Witts
Python Developer

//
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How it is better than java

2011-09-19 Thread Walter Prins
Hi Ashish,

On 19 September 2011 14:27, Ashish Gaonker ashish@gmail.com wrote:

 My obvious thinking is : Java being compiled language , must be faster then
 a interpreted   language.

 I know couple of points : Development time is less + easy to learn + python
 is expressive.

 Can you share some more especially as compared to Java / .net (two
 primarily used languages in enterprise language  web based applications)


There's many pages on the internet comparing Python, Java and other
languages.  I suggest you check them out.

Having said that, I'll point out that Python has several implementations,
including one called Jython, which actually targets the Java runtime and
so should have comparable performance to Java on the same runtime.
Additionally there's projects like PyPy which in some cases is faster even
than C/C++.

This page (from my bookmarks) has some interesting points of comparison for
consideration:
http://pythonconquerstheuniverse.wordpress.com/category/java-and-python/

Walter
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How it is better than java

2011-09-19 Thread Steven D'Aprano

Ashish Gaonker wrote:

My obvious thinking is : Java being compiled language , must be faster then
a interpreted   language.



There are three misunderstandings with that statement.

Firstly:

Languages are neither compiled or interpreted. Languages are syntax 
and grammar. Implementations are either compiled, or interpreted, or 
both: for example, there are C interpreters and C compilers. And the 
quality of both can vary significantly.


Asking which language is faster is like asking which is faster, Ford or 
Toyota? That depends on the particular model, and the conditions, and 
the skill of the driver.


It is ironic that you contrast Java as compiled and Python as 
interpreted, because that is *marketing*. When Java first came out, 
Sun didn't want people describing it as interpreted, which it was, so 
they popularized the term byte-code compiler just so that they could 
talk about Java being compiled. Java would compile your Java source code 
to byte-code which was then interpreted by a virtual machine.


That is *exactly* what Python does: it compiles Python source code to 
byte-code which is interpreted by a virtual machine, just like Java. 
What do you think the .pyc files contain, and what the compile() 
function does? And yet, even back in the 1980s, everybody swallowed 
Sun's marketing and called Java a compiled language and Python an 
interpreted language. This is a testament to Sun spending millions in 
advertising.


Byte-code compilation is a lot older than Java. Pascal used something 
similar in the early 1970s, called a p-machine. Even Apple's Hypertalk 
did the same thing, only they called it tokenized code instead of 
compiled. Java's big innovation was to convince people to use the term 
compiler for what was functionally identical to an interpreter.


Of course, Sun (now owned by Oracle) put in a lot of money into Java. 
Millions. Today, Java does have implementations which compile source 
code to machine code. But there are Python implementations that do the 
same, such as Nuitka and Compyler. (I don't know how successful or good 
they are.)


Secondly, what do you mean by faster? Faster to write? Faster to 
compile? Faster to run? Faster for the engine to start up? Even today, 
after Sun has spent tens of millions on Java development, the Java 
Runtime Environment is a big, heavyweight machine that takes a long time 
to start up: cold starts can easily take 30 seconds. That makes Java 
completely unsuitable for small, lightweight tasks: in the time it takes 
for a *single* Java program just to start up, you could possibly run a 
dozen Python programs or a hundred interpreted bash scripts.


But again, that's an *implementation*, not a hard rule about Java. There 
is at least one third-party JRE which claims to have startup times twice 
as fast as the Sun/Oracle JRE.


Either way, once you take startup time into account, sometimes Python 
scripts are not only faster to write and faster to maintain, but faster 
to run as well.


Thirdly, there is no rule of nature that a compiled program to do a job 
must be faster than an interpreted program to do the same thing. This 
depends entirely on the quality of implementation of both: a poor 
compiler may easily generate bad, slow code that takes longer to run 
than a wickedly fast and efficient interpreter. E.g. a compiled version 
of bubblesort will still be slower than an interpreted version of quicksort.


Nothing drives this home more than PyPy, a Just In Time optimizing 
version of Python. PyPy uses a JIT compiler to run code sometimes FASTER 
than the equivalent program in optimized C.


Yes. Faster than C. You read that right.

http://morepypy.blogspot.com/2008/01/rpython-can-be-faster-than-c.html
http://morepypy.blogspot.com/2011/02/pypy-faster-than-c-on-carefully-crafted.html
http://morepypy.blogspot.com/2011/08/pypy-is-faster-than-c-again-string.html


Of course, benchmarks are notoriously flawed, especially micro-
benchmarks. What they *really* answer is not which language is faster? 
(a nonsense question, as I have tried to explain) but which 
implementation is faster with these particular settings on this 
particular task?, a much more practical question.


As exciting as it is to see Python code run faster than C code, it 
shouldn't really surprise anyone that a JIT dynamic compiler with cross 
module optimization beats a static compiler without it. What *is* 
surprising is that a small group of open-source developers have been 
able to build an optimizing JIT compiler for Python of such quality.


Or at least, it is surprising to people who think that quality code can 
only come from big proprietary companies with huge budgets.


What's really exciting though is that now PyPy can be fast enough for 
large programs that traditionally needed to be written in C can now be 
(sometimes!) written in Python:


http://morepypy.blogspot.com/2011/07/realtime-image-processing-in-python.html


Who cares whether Java, or C, is faster