Re: Python vs Java - Perché i pythonisti ce l'hanno tanto con Java?
Enrico Franchi ha scritto: spazza spa...@alum.com wrote: ...snip... Non mi pare che al momento Python sia in grado di reggere tutto questo. Scusa, proseguendo in questa maniera andiamo pesantemente OT. Rimane pero' il problema di *dimostrare* la tua affermazione. Da quanto leggo, mi sembra che tu di Python sappia circa nulla e di conseguenza stai facendo affermazioni di inadeguatezza su una piattaforma che non conosci. Hai ragione, stiamo andando OT; però consideriamo solo questo: devi costruire un'applicazione per accedere ad un DB Oracle non nuovissimo che sai verrà aggiornato prima o poi. Cosa ti serve per Java e dove lo trovi? Scarichi direttamente dal sito Oracle il driver JDBC ultima release, che funziona con tutte le versioni più recenti di Java, e puoi sviluppare l'applicatione sul tuo PC, trasportandola poi su un altro ambiente senza colpo ferire. Al più, se hai prodotti molto datati, tipo Oracle DB 8.x o Java 1.3, devi prendere una versione del driver un po' più vecchia, tutto qui. Ma è molto probabile che l'applicazione continuerà a funzionare anche aggiornando in seguito il driver. Stessa situazione, cosa server con Python? Intanto, non è chiarissimo dove trovare il necessario: su OTN (Oracle) c'è scritto di usare cx_Oracle, ma ovviamente Oracle non ti supporta e dopo che hai speso svariati keuro per il canone di assistenza non è proprio il massimo. Poi, in ogni caso, cx_Oracle richiede l'installazione del client Oracle, che anche nella versione Instant è un affare abbastanza intrusivo e comunque è dipendente dal sistema operativo. Poi devi trovare tra i vari file di cx_Oracle la combinazione giusta tra versione di Python, versione dei driver Oracle e versione del sistema operativo corrispondente alla tua situazione. Se ti va male, es. usi Solaris, ti tocca anche provare a ricompilarlo. Quasi sicuramente, al primo upgrade massiccio del sistema in servizio devi ricominciare da capo. Non è nulla di impossibile, ma ritornando al punto: ti sembra praticabile da tutti? Ti sembra una soluzione sostenibile a medio/lungo termine in una realtà aziendale? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python for Java programmer
On Dec 14, 11:53 am, Nirav Thaker [EMAIL PROTECTED] wrote: Yo Group, I'm excited to learn Python as new language coming year, I consider myself good Java developer and, not so unusually, with very limited experience with dynamic programming languages such as Python or Ruby. I have started with basics athttp://docs.python.org, but I'm more interested in learning philosophies in programming dynamically typed languages, I really want to get rid of those Enterprisely weird Java techniques. I'm looking for good resources and a better technique to learn Python, would appreciate book references or URLs for them (Google explodes me with info. and I don't really have time to read all that). Also, I'm looking forward to hack some framework or library written in Python to get a good deal of exposure to language and class library, So it would be great if anyone would suggest such framework as well. Looking forward for suggestions Python community! You may want to check out these first: http://dirtsimple.org/2004/12/python-is-not-java.html http://www.razorvine.net/python/PythonComparedToJava George -- http://mail.python.org/mailman/listinfo/python-list
Re: Python for Java programmer
Nirav Thaker a écrit : Yo Group, I'm excited to learn Python as new language coming year, I consider myself good Java developer and, not so unusually, with very limited experience with dynamic programming languages such as Python or Ruby. Then you'll probably have to unlearn a few things... I have started with basics at http://docs.python.org, but I'm more interested in learning philosophies in programming dynamically typed languages, I really want to get rid of those Enterprisely weird Java techniques. Fine !-) A good start is of course the now famous Python is not Java article: http://dirtsimple.org/2004/12/python-is-not-java.html Also FWIW, the dynamic part is not restricted to typing. You can dynamically modify class or instance attribute set (including methods), hook into lookup rules or class creation, dynamically create functions, classes or modules, etc... Syntax errors set aside, everything happens at run time. I'm looking for good resources and a better technique to learn Python, would appreciate book references or URLs for them (Google explodes me with info. and I don't really have time to read all that). Having a decent knowledge of Python's object model (with special attention to the lookup rules - and how you can hook into -, the operators overloading and other __magic__ methods, and of course metaclasses) may help - since everything in Python is an object (including modules, classes, functions etc). Once you understand what's a Python object and how it works, you have a chance to start thinking otherwise about how to structure your programs. Most of the relevant doc is here: http://docs.python.org/ref/objects.html http://docs.python.org/ref/node33.html http://python.org/doc/newstyle/ http://docs.python.org/ref/specialnames.html Sadly, there isn't AFAIK any in-depth material exposing these features and how they can used in real-world. But anyway: Also, I'm looking forward to hack some framework or library written in Python to get a good deal of exposure to language and class library, Note that the Python libraries (standard and thir-part) are not necessarily that much class-oriented. With dynamic typing, you don't need deep class hierarchies. And with everything being an object, you end up thinking more in term of objects than in terms of classes. So it would be great if anyone would suggest such framework as well. Here are a couple packages I learned (and I'm still learning) from: - SqlAlchemy : a hi-level interface to RDBMS, including (but not restricted to) an ORM layer, - Elixir: a declarative layer on top of sqlAlchmy's ORM features, - FormEncode : a conversion/validation lib, mostly used for the web but usable for any outer-world/your-program data exchange. The declarative API it's built upon is really worth reading if you want to see Python's power in action, but beware, there are really things in it one should not show to childrens !-) HTH. And welcome onboard. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python for Java programmer
Welcome to Python! One way to get you up to speed fast (and fun) is take some java app you've written and implement it in Jython. After you've done that, and gotten over the pleasant surprise of how short and clean your code has become, go over the source again and see where you can replace calls to java libs with calls to Python libs. E.g. for xml xpath use ElementTree instead of JDom, for timing use Python's timeit module, etcetera. Although I've been using Python for a while now I've done the same thing recently and was surprised by how clearly that exercise showed Python's strengths. Just go ahead and start programming is the best way to learn about the philosophies behind a language. 2B -- http://mail.python.org/mailman/listinfo/python-list
Re: Python for Java programmer
Having a decent knowledge of Python's object model As explained clearly here: http://www.cafepy.com/article/python_types_and_objects/python_types_and_objects.html http://www.cafepy.com/article/python_attributes_and_methods/python_attributes_and_methods.html 2B -- http://mail.python.org/mailman/listinfo/python-list
Re: Python for Java programmer
Berco Beute a écrit : Having a decent knowledge of Python's object model As explained clearly here: http://www.cafepy.com/article/python_types_and_objects/python_types_and_objects.html http://www.cafepy.com/article/python_attributes_and_methods/python_attributes_and_methods.html I'm not sure these articles will bring that much to the OP. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Java
Steve Holden [EMAIL PROTECTED] wrote: Ed Jensen wrote: Steve Holden [EMAIL PROTECTED] wrote: Jython is an implementation of Python that compiles to Java bytecode, but at the moment there's some version lag so it won't handle the mos recent language enhancements. Probably worth a look, though. http://www.jython.org/ Does Jython compile to Java bytecode, or is Jython a Java implementation of a Python interpreter? Please read what I wrote again. I read it and understood it just fine. My question was meant more along the lines of, Are you SURE it compiles to Java bytecode, and isn't a Python interpreter written in Java? I guess I didn't make that clear. Anyway, I checked the Jython home page, and sure enough, Jython compiles Python code to Java bytecode, as stated in the FAQ which can be found at the following URL (in case anyone else reading this message is following along and is interested): http://www.jython.com/Project/userfaq.html#what-is-jython In particular: 1.1 What is Jython? Jython implements the Python programming language on the Java(tm) Platform. It consists of a compiler to compile Python source code down to Java bytecodes which can run directly on a JVM, a set of support libraries which are used by the compiled Java bytecodes, and extra support to make it trivial to use Java packages from within Jython. Sorry if I bothered/annoyed you, Steve. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Java
Ed Jensen wrote: Steve Holden [EMAIL PROTECTED] wrote: Ed Jensen wrote: Steve Holden [EMAIL PROTECTED] wrote: Jython is an implementation of Python that compiles to Java bytecode, but at the moment there's some version lag so it won't handle the mos recent language enhancements. Probably worth a look, though. http://www.jython.org/ Does Jython compile to Java bytecode, or is Jython a Java implementation of a Python interpreter? Please read what I wrote again. I read it and understood it just fine. My question was meant more along the lines of, Are you SURE it compiles to Java bytecode, and isn't a Python interpreter written in Java? I guess I didn't make that clear. Anyway, I checked the Jython home page, and sure enough, Jython compiles Python code to Java bytecode, as stated in the FAQ which can be found at the following URL (in case anyone else reading this message is following along and is interested): http://www.jython.com/Project/userfaq.html#what-is-jython In particular: 1.1 What is Jython? Jython implements the Python programming language on the Java(tm) Platform. It consists of a compiler to compile Python source code down to Java bytecodes which can run directly on a JVM, a set of support libraries which are used by the compiled Java bytecodes, and extra support to make it trivial to use Java packages from within Jython. Sorry if I bothered/annoyed you, Steve. No real problem, I just thought I had already answered the question you asked. Of course the web reference was, as you'd expect, definitive, and your quoting it in this group will probably help those weho follow along. Glad it sounds like Jython might suit you - it's a great integration job! regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Recent Ramblings http://holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Java
Sreelatha G wrote: Hi I am new to python .I need your help in solving my problem. Is there any way to call python files in a java file .How is it possible? Jython is an implementation of Python that compiles to Java bytecode, but at the moment there's some version lag so it won't handle the mos recent language enhancements. Probably worth a look, though. http://www.jython.org/ regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Recent Ramblings http://holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Java
On Apr 5, 7:18 am, Steve Holden [EMAIL PROTECTED] wrote: Sreelatha G wrote: Hi I am new to python .I need your help in solving my problem. Is there any way to call python files in a java file .How is it possible? Your other option is to utilize a system exec call, and try and trap the results. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Java
Steve Holden [EMAIL PROTECTED] wrote: Jython is an implementation of Python that compiles to Java bytecode, but at the moment there's some version lag so it won't handle the mos recent language enhancements. Probably worth a look, though. http://www.jython.org/ Does Jython compile to Java bytecode, or is Jython a Java implementation of a Python interpreter? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Java
Ed Jensen wrote: Steve Holden [EMAIL PROTECTED] wrote: Jython is an implementation of Python that compiles to Java bytecode, but at the moment there's some version lag so it won't handle the mos recent language enhancements. Probably worth a look, though. http://www.jython.org/ Does Jython compile to Java bytecode, or is Jython a Java implementation of a Python interpreter? Please read what I wrote again. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Recent Ramblings http://holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java eclipse
Amir Michail a écrit : Hi, It seems to me that measuring productivity in a programming language must take into account available tools and libraries. Eclipse for example provides such an amazing IDE for java that it is no longer obvious to me that one would be much more productive in python for medium sized projects. Sure, all that Java static typing can be painful, but Eclipse takes some of that pain away. Moreover, static typing can result in better on-the-fly error detection and refactoring support. Any thoughts on this? Yes : Python's productivity does not only comes from dynamic typing. -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java eclipse
Amir Michail wrote: Hi, It seems to me that measuring productivity in a programming language must take into account available tools and libraries. Eclipse for example provides such an amazing IDE for java that it is no longer obvious to me that one would be much more productive in python for medium sized projects. Sure, all that Java static typing can be painful, but Eclipse takes some of that pain away. Moreover, static typing can result in better on-the-fly error detection and refactoring support. Any thoughts on this? Amir FYI: http://showmedo.com/videos/series?name=PyDevEclipseList hg -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java eclipse
Hi, Here's a blog post that is relevant to this discussion: http://sixthandredriver.typepad.com/river_of_code/2006/01/automated_refac.html Amir -- http://mail.python.org/mailman/listinfo/python-list
RE: python vs java eclipse
If you're in the PyDev perspective, F9 runs the current script while ctrl-F11 reruns the last script run. I have found that certain types of operations just plain don't work this way and must be run from a conventional shell window. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of krishnakant Mane Sent: Friday, December 01, 2006 6:19 AM To: python-list@python.org Subject: Re: python vs java eclipse just used the py dev plugin for eclipse. it is great. auto indentation and intellisence. and all other things. so now how does it look from this end? python + productivity and eclipse + productivity = double productivity! only problem with the plugin is that I find it difficult to manage the script running. I open a command prompt and run the scripts manually. any suggestion for this. for example I had name = raw_input(please enter your name) and the moment I type the first letter on the keyboard the code execution moves over to the next statement. should it not wait for the return key as it always does? Krishnakant. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java eclipse
On 1 Dec 2006 01:24:47 -0800, Amir Michail [EMAIL PROTECTED] wrote: Eclipse for example provides such an amazing IDE for java that it is no longer obvious to me that one would be much more productive in python for medium sized projects. Eclipse can generate a lot of the Java boilerplate code, it's true, saving you a lot of typing up front. But it can't maintain all those reams of pointless code for you, and perhaps more importantly, it can't read it for you. All the useless code that Java requires still has a large price, even if you don't need to type it yourself. Sure, all that Java static typing can be painful, but Eclipse takes some of that pain away. Moreover, static typing can result in better on-the-fly error detection and refactoring support. I do sometimes spend some time finding and fixing bugs of the I though I had a Spam instance, but it turns out to be a Eggs instance issues when coding in Python, but then I spend some time sorting out I know you've got a fry() method in there somewhere - just let me call it! issues in Java, so it balances out. And the latter problems are more annoying, 'cos I feel the compiler isn't trusting me. Python usually trusts me, even if I don't always deserve it. ;-) FWIW, I spend perhaps 80% of my coding time with Java (and Eclipse), and 20% with Python. -- Cheers, Simon B [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java eclipse
just used the py dev plugin for eclipse. it is great. auto indentation and intellisence. and all other things. so now how does it look from this end? python + productivity and eclipse + productivity = double productivity! only problem with the plugin is that I find it difficult to manage the script running. I open a command prompt and run the scripts manually. any suggestion for this. for example I had name = raw_input(please enter your name) and the moment I type the first letter on the keyboard the code execution moves over to the next statement. should it not wait for the return key as it always does? Krishnakant. -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java eclipse
krishnakant Mane wrote: just used the py dev plugin for eclipse. it is great. auto indentation and intellisence. and all other things. so now how does it look from this end? python + productivity and eclipse + productivity = double productivity! only problem with the plugin is that I find it difficult to manage the script running. I open a command prompt and run the scripts manually. any suggestion for this. for example I had name = raw_input(please enter your name) and the moment I type the first letter on the keyboard the code execution moves over to the next statement. should it not wait for the return key as it always does? Krishnakant. I don't know about raw_input ... my programs all go through some GUI ... but I run / debug(although almost never) all of my applications from pydev - no need to change project as with Visual Studio, I just run/debug whatever I need with a few clicks ... have not touched Konsole in weeks. I also, after weeks of testing, decided to invest in the pydev extensions / the bugs it has found for me already justify the investment. hg -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java eclipse
Thomas Ploch schrieb: Amir Michail schrieb: Hi, It seems to me that measuring productivity in a programming language must take into account available tools and libraries. Eclipse for example provides such an amazing IDE for java that it is no longer obvious to me that one would be much more productive in python for medium sized projects. Sure, all that Java static typing can be painful, but Eclipse takes some of that pain away. Moreover, static typing can result in better on-the-fly error detection and refactoring support. Any thoughts on this? Amir Yes, thats true, but since eclipse is resource monster (it is still using java), and some people (like me) don't have a super fresh and new computer, and have to run other services to test their work locally (like mysql and apache servers), it gets pretty harsh with eclipse. I personally tried eclipse on my laptop (which I work most with), and I had quite a system resource problem. So I switched back to vim and console and it hasn't been too bad, since if you know how to use a powerful editor, it can be as productive. But in the end, it is up to anyone to find the best solutiion for themselves. Thomas Yes, thats true, but since eclipse is resource monster (it is still using java), and some people (like me) don't have a super fresh and new computer, and have to run other services to test their work locally (like mysql and apache servers), it gets pretty harsh with eclipse. I personally tried eclipse on my laptop (which I work most with), and I had quite a system resource problem. So I switched back to vim and console and it hasn't been too bad, since if you know how to use a powerful editor, it can be as productive. But in the end, it is up to anyone to find the best solutiion for themselves. Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java eclipse
Thomas Ploch wrote: Thomas Ploch schrieb: Amir Michail schrieb: Hi, It seems to me that measuring productivity in a programming language must take into account available tools and libraries. Eclipse for example provides such an amazing IDE for java that it is no longer obvious to me that one would be much more productive in python for medium sized projects. Sure, all that Java static typing can be painful, but Eclipse takes some of that pain away. Moreover, static typing can result in better on-the-fly error detection and refactoring support. Any thoughts on this? Amir Yes, thats true, but since eclipse is resource monster (it is still using java), and some people (like me) don't have a super fresh and new computer, and have to run other services to test their work locally (like mysql and apache servers), it gets pretty harsh with eclipse. I personally tried eclipse on my laptop (which I work most with), and I had quite a system resource problem. So I switched back to vim and console and it hasn't been too bad, since if you know how to use a powerful editor, it can be as productive. But in the end, it is up to anyone to find the best solutiion for themselves. Thomas Yes, thats true, but since eclipse is resource monster (it is still using java), and some people (like me) don't have a super fresh and new computer, and have to run other services to test their work locally (like mysql and apache servers), it gets pretty harsh with eclipse. I personally tried eclipse on my laptop (which I work most with), and I had quite a system resource problem. So I switched back to vim and console and it hasn't been too bad, since if you know how to use a powerful editor, it can be as productive. But in the end, it is up to anyone to find the best solutiion for themselves. Thomas If you compare eclipse to VS, it is not that memory hungry - but i agree with you that a min-config is needed. Yet (I believe that) a complete IDE can bring functions that an editor, however powerful, cannot (I still use emacs). I have tried Komodo, Wing, Eric3, Idle, emacs, (not vi ;-) ), SPE, boa-constructor, and many more - I like most of them but am really addicted to eclipse + pydev. ... but even without pydev, I would not use java just because of eclipse. hg -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java eclipse
krishnakant Mane wrote: just used the py dev plugin for eclipse. it is great. But isn't support for java better because the eclipse ide can take advantage of explicit type declarations (e.g., for intellisense, refactoring, etc.)? Amir auto indentation and intellisence. and all other things. so now how does it look from this end? python + productivity and eclipse + productivity = double productivity! only problem with the plugin is that I find it difficult to manage the script running. I open a command prompt and run the scripts manually. any suggestion for this. for example I had name = raw_input(please enter your name) and the moment I type the first letter on the keyboard the code execution moves over to the next statement. should it not wait for the return key as it always does? Krishnakant. -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java eclipse
Amir Michail escreveu: krishnakant Mane wrote: just used the py dev plugin for eclipse. it is great. But isn't support for java better because the eclipse ide can take advantage of explicit type declarations (e.g., for intellisense, refactoring, etc.)? Amir The support for Java is light-years ahead. Sometimes I feel that Eclipse is coding for me (quickfix, for instance). There's the fact that Eclipse is developed in Java, so they are eating their own dogfood. That said, the code completion for Python is still in its early stages. There is a lot of room for improvement, even for a dynamic language. Stephen -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java eclipse
Stephen Eilert wrote: The support for Java is light-years ahead. Sometimes I feel that Eclipse is coding for me (quickfix, for instance). Eclipse may be quite a technical achievement, but I found it irritating. Aside from the misuse of screen real-estate, I found that typing two characters and having what seemed like half my source file underlined in red, with multiple messages telling me that I had yet to define or import something or other when what I was about to do was to write the declaration, all conspired to make me want to scream, WTF do you think I was going to type in about five seconds time? Work it out and autocomplete it if you're so damned clever! So, Eclipse certainly has its share of detractors, too. ;-) [...] That said, the code completion for Python is still in its early stages. There is a lot of room for improvement, even for a dynamic language. Agreed. I don't believe in endless refactoring, and I think that's frequently a symptom of using an overly inflexible statically typed language (where it's more like Refactoring - the big R symbolising the seriousness and heavy lifting involved), but there are often times when I've wondered whether something could alert me to obvious breakage, especially after fairly big changes, acting possibly within the editing environment. I suppose pylint and similar tools have been working towards that goal, but I often wonder about producing something more subtle: something which is more clever than looking at modules and globals, and yet doesn't nag you continously about things which you'll discover almost immediately anyway. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java eclipse
Paul Boddie wrote: Eclipse may be quite a technical achievement, but I found it irritating. Aside from the misuse of screen real-estate, I found that typing two characters and having what seemed like half my source file underlined in red, with multiple messages telling me that I had yet to define or import something or other when what I was about to do was to write the declaration, all conspired to make me want to scream, WTF do you think I was going to type in about five seconds time? Work it out and autocomplete it if you're so damned clever! I had exactly the same experience when trying out Eclipse :D I'll stick with good ol' vi. Regards, Björn -- BOFH excuse #227: Fatal error right in front of screen -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java eclipse
hg wrote: Thomas Ploch wrote: Yes, thats true, but since eclipse is resource monster (it is still using java), and some people (like me) don't have a super fresh and new computer If you compare eclipse to VS, it is not that memory hungry And if you compare Saturn to Jupiter, it's not that big. Yet (I believe that) a complete IDE can bring functions that an editor, however powerful, cannot Is there anything _useful_ that it'll bring that a good editor doesn't? e.g. in vim I do get * automatic syntax checking (if I type if a=1: and hit enter, it'll immediately highlight the syntax error) * omni-completion (because Intellisense is trademarked) * refactoring (with BicycleRepairMan integration) * folding (which is more important than the above 3 combined, IMO) * online help (typing cmp( gives me the docstring for cmp in the status line, F1 to view the whole thing) As well as all the basics (tags/class browser/good regex support/syntax highlighting/autoindent/source control integration/etc). I'm not trolling here, I'm looking for interesting new features I can steal. -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java eclipse
[EMAIL PROTECTED] wrote: ... Is there anything _useful_ that it'll bring that a good editor doesn't? e.g. in vim I do get * automatic syntax checking (if I type if a=1: and hit enter, it'll immediately highlight the syntax error) * omni-completion (because Intellisense is trademarked) * refactoring (with BicycleRepairMan integration) * folding (which is more important than the above 3 combined, IMO) * online help (typing cmp( gives me the docstring for cmp in the status line, F1 to view the whole thing) As well as all the basics (tags/class browser/good regex support/syntax highlighting/autoindent/source control integration/etc). I'm not trolling here, I'm looking for interesting new features I can steal. How about we try to find some papers on the subject? Here's one to start things off: http://pag.csail.mit.edu/~akiezun/companion.pdf Amir -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java eclipse
Amir Michail wrote: [EMAIL PROTECTED] wrote: ... Is there anything _useful_ that it'll bring that a good editor doesn't? e.g. in vim I do get * automatic syntax checking (if I type if a=1: and hit enter, it'll immediately highlight the syntax error) * omni-completion (because Intellisense is trademarked) * refactoring (with BicycleRepairMan integration) * folding (which is more important than the above 3 combined, IMO) * online help (typing cmp( gives me the docstring for cmp in the status line, F1 to view the whole thing) As well as all the basics (tags/class browser/good regex support/syntax highlighting/autoindent/source control integration/etc). I'm not trolling here, I'm looking for interesting new features I can steal. How about we try to find some papers on the subject? Thanks. Seems a bit high-level to be very useful, and the plethora of examples around self encapsulate field seem inapplicable, but it makes me wonder if there's anything to be gained by integrating the vim refactoring support with the Vim 7 undo branches. -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java eclips
may be emacs can provide code completion (intellicense) I have not used it so far so can't say. but the main reason I use eclipse is for the above feature. and yes indentation happens in eclipse python-mode so that is not a major feature eclipse offers any way. syntax highlighting is a very common feature again. so if there is an editor which will give me auto code completion, I will happily give up using eclipse. by the way, there is one problem I am finding with eclipse and py dev. the following snippad of code is a mesterious problem. name = raw_input(please identify your self ) if name == tom: print hello and welcome else: print I don't know you just run this script and you will find that you always get I don't know you, even if you entered tom. I then figured out that length of name actually comes to 4 even when I entered tom. that's why it always goes in the else claws. but when I ran the same script from a command promt the length of name returned 3 when tom was entered and the code worked fine. I can't understand why is this happening? why is eclipse putting an extra character in the name variable? Krishnakant. -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java
Jason wrote: Bruno Desthuilliers wrote: With a GUI ? If so, you probably want to check out wxPython or PyGTK (wxPython will also buy you MacOS X IIRC, and wil perhaps be easier to install on Windows). Just a warning: wxPython does operate slightly differently between Mac OS X, Linux, and Windows. The differences are usually minor and easy to clean up in a cross-platform manner, but be aware that you need to test on all platforms that you're going to release on. I don't think one could pretend writing a cross-platform application without testing it on all targeted platforms. (snip) -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java
2006/9/7, Bruno Desthuilliers [EMAIL PROTECTED]: I don't think one could pretend writing a cross-platform application without testing it on all targeted platforms. E.g: while creating a free software, you may not have an Apple computer but you may want to be *possible* to run your program there. You don't test it, but you *think* it runs there. Not everybody has a spare MacOS X to test apps. Of course, if your software *needs* to run in some particular OS then you have to test on it. -- Felipe. -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java
Felipe Almeida Lessa wrote: 2006/9/7, Bruno Desthuilliers [EMAIL PROTECTED]: I don't think one could pretend writing a cross-platform application without testing it on all targeted platforms. E.g: while creating a free software, you may not have an Apple computer but you may want to be *possible* to run your program there. You don't test it, but you *think* it runs there. Not everybody has a spare MacOS X to test apps. Ah, but those with the Intel Apples can run Linux, Windows, and Mac OS X at the same time! *grin* Actually, that's how I'm working on my wx/Python application. I write it under Mac OS X and occasionally pull it into my Windows and Ubuntu virtual machines for further testing. Of course, if your software *needs* to run in some particular OS then you have to test on it. Certainly. And this point should be emphasized for any cross-platform language, especially for folk who may not have done such development before. The write once, run everywhere phrase does have a footnote. Python's documentation is very good at pointing out what is platform independent and what isn't, but other packages are not as thorough. --Jason -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java
Aravind wrote: hi, some of my friends told that python and java are similar in the idea of platform independency. Can anyone give me an idea as i'm a newbie to java and python but used to C++. My idea is to develop an app which can run both in windows and linux. That's true to an extent. Both Java and Python come with extensive standard libraries, providing a useful toolkit for the programmer. Python does have a number of cross-platform GUI toolkits abailable too, including one in the standard library, although WxWidgets (formerly WxWindows) is also popular. I'd say that Python is easier to learn and more productive as a language, but Java has a much larger selection of add-ons and libraries available. I can't give you much more help without knowing what the app will do, and therefore what language features or library/framework support would be helpful. Simon Hibbs -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java
Aravind wrote: some of my friends told that python and java are similar in the idea of platform independency. Similar in goal, but quite different in approach. Python supports lots of platforms and goes to great lengths to offer facades around whatever features a platform does have, so as to offer the same benefits as Unix. Java lives in a virtualised environment where it pretends there aren't any platforms. Perl pretends everything _is_ Unix and falls flat when it isn't. If you can cope with this, Java is simpler and less platform-bound. If you actually need to get OS-level work done, Python is wonderful. You can write stuff that hooks in at a fairly deep level, yet really is portable. -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java
On Wed, 6 Sep 2006 17:53:29 +0530, Aravind [EMAIL PROTECTED] wrote: hi, some of my friends told that python and java are similar in the idea of platform independency. Can anyone give me an idea as i'm a newbie to java and python but used to C++. Well, what Java and Python (and some other languages) have in common is a large standard library. The C++ standard library is smaller, and doesn't cover things like advanced file I/O, networking, concurrency, or user interfaces. You either have to find third-party portable libraries for the things you want to do, or target a specific platform. As a side note, Python differs from Java by happily including non-portable things in its standard library. If Unix people need access to poll(2); fine, then they make it available, even though it won't work on e.g. Win32. And document that it isn't portable. /Jorgen -- // Jorgen Grahn grahn@Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.dyndns.org R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java
Aravind wrote: hi, some of my friends told that python and java are similar in the idea of platform independency. Well, not quite IMHO. Java treats the problem by taking the autistic attitude of pretending the underlying platform doesn't exists - which can be a major PITA. Python is much more pragmatic, and can even offer really strong integration with the platform *without* sacrifying portability - the core language is platform-independant and tries to help you wrinting platform-independant code (cf the os and os.path modules), and platform-specific stuff is usually isolated in distinct packages with a BIG caution note on it !-) Can anyone give me an idea as i'm a newbie to java and python but used to C++. My idea is to develop an app which can run both in windows and linux. With a GUI ? If so, you probably want to check out wxPython or PyGTK (wxPython will also buy you MacOS X IIRC, and wil perhaps be easier to install on Windows). Else (web, command-line, what else ?), you should not have any particular problem as long as you avoid using platform-specific packages and always use the portability helper features (ie os.path etc). Coming from C++, you'll probably need a few days to grasp Python's object model and idioms (Python looks much less like a dumbed-down C++ than Java), but my bet is that you'll be productive *way* sooner with Python, and *much* more productive. My 2 cents, -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java
On 9/6/06, Aravind [EMAIL PROTECTED] wrote: hi,some of my friends told that python and java are similar in the idea ofplatform independency. Can anyone give me an idea as i'm a newbie to javaand python but used to C++. My idea is to develop an app which can run both in windows and linux. IMHO i think that in general Python is better than Java for many reason: 1) Java - statically typed, all variable name must be explicitly declared 1) Python - you never declare anything. An assignment statement binds a name to an object, and the object can be of any type. 2) Java - verbose, too many words than are necessary. 2) Python - concise, clean-cut brevity. 3) Java - not compact 3) Python - Compact stupid example: Java public class HelloWorld { public static void main (String[] args) { System.out.println(Hello, world!); } } Python print Hello, world 4)Python - You can create mixed list 4)Java - You can't 5) Java learning is not fast and easy 5) Python learning is fast and easy also for newbie developers There are other many advantages but it depends from what you want do. -- MorphNon sono i popoli a dover aver paura dei propri governi, ma i governi che devono aver paura dei propri popoli. (V) -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java
http://www.ferg.org/projects/python_java_side-by-side.html -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java
Bruno Desthuilliers wrote: With a GUI ? If so, you probably want to check out wxPython or PyGTK (wxPython will also buy you MacOS X IIRC, and wil perhaps be easier to install on Windows). Just a warning: wxPython does operate slightly differently between Mac OS X, Linux, and Windows. The differences are usually minor and easy to clean up in a cross-platform manner, but be aware that you need to test on all platforms that you're going to release on. For example, MDI apps are anthema to Linux's GTK, so wxGTK uses a tabbed dialog to approximate the same thing. While Mac OS X can associate a Python object (in my case, None) with a hidden top-level tree control node, Windows will throw a C++ assertion. If you are used to using MFC, wxWidgets (which wxPython uses) provides a very MFC'ish programming experience. It's pretty decent, and the wxPython demo provides lots of neat interactive examples. --Jason -- http://mail.python.org/mailman/listinfo/python-list
Re: Python vs. Java gzip performance
Em Qua, 2006-03-22 às 00:47 +0100, Martin v. Löwis escreveu: Caleb Hattingh wrote: What does .readlines() do differently that makes it so much slower than .read().splitlines(True)? To me, the one obvious way to do it is .readlines(). [snip] Anyway, decompressing the entire file at one lets zlib operate at the highest efficiency. Then there should be a fast-path on readlines like this: def readlines(self, sizehint=None): if sizehint is None: return self.read().splitlines(True) # ... Is it okay? Or is there any embedded problem I couldn't see? -- Felipe. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python vs. Java gzip performance
Felipe Almeida Lessa wrote: def readlines(self, sizehint=None): if sizehint is None: return self.read().splitlines(True) # ... Is it okay? Or is there any embedded problem I couldn't see? It's dangerous, if the file is really large - it might exhaust your memory. Such a setting shouldn't be the default. Somebody should research what blocking size works best for zipfiles, and then compare that in performance to read it all at once. It would be good if the rationale for using at most 100 bytes at a time could be discovered. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Python vs. Java gzip performance
Hi Peter Clearly I misunderstood what Martin was saying :)I was comparing operations on lines via the file generator against first loading the file's lines into memory, and then performing the concatenation. What does .readlines() do differently that makes it so much slower than .read().splitlines(True)? To me, the one obvious way to do it is .readlines(). Caleb -- http://mail.python.org/mailman/listinfo/python-list
Re: Python vs. Java gzip performance
Caleb Hattingh wrote: What does .readlines() do differently that makes it so much slower than .read().splitlines(True)? To me, the one obvious way to do it is .readlines(). readlines reads 100 bytes (at most) at a time. I'm not sure why it does that (probably in order to not read further ahead than necessary to get a line (*)), but for gzip, that is terribly inefficient. I believe the gzip algorithms use a window size much larger than that - not sure how the gzip library deals with small reads. One interpretation would be that gzip decompresses the current block over an over again if the caller only requests 100 bytes each time. This is a pure guess - you would need to read the zlib source code to find out. Anyway, decompressing the entire file at one lets zlib operate at the highest efficiency. Regards, Martin (*) Guessing further, it might be that read a lot fails to work well on a socket, as you would have to wait for the complete data before even returning the first line. P.S. Contributions to improve this are welcome. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python vs. Java gzip performance
Bill wrote: The Java version of this code is roughly 2x-3x faster than the Python version. I can get around this problem by replacing the Python GzipFile object with a os.popen call to gzcat, but then I sacrifice portability. Is there something that can be improved in the Python version? Don't use readline/readlines. Instead, read in larger chunks, and break it into lines yourself. For example, if you think the entire file should fit into memory, read it at once. If that helps, try editing gzip.py to incorporate that approach. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Python vs. Java gzip performance
I tried this: from timeit import * #Try readlines print Timer('import gzip;lines=gzip.GzipFile(gztest.txt.gz).readlines();[i+1 for i in lines]').timeit(200) # This is one line # Try file object - uses buffering? print Timer('import gzip;[i+1 for i in gzip.GzipFile(gztest.txt.gz)]').timeit(200) # This is one line Produces: 3.90938591957 3.98982691765 Doesn't seem much difference, probably because the test file easily gets into memory, and so disk buffering has no effect. The file gztest.txt.gz is a gzipped file with 1000 lines, each being This is a test file. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python vs. Java gzip performance
Caleb Hattingh wrote: I tried this: from timeit import * #Try readlines print Timer('import gzip;lines=gzip.GzipFile(gztest.txt.gz).readlines();[i+1 for i in lines]').timeit(200) # This is one line # Try file object - uses buffering? print Timer('import gzip;[i+1 for i in gzip.GzipFile(gztest.txt.gz)]').timeit(200) # This is one line Produces: 3.90938591957 3.98982691765 Doesn't seem much difference, probably because the test file easily gets into memory, and so disk buffering has no effect. The file gztest.txt.gz is a gzipped file with 1000 lines, each being This is a test file. $ python -cfile('tmp.txt', 'w').writelines('%d This is a test\n' % n for n in range(1000)) $ gzip tmp.txt Now, if you follow Martin's advice: $ python -m timeit -sfrom gzip import GzipFile GzipFile('tmp.txt.gz').readlines() 10 loops, best of 3: 20.4 msec per loop $ python -m timeit -sfrom gzip import GzipFile GzipFile('tmp.txt.gz').read().splitlines(True) 1000 loops, best of 3: 534 usec per loop Factor 38. Not bad, I'd say :-) Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Python vs. Java gzip performance
Bill wrote: I've written a small program that, in part, reads in a file and parses it. Sometimes, the file is gzipped. The code that I use to get the file object is like so: if filename.endswith(.gz): file = GzipFile(filename) else: file = open(filename) Then I parse the contents of the file in the usual way (for line in file:...) The equivalent Java code goes like this: if (isZipped(aFile)) { input = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(aFile))); } else { input = new BufferedReader(new FileReader(aFile)); } Then I parse the contents similarly to the Python version (while nextLine = input.readLine...) The Java version of this code is roughly 2x-3x faster than the Python version. I can get around this problem by replacing the Python GzipFile object with a os.popen call to gzcat, but then I sacrifice portability. Is there something that can be improved in the Python version? The gzip module is implemented in Python on top of the zlib module. If you peruse its source (particularly the readline() method of the GzipFile class) you might get an idea of what's going on. popen()ing a gzcat source achieves better performance by shifting the decompression to an asynchronous execution stream (separate process) while allowing the standard Python file object's optimised readline() implementation (in C) to do the line splitting (which is done in Python code in GzipFile). I suspect that Java approach probably implements a similar approach under the covers using threads. Short of rewriting the gzip module in C, you may get some better throughput by using a slightly lower level approach to parsing the file: while 1: line = z.readline(size=4096) if not line: break ... # process line here This is probably only likely to be of use for files (such as log files) with lines longer that the 100 character default in the readline() method. More intricate approaches using z.readlines(sizehint=size) might also work. If you can afford the memory, approaches that read large chunks from the gzipped stream then line split in one low level operation (so that the line splitting is mostly done in C code) are the only way to lift performance. To me, if the performance matters, using popen() (or better: the subprocess module) isn't so bad; it is actually quite portable except for the dependency on gzip (probably better to use gzip -dc rather than gzcat to maximise portability though). gzip is available for most systems, and the approach is easily modified to use bzip2 as well (though Python's bz2 module is implemented totally in C, and so probably doesn't have the performance issues that gzip has). - Andrew I MacIntyre These thoughts are mine alone... E-mail: [EMAIL PROTECTED] (pref) | Snail: PO Box 370 [EMAIL PROTECTED] (alt) |Belconnen ACT 2616 Web:http://www.andymac.org/ |Australia -- http://mail.python.org/mailman/listinfo/python-list
Re: Python vs. Java gzip performance
Bill wrote: Is there something that can be improved in the Python version? Seems like GzipFile.readlines is not optimized, file.readline works better: C:\pypython -c file('tmp.txt', 'w').writelines('%d This is a test\n' % n for n in range(1)) C:\pypython -m timeit open('tmp.txt').readlines() 100 loops, best of 3: 2.72 msec per loop C:\pypython -m timeit open('tmp.txt').readlines(100) 100 loops, best of 3: 2.74 msec per loop C:\pypython -m timeit open('tmp.txt').read().splitlines(True) 100 loops, best of 3: 2.79 msec per loop Workaround has been posted already. -- Serge. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Java
Thanks for these suggestions. To be clear, we already have a Python 2.4 minimum requirement for other reasons, and we are looking for a long-term solution so that as Python advances, the scripting solution can keep up in a timely way. Since the Java code is for a very large, complex application, we need to bring Python to Java rather than Java to Python. We will take a look at some of the other ideas. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Java
JKPeck wrote: Suppose you have an application written in Java, and you want to enable other applications or processes written in Python to communicate with it, i.e., to use Python as a scripting language for the application. On Windows you could do this with COM and various addons such as J-Integra and Mark Hammond's libraries. How would you do this if you want a mechanism that is portable across Windows, Linux, Mac, and Unix? Any ideas? Jython would be a natural candidate, but it is stuck at Python 2.1 and seems to have an uncertain future. JPype or CORBA/ICE. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Java
JKPeck [EMAIL PROTECTED] writes: Suppose you have an application written in Java, and you want to enable other applications or processes written in Python to communicate with it, i.e., to use Python as a scripting language for the application. On Windows you could do this with COM and various addons such as J-Integra and Mark Hammond's libraries. How would you do this if you want a mechanism that is portable across Windows, Linux, Mac, and Unix? Any ideas? Jython would be a natural candidate, but it is stuck at Python 2.1 and seems to have an uncertain future. Thanks in advance. If you need real CPython (e.g., need add-on libraries compiled in C), then XMLRPC is a clean way to make the connection. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Java
JKPeck [EMAIL PROTECTED] writes: Suppose you have an application written in Java, and you want to enable other applications or processes written in Python to communicate with it, i.e., to use Python as a scripting language for the application. On Windows you could do this with COM and various addons such as J-Integra and Mark Hammond's libraries. How would you do this if you want a mechanism that is portable across Windows, Linux, Mac, and Unix? I suppose you could make some layer that sits between JNI and Python's C API. It may be easier to use some slower IPC mechanism like sockets, if you can tolerate that. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Java
JKPeck wrote: Suppose you have an application written in Java, and you want to enable other applications or processes written in Python to communicate with it, i.e., to use Python as a scripting language for the application. On Windows you could do this with COM and various addons such as J-Integra and Mark Hammond's libraries. How would you do this if you want a mechanism that is portable across Windows, Linux, Mac, and Unix? Any ideas? Jython would be a natural candidate, but it is stuck at Python 2.1 and seems to have an uncertain future. Jython 2.1 works great and there is (slow) progress being made in modernizing it. I recommend it. Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Java
For most purposes Jython 2.1 is just fine. The lack of recent features is not a show stopper. What do you need metaclasses? decorators? BTW, there is Jython 2.2 as an alpha release. There are a number of ways you can use Java code through Python. Use JPype to start a Java VM http://jpype.sourceforge.net/ Or compile using GCJ and expose as a DLL/SO or better yet, make a SWIG extension. A good example for this is PyLucene. Python/Java Wrapper Generator http://www.rexx.com/~dkuhlman/generate_wrappers.html simplifies the process. Or use some standard interop mechanism. Write an XMLRPC/SOAP/CORBA and script via Python. This is similar to the COM approach. Or maybe, you can look into XPCOM. I have no experience with it. And finally a bit more perverse approach that I used once. Converted Java bytecode to CIL with IKVM. http://www.ikvm.net/ And then I used Python for .NET (http://www.zope.org/Members/Brian/PythonNet), a really well implemented integration module if I ever saw one, to access the code. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
Peter Hansen wrote: Alex Martelli wrote: One great programming principle is Dont' Repeat Yourself: when you're having to express the same thing over and over, there IS something wrong. I believe the DYR phrasing is due to the so-called Pragmatic Programmers, who are paladins of Ruby, but I also believe it's a principle most experienced programmers could accept. Shall we assume DYR == Do You Ruby? ? wink No. it's the Forth equivalent of DRY: Don't yourself repeat. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.python.org/pycon/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
Mike Meyer wrote: That doesn't sounds like hates to me. More like doesn't like the baggage. mike Yet anonymous functions are nice. Wouldn't it be possible to change the `def` statement to return a reference to the function, and allow omitting the function name thereby bypassing the default binding (current behavior)? Something along the lines of # Current behavior def foo(*args, **kwargs): pass print foo function foo at 0x00FA37B0 # Extended behavior # returns a reference to the function def foo(*args, **kwargs): pass function at 0x00FA37B0 # Anonymous functions def (*args, **kwargs): pass function at 0x00FA3830 foo = def(*args, **kwargs): pass Note that the function wouldn't have it's own name anymore (no more __name__ attribute? Or a blank one?) Since functions can already be defined inline, the only thing that'd be left would be to end the function's definition when the wrapper structure ends: doSomething(def (*args, **kwargs): pass, arg) # End of the function definition at the end of it's argument doSomethingElse(def (*args, **kwargs): ... # Multiline ... pass ...) I'm not too sure about the multi line version (and it looks very ugly with a non-monospaced font), but: Pros (I think): * Backwards-compatible (I think, since the new uses of `def` are currently errors) * Fairly obvious syntax * No `lambda` or `macros` baggage, the new form of def would merely define an anonymous function instead of a named one. * No new keyword, or structure, or idiom * Existing idioms are merely slightly extended without changing their current meaning Cons: * May reduce readability when misused, and may be used in Very Stupid Ways that reduce readability a lot (but then again most construct may be abused in some way), e.g.: doSomething(arg1, arg2, arg3, def foo(a): manipulate(a)) # binds a function to `foo` _and_ sends it to `doSomething` ... [a few lines of code] ... foo(value) # where the hell did that foo come from? * Replaces lambdas with something much more powerful, which may go against the goal of getting rid of lambdas (unless the aforementioned goal is mostly because of the historical baggage of lambdas/macros) Unsure: * Shows that Python is the Ultimate Language, people are not ready yet. * May allow for blocks-like constructs (I'm not sure of the current state of the closures over Python functions though, these may have to be extended to full closures if they aren't) and be considered by some as yielding to the hype (even though the structure itself is more or less 35 years old) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
Xavier Morel [EMAIL PROTECTED] wrote: ... Wouldn't it be possible to change the `def` statement to return a reference to the function, and allow omitting the function name thereby bypassing the default binding (current behavior)? It's _possible_ (doesn't introduce syntax ambiguities) though it does introduce incompatible interactive-interpreter behavior, as you say: # Extended behavior # returns a reference to the function def foo(*args, **kwargs): pass function at 0x00FA37B0 This could be avoided if 'def nameetc' remained a statement like today, and a separate expression 'defetc' returned a function object as a result; this would have the aded plus of avoiding the totally new (to Python) idea of statement returning a value (_expressions_ return a value). Note that the function wouldn't have it's own name anymore (no more __name__ attribute? Or a blank one?) Currently, a lambda has a __name__ of 'lambda'; I'd assume a similar arrangement if 'expression def' took lambda's place. I'm not too sure about the multi line version (and it looks very ugly Yeah, the multiline's the rub -- there's currently no multiline expression, and it does look ugly. * May allow for blocks-like constructs (I'm not sure of the current state of the closures over Python functions though, these may have to be extended to full closures if they aren't) and be considered by some as Python's closures are 'full', but don't allow inner functions to rebind names in the namespace of outer functions. I'm not sure a PEP like this has ever been proposed, but the idea of anonymous def is not new (bar some details of your proposal): if a PEP doesn't exist, you could write one, at least to firm up all details. Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
Alex Martelli wrote: Xavier Morel [EMAIL PROTECTED] wrote: ... Wouldn't it be possible to change the `def` statement to return a reference to the function, and allow omitting the function name thereby bypassing the default binding (current behavior)? It's _possible_ (doesn't introduce syntax ambiguities) though it does introduce incompatible interactive-interpreter behavior, as you say: # Extended behavior # returns a reference to the function def foo(*args, **kwargs): pass function at 0x00FA37B0 This could be avoided if 'def nameetc' remained a statement like today, and a separate expression 'defetc' returned a function object as a result; this would have the aded plus of avoiding the totally new (to Python) idea of statement returning a value (_expressions_ return a value). True that, I didn't even consider the possibility to create an independent expression. And it completely remove the possibility to generate the first con. * May allow for blocks-like constructs (I'm not sure of the current state of the closures over Python functions though, these may have to be extended to full closures if they aren't) and be considered by some as Python's closures are 'full', but don't allow inner functions to rebind names in the namespace of outer functions. I'm not sure a PEP like this has ever been proposed, but the idea of anonymous def is not new (bar some details of your proposal): if a PEP doesn't exist, you could write one, at least to firm up all details. Alex Or maybe start by creating a thread on the subject of an anonymous def expression on this list first? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
Xavier Morel [EMAIL PROTECTED] writes: Mike Meyer wrote: That doesn't sounds like hates to me. More like doesn't like the baggage. mike Yet anonymous functions are nice. Wouldn't it be possible to change the `def` statement to return a reference to the function, and allow omitting the function name thereby bypassing the default binding (current behavior)? [...] # Anonymous functions def (*args, **kwargs): pass function at 0x00FA3830 foo = def(*args, **kwargs): pass This kind of thing has been proposed a number of times, by a number of people. Including me. [examples elided] I'm not too sure about the multi line version (and it looks very ugly with a non-monospaced font), but: The multi-line version is actually a killer problem. If you allow newlines it, you get all kinds of problems with nesting, and the code gets really ugly. If you don't allow newlines, what you have is barely more powerfull than the existing lambda, and would tempt people to write really ugly suites in a single line. Pros (I think): * Backwards-compatible (I think, since the new uses of `def` are * currently errors) * Fairly obvious syntax * No `lambda` or `macros` baggage, the new form of def would * merely define an anonymous function instead of a named one. * No new keyword, or structure, or idiom * Existing idioms are merely slightly extended without changing * their current meaning My version was actually even more backwards compatible - I only returned the value in the case where you were defining an anonymous function. Not that that makes any real difference. Cons: * May reduce readability when misused, and may be used in Very * Stupid Ways that reduce readability a lot (but then again most * construct may be abused in some way), e.g.: It's not clear that there are any useful uses that are readable. I had examples in my proposal, and freely admitted that they were ugly. I may even have mentioned it in the proposal. How about some use cases with example usage? That would show us whether or not there are uses that are both useful and not ugly. Even if the idea is ultimately rejected, the use cases may generate different proposals for solving them that are accepted. mike -- Mike Meyer [EMAIL PROTECTED] http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
While on topic of custom contructs, the topic of syntactic macros has come up in the past. Does anyone know if the dev team ever considered for or against them? My interest in them was renewed when I came across Logix http://www.livelogix.net/logix/ It does not seem very active at the moment nor do they see Python as a long tem platform for their project. Although it already seemed usable in the little programs I tested it with. I keep asking myself why isn't this more popular especially when many prominent Python devs seem to be well aware of Lisp where macros are done right. But then again, Gosling's great Lisp prowess did not seem to transfer into Java at all :-). Won't macros and type inference make Python a Lisp with a syntax that I can stand and libraries that I could use :-) ? Unfortunately there doesn't seem to be a peep from Mike Salib on StarKiller either. Did he move on to other pursuits? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
In article [EMAIL PROTECTED], James [EMAIL PROTECTED] wrote: I keep asking myself why isn't this more popular especially when many prominent Python devs seem to be well aware of Lisp where macros are done right. You have confused many Python devs with Guido. ;-) Guido hates macros. Oddly enough, my impression is that macros are popular only in the Lisp community, and they may well be part of the reason Lisp has never become popular. -- Aahz ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ Given that C++ has pointers and typecasts, it's really hard to have a serious conversation about type safety with a C++ programmer and keep a straight face. It's kind of like having a guy who juggles chainsaws wearing body armor arguing with a guy who juggles rubber chickens wearing a T-shirt about who's in more danger. --Roy Smith -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
Guido's concerns about preserving simplicity resonate well with me. Maybe I am just a kid excited with his new toy. I have always admired macros. Quite a few functional languages have them now. But they have always been in languages with sub-optimal community code base, which meant I never went too deep into any of those languages. So I never used any macro supported language for long to have strong opinions about any one implementation. However, Logix's implementation looks rather interesting. By creating sub languages that are close to but isolated from Python, it does not really mess with the existing language but creates nice oppurtunities to encapsulate boiler-plate code structures when the need arises. I would not necessarily expect such functionality to be in the standard distribution but language oriented programming could just be another jewel in Python's multi-paradigm crown and set it distinctly apart from competitors like Ruby. Do you have any specific comments towards Logix's implementation? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
In article [EMAIL PROTECTED], James [EMAIL PROTECTED] wrote: Do you have any specific comments towards Logix's implementation? Nope. I do know that Guido is generally in favor of Python-like languages, and one of the goals of the AST project was to make that easier. Ditto PyPy. -- Aahz ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ Given that C++ has pointers and typecasts, it's really hard to have a serious conversation about type safety with a C++ programmer and keep a straight face. It's kind of like having a guy who juggles chainsaws wearing body armor arguing with a guy who juggles rubber chickens wearing a T-shirt about who's in more danger. --Roy Smith -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
[EMAIL PROTECTED] (Aahz) writes: In article [EMAIL PROTECTED], James [EMAIL PROTECTED] wrote: I keep asking myself why isn't this more popular especially when many prominent Python devs seem to be well aware of Lisp where macros are done right. You have confused many Python devs with Guido. ;-) Guido hates macros. I vaguelly recall hearing that Guido thought about adding macros to Python, and rejected the idea because he didn't want users to have to deal with compile-time errors at run time. Or something to that effect. That doesn't sounds like hates to me. More like doesn't like the baggage. mike -- Mike Meyer [EMAIL PROTECTED] http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
Macros in Python? (was Re: Python or Java or maybe PHP?)
In article [EMAIL PROTECTED], Mike Meyer [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] (Aahz) writes: In article [EMAIL PROTECTED], James [EMAIL PROTECTED] wrote: I keep asking myself why isn't this more popular especially when many prominent Python devs seem to be well aware of Lisp where macros are done right. You have confused many Python devs with Guido. ;-) Guido hates macros. I vaguelly recall hearing that Guido thought about adding macros to Python, and rejected the idea because he didn't want users to have to deal with compile-time errors at run time. Or something to that effect. That doesn't sounds like hates to me. More like doesn't like the baggage. The smiley applies to that whole bit. Guido's main problem with macros is that there's no clean way to integrate them into a language with strong syntactical structure. He also doesn't like the idea of splitting Python itself into mini-languages (by adding new keywords). He does have a strong distaste for functional programming and sees macros as partly an attempt to expand inappropriate usage of functional programming in Python. Plus your point, that probably covers most of it. -- Aahz ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ Given that C++ has pointers and typecasts, it's really hard to have a serious conversation about type safety with a C++ programmer and keep a straight face. It's kind of like having a guy who juggles chainsaws wearing body armor arguing with a guy who juggles rubber chickens wearing a T-shirt about who's in more danger. --Roy Smith -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
On Tue, 03 Jan 2006 16:25:06 -0500, Mike Meyer [EMAIL PROTECTED] wrote: I vaguelly recall hearing that Guido thought about adding macros to Python, and rejected the idea because he didn't want users to have to deal with compile-time errors at run time. Or something to that effect. That would eliminate eval and exec, too. Regards, Dan -- Dan Sommers http://www.tombstonezero.net/dan/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
Alex Martelli wrote: One great programming principle is Dont' Repeat Yourself: when you're having to express the same thing over and over, there IS something wrong. I believe the DYR phrasing is due to the so-called Pragmatic Programmers, who are paladins of Ruby, but I also believe it's a principle most experienced programmers could accept. Shall we assume DYR == Do You Ruby? ? wink -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
[EMAIL PROTECTED] wrote: Hi everyone, I need to write a web app, that will support millions of user accounts, template-based user pages and files upload. The client is going to be written in Flash. I wondered if I coudl get your opinions - what do you think is the best language to use for the server? Python or Java? And I'm talking scalability, object oriented, development tools etc. Thansk for any idea! I'd love to hear it Happy New 2006, Lior You may want to review some basic evaluations, which can simplify the selection process: (note that this is a work in progress) http://lazaridis.com/case/lang/index.html and some community evaluations: http://lazaridis.com/core/eval/index.html - You have to define your requirements. This way you can manage the complexity of the evaluation. - please feel free to contact me with private email. . -- http://lazaridis.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
Peter Hansen [EMAIL PROTECTED] wrote: Alex Martelli wrote: One great programming principle is Dont' Repeat Yourself: when you're having to express the same thing over and over, there IS something wrong. I believe the DYR phrasing is due to the so-called Pragmatic Programmers, who are paladins of Ruby, but I also believe it's a principle most experienced programmers could accept. Shall we assume DYR == Do You Ruby? ? wink Heh, I _did_ mean DRY of course;-) Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
In article [EMAIL PROTECTED], Alex Martelli [EMAIL PROTECTED] wrote: . [much valuable and correct detail that somehow managed to avoid mentioning Forth or Smalltalk] . . Despite the many differences of detail (mostly, though not exclusively, details of syntax sugar), I consider Ruby and Python to be essentially equivalent *as languages*, so I would suggest you choose on a strictly pragmatical basis -- quality of framework and library, execution speed, tools, books, third-party extensions, c. I see it as a tribute to both . . . I think it's worth repeating, Alex, a point you've made in the past, and that tangentially supports your elided example about c = d unless ...: it's possible to distinguish Python from Ruby in another way. Python is arguably better for group work, or at least more standard for team projects, because it more consistently exposes one correct solution, while Ruby both admits more stylistic variation, *and* encourages construction of novel control structures. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
Cameron Laird [EMAIL PROTECTED] wrote: ... c = d unless ...: it's possible to distinguish Python from Ruby in another way. Python is arguably better for group work, or at least more standard for team projects, because it more consistently exposes one correct solution, while Ruby both admits more stylistic variation, *and* encourages construction of novel control structures. Arguably, yes; but in the end any team (or firm working as a set of fluid teams) that really wants such uniformity (and, it _should_;-), can't rely on just the language, but must supplement it with an internal coding style guide. It will supplement Python's rules by (say) PEP 8 and more rigid choices about capitalization of names (such guidance about capitalization IS embedded in Ruby, btw -- one aspect where Ruby promotes uniformity more than Python does); it will supplement Ruby's rules by similar sets of style constraints. You can construct novel control structures with Python's generators (particularly in 2.5, with the already-accepted enrichments of generator functionality) just as you can in Ruby by passing blocks to methods; whether you DO so on a routine basis (rather than, say, in a few specific common modules that are collectively accepted and maintained by the whole team or firm) does not depend so much on the language, as on the team's/firm's central collective coordination. (Much the same, in spades, could be said of macros in Common Lisp, of course). Yes, Python has a cultural, community value of uniformity -- that may make it easier to convince Python enthusiasts of the need to agree collectively on strict coding-style standards, compared to doing the same convincing on enthusiasts of languages whose cultural values include enthusiastic, exhuberant acceptance of individual variation. But I do not think that such cultural and philosophical differences as they apply to a whole community are more than a secondary factor in determining the culture and philosophy of a specific team, or firm... Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
NOKs [EMAIL PROTECTED] writes: Thanks! That's really useful. I'm not sure if I'm a dynamically typed guy - coming form C#, very strict language, and C++, statically typed, but i definetly searched and see the debate going strong. Not try to start it here, but do you think that statically typed - namely, if I undertood correctly, the fact that there's no need to declare the variables - do you think it has such an effect on productivity? Alex Martelli gave an excellent overview of this question, and his answer (Yes). However, you're in a forum for dynamically typed languages, so that's to be expected. In a forum devoted to statically typed languages, you'll find people who will answer the other way, using their experience and observations as the grounds for that conclusion. What's notably lacking for both camps is any real research on the subject. I've seen it claimed that the SPARK folks have that research, but have been unable to find such. What SPARK papers I have found concentrate more on correctness than productivity: IIRC, they claim millions of lines of production code with no errors. I wanted to point out that there are other more sides to this issue. To start with, when you say declare variables, you really mean declare variables TYPES. There are dynamically typed languages where you have to declare every variable, and others where variables spring into existence when mentioned. Python is halfway between the two, requiring you to declare arguments, and only creating variables when they are assigned to. As Alex mentioned, there are statically typed languages where you don't have to declare the variables types either. I'm just starting to look into this, and I don't know of any that don't require you to declare all your variables as well. Finally, there's a camp that pushes static typing up a notch, practicing what's called Design by Contract (DbC). Languages like Eiffel and D incluce DbC facilities. With these, you add extra code that provides checks on the preconditions to a method invocation, postconditions when it exits, invariants for an object, and various conditions on a loop. This help with the DRY principle, as a good set of unit tests would check all these things before and after each test, so you'd have to code the checks (or invocations of them) for every method invocation in every test. With language support, you only code them once, and the compiler generates code to check them automatically. Again, people who use them swear by them - but have no hard data to back up their believes. mike -- Mike Meyer [EMAIL PROTECTED] http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
On Mon, 02 Jan 2006 19:35:10 -0500, Mike Meyer wrote: What SPARK papers I have found concentrate more on correctness than productivity: IIRC, they claim millions of lines of production code with no errors. Writing error-free code is easy. That's just a matter of incremental improvement of error-full code. Writing error-free code *the first time* is hard. One wonders how many edit-compile-test cycles it takes to get these millions of lines of error-free code. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
Steven D'Aprano [EMAIL PROTECTED] writes: On Mon, 02 Jan 2006 19:35:10 -0500, Mike Meyer wrote: What SPARK papers I have found concentrate more on correctness than productivity: IIRC, they claim millions of lines of production code with no errors. Writing error-free code is easy. That's just a matter of incremental improvement of error-full code. *Proving* that it's error-free is the hard part. Writing error-free code *the first time* is hard. One wonders how many edit-compile-test cycles it takes to get these millions of lines of error-free code. Dunno. But the SPARK folks are doing things where errors kill people (airplane flight control systems being the example that comes to mind). The amount they're willing to spend getting error-free code is probably more than it is for most people. mike -- Mike Meyer [EMAIL PROTECTED] http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
Now I am curious. How do Python 2.5 and Ruby create new control structures? Any code samples or links? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
James [EMAIL PROTECTED] wrote: Now I am curious. How do Python 2.5 and Ruby create new control structures? Any code samples or links? A Ruby example of reimplementing while: def WHILE(cond) | return if not cond | yield | retry | end i=0; WHILE(i3) { print i; i+=1 } Python's a bit less direct here, but: def WHILE(cond): if not cond(): return yield None yield WHILE(cond) i = 0 for blah in WHILE(lambda: i3): print i; i += 1 You need to explicitly guard the condition with a lambda to defer execution (while Ruby's retry repeats deferred execution directly), and explicitly use recursion to loop forever, but conceptually the differences are not all that deep. Of course nobody would write such WHILE functions in either Ruby or Python, since the built-in 'while' statement of each language is perfectly sufficient, but I hope this suffices to show what we mean... Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
Alex Martelli wrote: A Ruby example of reimplementing while: def WHILE(cond) | return if not cond | yield | retry | end i=0; WHILE(i3) { print i; i+=1 } Python's a bit less direct here, but: def WHILE(cond): if not cond(): return yield None yield WHILE(cond) Maybe I misunderstand, but shouldn't this be: def WHILE(cond): if not cond(): return yield None for x in WHILE(cond): yield x After all, the original version only yields two things: None and a generator. (Or is this behavior different in Python 2.5? I hope not...) -- Hans Nowak http://zephyrfalcon.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
In article [EMAIL PROTECTED], Mike Meyer [EMAIL PROTECTED] wrote: . [valuable remarks on scientific evidence and so on] . . Finally, there's a camp that pushes static typing up a notch, practicing what's called Design by Contract (DbC). Languages like Eiffel and D incluce DbC facilities. With these, you add extra code that provides checks on the preconditions to a method invocation, postconditions when it exits, invariants for an object, and various conditions on a loop. This help with the DRY principle, as a good set of unit tests would check all these things before and after each test, so you'd have to code the checks (or invocations of them) for every method invocation in every test. With language support, you only code them once, and the compiler generates code to check them automatically. Again, people who use them swear by them - but have no hard data to back up their believes. . . . ... and it's even possible, as has already been hinted several times in slightly different aspects in this thread already, to combine these concepts to yield, for example, DbC practices with a dynamic language such as Python (Design By Contract for Python, PyDBC, Contracts for Python, ...). -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
Hans Nowak [EMAIL PROTECTED] wrote: ... Maybe I misunderstand, but shouldn't this be: def WHILE(cond): if not cond(): return yield None for x in WHILE(cond): yield x After all, the original version only yields two things: None and a generator. (Or is this behavior different in Python 2.5? I hope not...) No misunderstanding on your part, just my error on untested code -- no changes in Python 2.5 so that yield of a generator means yielding each of its items, my bad, sorry. Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
[EMAIL PROTECTED] wrote: Hi everyone, I need to write a web app, that will support millions of user accounts, template-based user pages and files upload. The client is going to be written in Flash. I wondered if I coudl get your opinions - what do you think is the best language to use for the server? Python or Java? And I'm talking scalability, object oriented, development tools etc. I would personally not consider PHP, in terms of human scalability (if the server needs to grow to substantially rich logic etc). However, Ruby (with Rails, of course, as the server-side framework), Python (many options server-side, from Twisted to Django), and Java (even more options server-side), are, I believe, all worthy candidates. They're all object oriented enough that the fine distinctions among them don't really matter; choice of developer tools is probably widest for Java and least wide for Ruby (and the same for server-side web frameworks), but this cuts both ways (once you've decided on Java as the language you still have many weeks of evaluation to pick tools and frameworks -- if you decide on Ruby, tools and framework are more or less fixed -- Python is in between in both fields). The etc. is where the fun is;-). Java is statically typed, Ruby and Python are dynamically typed: you will perhaps find more flamewars on the web about this one aspect of programming languages than about all others combined. On the basis of extensive personal experience, I'm firmly in the dynamical-typing camp -- firmly convinced that Ruby or Python make developers and teams more productive, or, in other words, that Ruby and Python are higher-level than Java, requiring much less code to implement a given amount of functionality, and developers' productivity is tied mostly to the amount of code they need to develop, debug, maintain (functional specs and user documentation OTOH depend on functionality, not on code needed to implement the functionality, and so don't depend on the choice of implementation language[s]). You'll also find lots of flamewars on each side about side issue such as community, or the quality of programmers that you can easily get for language A vs language B (for just about any choice of A and B;-). I'm not sure how much weight you should give to these considerations, or other soft and fuzzy ones such as the issue of philosophy reflected by each language's design and community. All things considered, I would tentatively suggest Python, but if you examined both languages a little and then picked Ruby (or, given a suitable number of CS PhD's in your development team, Common Lisp, or Haskell, but that's another issue) I'd have no basis for predicting that your choice would be wrong; if you picked Java, I would strongly suspect you made the wrong choice; if you picked PHP, I would personally feel _certain_ that you made the wrong choice;-). And just to give the devil its due, if it's an acceptable trade-off for your server to be shackled to Microsoft systems forevermore, you might even want to consider ASP.NET -- I have no experience with it whatsoever, but some people whose technical judgment I respect do claim it's a good choice. Personally, I would consider the 'strategic' cost (the above-mentioned MS shackes) too high in any case, but only you can make such decisions for your own circumstances. Similarly, Apple's WebObjects have also been widely praised, but they would shackle you to Apple systems (language choice directly supported by Apple for WebObjects is Objective C, Java, and WebScript, a proprietary very-high-level language; but I believe that thanks to PyObjC you could use Python instead or side by side with ObjC, just as, of course, you always have the option of Jython, instead or side by side with Java, whenever you choose a Java-based platform). Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
Thanks! That's really useful. I'm not sure if I'm a dynamically typed guy - coming form C#, very strict language, and C++, statically typed, but i definetly searched and see the debate going strong. Not try to start it here, but do you think that statically typed - namely, if I undertood correctly, the fact that there's no need to declare the variables - do you think it has such an effect on productivity? thanks again! Lior -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Java or maybe PHP?
NOKs [EMAIL PROTECTED] wrote: Thanks! That's really useful. I'm not sure if I'm a dynamically typed guy - coming form C#, very strict language, and C++, statically typed, C#'s pretty close to Java, typing-wise, and C++'s not that far away. I did mention one GOOD statically typed language in my previous post... unfortunately it's one of those for which you need a bunch of CS PhD's -- Haskell. but i definetly searched and see the debate going strong. Not try to start it here, but do you think that statically typed - namely, if I undertood correctly, the fact that there's no need to declare the variables - do you think it has such an effect on productivity? One great programming principle is Dont' Repeat Yourself: when you're having to express the same thing over and over, there IS something wrong. I believe the DYR phrasing is due to the so-called Pragmatic Programmers, who are paladins of Ruby, but I also believe it's a principle most experienced programmers could accept. So, when in Java you have to code: FooBar zap = (FooBar) glak; you KNOW there must definitely be something wrong -- what's the POINT of making you say FooBar TWICE?! There are two ways to let you avoid declaring variables, enabling DYR and enhancing productivity: a. do everything at runtime (as Java will of course do for the check, in the above code, that glak CAN be properly cast to a FooBar); if you do ALL the typechecks at runtime, consistently, you get a dynamically typed language. Dynamically is much the same as at runtime. And it turns out that the only check you really need is: -- when you call bleep.zupdok(), DOES whatever object bleep refer to support a 'zupdok' method that is callable with no args? Runtime typing is enabled, as a productive programming approach, by the fact that, whatever your language's approach to typing, you NEED unit-tests anyway (because they're indispensable to check, necessarily at runtime, a lot of things nobody can check statically)... and, as a side effect, good unit-tests will also duplicate all the (very modest) checks a statically typed language could do for you. b. do everything at compile time. The typesystems of Java, C#, C++ are substantially too weak and inconsistent for that; however, language such as ML (in its several variants) and Haskell prove that a typesystem CAN be designed to allow that. With a properly designed typesystem, you don't NEED declarations either: you code something like (in Python syntax) def f(a, b): return a+b and the compiler deduces a and b must be variables of a typeclass that supports addition, and function f's return value is going to be of the same typeclass as a and b. So, if you later call f(2,3), the compiler accepts that and knows the result must be an int, but if you try to code f('zap', 67) the compiler screams at you because it knows you can't add a string and an int. This type inference is very powerful, and practically equivalent (at least in the Haskell variant, based on classes of types, aka typeclasses, not mere types) to the dynamic typing you get with Python, with further benefits (you get some errors diagnosed faster, without even needing to run your unit-tests, which saves you a few seconds when it happens). Unfortunately, I believe Haskell (and SML, etc) only really suit programmers who have a very particular qualification and mindset -- essentially, higher degrees in mathematics or CS, or the equivalent (some people will have that knack without formal titles, of course, but it's somewhat hard to predict who will). If you have the rare fortune that your programming team can be counted on to be composed only of such people, do give Haskell a try (and don't forget Common Lisp, another language of uncanny power), and you may be even happier than with dynamic language (not necessarily -- a high-profile site has just been recoded from Lisp to Python, essentially for highly pragmatic reasons, for example -- but Python-friendly, Lisp-centered authorities such as Norvig and Graham still think Lisp would have an advantage in such circumstances, assuming of course the pragmatical issues can be swep away in your case). If really good static typing, as in Haskell, is not a real possibility -- that is, in the real world, given the choice between dynamic typing as in Python and faulty semi-static but with some inevitable runtime aspects AND lots of redundancy required of the programmer typing as in, say, Java -- I really have no doubt that dynamic typing increases programmer productivity quite substantially. At Google, I see the same brilliant engineers code in Python, C++, and Java (the three general purpose languages Google uses), and the productivity results that I observe appear to fully confirm my opinions (already formed on the basis of other experiences, both regarding my own coding and that of other programmers, of varying skills, I observed in the past). Once you've decided to give dynamic-typing languages a try, the
Re: python under java
At a command prompt, do which python to see where the python binary lives. Then specify the full path to python in your exec() call, instead of just python. What probably happens is that you don't have the python binary in your PATH when you run exec() from your Java code. Grig -- http://mail.python.org/mailman/listinfo/python-list