Why I Love Python V2

7,082 views

Published on

Bruce Eckel

Published in: Technology, Economy & Finance
2 Comments
12 Likes
Statistics
Notes
  • Hi Sathya, this is a presentation of Mr. Bruce Eckel. He participated at PyconBrasil 2008.
    But in IMHO if I would change, even been a harder transitiion, I would move to Python. Once you have productivity in Python you will know that difference.
    you can watch this full presentation here: http://goo.gl/aJ2CCM
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Couldn't you make similar arguments to go from Java to Groovy? Would be an easier transition than Python.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
7,082
On SlideShare
0
From Embeds
0
Number of Embeds
78
Actions
Shares
0
Downloads
141
Comments
2
Likes
12
Embeds 0
No embeds

No notes for slide

Why I Love Python V2

  1. Why I Love Python …with some essential questions about computing © 2008 Bruce Eckel MindView, Inc. www.mindviewinc.com Write questions on paper
  2. Alas, I’ve spent years of my life here… Why I Love Python ©2008 www.MindView.net
  3. The language you speak affects what you can think By learning multiple languages, I can think more broadly and create better designs
  4. Reduces rigid thinking
  5. Does Language Matter?
  6. Fundamental Question How much safety can we build into a language? What can you actually get? What does it cost? Why I Love Python ©2008 www.MindView.net
  7. Directing vs. Enabling Why I Love Python ©2008 www.MindView.net
  8. More static typing is better It’s a belief Why I Love Python ©2008 www.MindView.net
  9. Why I Love Python ©2008 www.MindView.net
  10. From “Sway”: Fear of loss -> Playing “not to lose” Commitment
  11. Static analysis is very useful But it should be decoupled from the language Allows more experiments; faster addition of new tests Python benefits from more static analysis tools Why I Love Python ©2008 www.MindView.net
  12. Optional Static Typing Scott Meyers: Static typing is for development tools and code generation. ActionScript (the Flex language) is a dynamic language with optional static typing FlexBuilder gives code hinting when you provide type information But you can turn it off whenever you want Something like what Python 3 allows Why I Love Python ©2008 www.MindView.net
  13. ActionScript package com.mindviewinc.functional { public function reduce(a:Array, reducer:Function):* { var result:* = a[0] for each(var item:* in a.slice(1, a.length)) result = reducer(result, item) return result } }
  14. Is Programming Art or Engineering?
  15. Many Companies Desperately Want it to be Engineering Replaceable You
  16. Why I Love Python ©2008 www.MindView.net
  17. The Concurrency Problem Processor speed increases replaced by multiple cores How do we use them? Why I Love Python ©2008 www.MindView.net
  18. Why I Love Python Why I Love Python ©2008 www.MindView.net
  19. What I love most: Python is about ME As if Guido said: “Bruce, what can we do to make your programming experience as easy as possible?” No compromises: it’s all about making me more productive Why I Love Python ©2008 www.MindView.net
  20. A ‘Bout’ of Perl After C++ and Java, seemed amazing Python is executable pseudocode. Perl is executable line noise. Perl is like vice grips. You can do anything with it, and it's the wrong tool for every job (Leaves teeth marks everywhere) Perl is worse than Python because people wanted it worse. Larry Wall, 14 Oct 1998 I would actively encourage my competition to use Perl. Sean True, 30 Mar 1999 Why I Love Python ©2008 www.MindView.net
  21. Python Reduces Clutter Programs are read more than they are written Consistent formatting really is important Readability and compactness Conservation of complexity: Simplicity really does make a difference Consistent use of programming idioms improves understandability Rapid understanding The opposite of “more than one way to do it” Why I Love Python ©2008 www.MindView.net
  22. It doesn’t value performance over my productivity C++: can’t let go of C performance Better than C, sure, but still takes forever to get something working; memory leaks are almost impossible to design out Java: Primitive types require awkward coding (primitives “necessary” for speed) As opposed to Python: everything is an object; escape mechanism for speed: ctypes Why I Love Python ©2008 www.MindView.net
  23. It doesn’t treat me like I’m stupid “Operator overloading is bad because you can make ugly code with it” “finalize( ) does something” “We reviewed Java designs before putting them into the language” AWT & EJB are great, Swing is easy, JavaFX will be great! “Every new feature makes it better! Generics! Closures!” Why I Love Python ©2008 www.MindView.net
  24. Pro Con Garbage collection is now Dumb naming. Java 2 is mainstream 1.2, Java 5 is 1.5. Also Virtual nio and nnio. Naming is machines/bytecode important. interpreters are now Classpath (enough said) mainstream Bad invention in general Unified error handling vs. Added-on features to C++ compensate for bad language design Never admitting that the design was bad in the first place Checked exceptions. Sound good, don't scale Why I Love Python ©2008 www.MindView.net
  25. Con Con Primitives (but they like to Assertions: they're off by call the language quot;pure”) default; you have to turn Knee-jerk threading, them on via a command- which is confusing and line flag too hard to get right. Generics (so-called) w/ Subtle threading bugs erasure. Not really until Java 5 generics, just support for They *had* to rush it out, collection typing. Even now they're one of the architects has monkeypatching the reversed position. language Now closures! But this Faked properties and has rapidly become a events (JavaBeans) mess with lots of push- back, no doubt because of generics. Why I Love Python ©2008 www.MindView.net
  26. Con Con The EJB fiasco (many AWT was too simple & billions lost) bad. Swing is too The JCP: Panders to complex, but Sun has a every special interest and deathgrip on it (sunk cost pushes the results on us model). Now we have (you get 10 days to JavaFX instead of playing comment) well with, say, Flex which has already solved the problems. I could go on. Why I Love Python ©2008 www.MindView.net
  27. Con Pro Self (Everything else) GIL is unavoidable, but Biggest: I trust Guido, the we need a pythonic team, and the community. concurrency model (don't Choices that seem weird just use threads because at first turn out to be good everyone else does). (comprehensions). Need a one-click installer Things that are broken as part of the distribution. get fixed (XML library, An easy_install type of refactoring in Python 3). service should also be I'd like to just work with built in. Python and Flex. Currently, for me, that's the best of all worlds. Why I Love Python ©2008 www.MindView.net
  28. It doesn’t make assumptions about how we discover errors Is static type checking really the only way to be sure? Lack of good static typing in pre-ANSI C was certainly heaps of trouble Doesn’t mean it’s the best solution Errors discovered with real data seem to me to be the hardest to find statically Why I Love Python ©2008 www.MindView.net
  29. Marketing people are not involved “Java is flawless” Of course, Python isn’t immune Spam, spam, spam, spam … Why I Love Python ©2008 www.MindView.net
  30. I don’t have to type so much … And I don’t have to wade through so much code when I’m reading But the right typing Not obscure like APL Not endlessly inventive like Perl or FORTH Why I Love Python ©2008 www.MindView.net
  31. The clean design of the language encourages clean library design: import feedparser rss = feedparser.parse('myurl.rss') for entry in rss['entries']: print entry['link'], entry['title'], entry['summary‘] Why I Love Python ©2008 www.MindView.net
  32. My guesses are usually right Most things in Java require me to look something up I can remember many Python idioms because they’re simpler One more reason I program faster Why I Love Python ©2008 www.MindView.net
  33. I can remember this: file(quot;Myfile.txtquot;) I always have to look this up: import java.io.*; BufferedReader in = new BufferedReader( new FileReader(quot;Myfile.txtquot;)); Why I Love Python ©2008 www.MindView.net
  34. #1: Python lets me focus on concepts No stumbling through Java designs, fighting with C++ compilations or run-time bugs. Why I Love Python ©2008 www.MindView.net
  35. Duck (Structural) typing Only constraints on an object that is passed into a function are that the function can apply its operations to that object def sum(arg1, arg2): return arg1 + arg2 print sum(42, 47) print sum('spam', 'eggs') If it walks like a duck, and talks like a duck… Why I Love Python ©2008 www.MindView.net
  36. Duck Typing in C++: Templates #include <string> #include <iostream> using namespace std; template<class A, class B, class R> R sum(A a, B b) { return a + b; } int main() { string a(quot;onequot;), b(quot;twoquot;) cout << sum<string, string, string>(a, b) << endl; cout << sum<int, int, int>(1, 2) << endl; } Why I Love Python ©2008 www.MindView.net
  37. Duck Typing in Java Reflection, possibly with interfaces Why I Love Python ©2008 www.MindView.net
  38. interface addable { Object add(Object b);} class X implements addable { public Object add(Object b) { return new Object(); // Test } } class AddableNotFoundException extends Exception {} public class DuckTyping { public static Object sum(Object a, Object b) throws AddableNotFoundException { Class[] intfs = a.getClass().getInterfaces(); for(int i = 0; i < intfs.length; i++) if(intfs[i] == addable.class) return ((addable)a).add(b); throw new AddableNotFoundException(); } public static void main(String[] args) throws Exception { X a = new X(); X b = new X(); Object c = sum(a, b); } }
  39. Duck typing isn't weak You write what you want to do, let Python worry about how Argument against dynamic typing: “errors won’t be found” Like in pre-ANSI C (had no rules) As long as rules are enforced sometime, you’ll find the errors Heresy: run-time is better than compile time Why I Love Python ©2008 www.MindView.net
  40. Performance issues Machine Performance vs. Programmer Performance Most of the time, which is really more important? Python 2.5 cytpes easily connect to dlls pp and similar solutions for multiprocessor machines and machine clusters Why I Love Python ©2008 www.MindView.net
  41. Life is Short (You Need Python) Why I Love Python ©2008 www.MindView.net
  42. Questions

×