why i love python
DESCRIPTION
I love Python, but I didn't make this. It was created by someone named Bruce.TRANSCRIPT
Why I Love Python ©2001 www.BruceEckel.com
Why I Love Python© 2001 Bruce Eckel
MindView, Inc.Training & Consulting5343 Valle VistaLa Mesa, CA [email protected]
www.MindView.netftp://www.mindview.net/pub/eckel/LovePython.zip
Why I Love Python ©2001 www.BruceEckel.com
The language you speak affects what you can think
Python is what I use the most to solve my own problems (I think better)
Including CGI/e-commerce with MySQL
5-10 times productivity (really!)
I’ve been trying to figure out how to explain “why” to people
Top 10 reasons I’ve come up with
And a few other interesting topics
Why I Love Python ©2001 www.BruceEckel.com
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 ©2001 www.BruceEckel.com
My Language History
Age 13: BASIC on HP1000(HOSRAC.BAS is invented)Age 19: APL for physics. The concept of a "terse language".Basic again, survey courses, Pascal et al.Age 21: Computer engineering, Chips + assembly languageAge 22: I begin to understand the value of high-level languagesAge 24: Database programming AppleII Basic
Age 25: Graduate (finally) with MS, discover C, work in embedded programming (in assembly).
I am my own C compiler
Age 26: Basic (again) for data analysis and control of wind-tunnel experimentsAge 27: Embedded C development. Program 4-bit Harvard architecture machine in assembly.
Wrote Assembler in GNU-Lisp. Created (?) primitive C++ mode for Gnu-emacsStart writing for Micro Cornucopia
Age 29: University of Washington School of Oceanography with Tom Keffer.
Chose C++ over Objective-C for openness.Published “Computer Interfacing with Pascal & C”
Age 32: Publish “Using C++”Join ANSI C++ Committee
Later: “C++ Inside & Out”, “Black-Belt C++” (edited), “Thinking in C++”
Java: “easy translation from C++”Actually took two years
Thinking in PythonResearch mode now, web page with notes at www.BruceEckel.com
The other books and languages wrapped around me like Jacob Marley’s chains…
Why I Love Python ©2001 www.BruceEckel.com
A ‘Bout’ of Perl
After C++ and Java, seemed amazingPython 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 ©2001 www.BruceEckel.com
Top 10 Reasons Why I Love Python
Why I Love Python ©2001 www.BruceEckel.com
10. Reduced Clutter
Programs are read more than they are writtenXP: Consistent formatting really is important
Readability and compactnessPart of “conservation of complexity”
Consistent use of programming idioms improves understandability
Rapid understandingThe opposite of “more than one way to do it”
Why I Love Python ©2001 www.BruceEckel.com
9. It’s not backward-compatible in exchange for pain
C++: Backward compatible with C – its strength and its baneJava: more or less with C++ syntax (not too bad, but a lot of typing)Perl: compatible with every hacky syntax of every Unix tool ever inventedC# and .NET: backward compatible with previous Microsoft marketing campaignsJavascript: not even compatible with itself
Why I Love Python ©2001 www.BruceEckel.com
8. 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 (extension) for speed
Why I Love Python ©2001 www.BruceEckel.com
7. 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”
“Java has an open development process”
Why I Love Python ©2001 www.BruceEckel.com
6. I don’t wait forever for a full implementation of the language
Some features we invented in the C++ committee are still not implemented
Unused features don’t get tested;circular problem
Many C++ vendors say “it’s hard, andno one’s asking for it.”
Why I Love Python ©2001 www.BruceEckel.com
5. It doesn’t make assumptions about how we discover errors
Is strong 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
(More about this later)
Errors discovered with real data seem to me to be the hardest to find
Why I Love Python ©2001 www.BruceEckel.com
4. Marketing people are not involved
“Java is flawless”
Microsoft “Visual” “C++”Microsoft happens
Of course, Pythonisn’t immune
Why I Love Python ©2001 www.BruceEckel.com
3. I don’t have to type so much
… And I don’t have to wade through so much code when I’m reading
Conservation of complexity: simplicity really does make a difference
But the right typingNot obscure like APL
Not endlessly inventivelike Perl or FORTH
Why I Love Python ©2001 www.BruceEckel.com
2. My guesses are usually right
I still have to look up how to open a file every time I do it in Java
In fact, 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 ©2001 www.BruceEckel.com
1. Python lets me focus on concepts
No stumbling through Java designs, fighting with C++ compilations or run-time bugs.
Why I Love Python ©2001 www.BruceEckel.com
Python and “The Tipping Point”
Email: possible to carry on dozens of conversations by paper mail, but you don’t.
Automating Everything:Possible to write programsto automate every task. But youdon’t.Python makes it easy enoughGreat with Gnu make (myCD build system)
Why I Love Python ©2001 www.BruceEckel.com
Weak typing
Only constraints on an object that is passed into a function are that the function can apply its operations to that objectdef sum(arg1, arg2): return arg1 + arg2
print sum(42, 47)print sum('spam', 'eggs')
“Weak” sounds bad
Why I Love Python ©2001 www.BruceEckel.com
Weak 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("one"), b("two") cout << sum<string, string, string>(a, b) << endl; cout << sum<int, int, int>(1, 2) << endl;}
Why I Love Python ©2001 www.BruceEckel.com
Weak Typing in Java
Reflection, possibly with interfaces
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 WeakTyping { 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); }}
Why I Love Python ©2001 www.BruceEckel.com
Why weak typing isn't weak
Upcasting becomes meaningless
You write what you want to do, let Python worry about how
Argument against weak 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 ©2001 www.BruceEckel.com
Performance issues
Machine performance vs. Programmer Performance
Most of the time, which is really more important?
C++ is naturally faster -- or is it?with IOStreams, not always
Why I Love Python ©2001 www.BruceEckel.com
Future Impact
Programmer productivity is the most important thing
Python excels at rapid creation of maintainable code
To increase performance, throw hardware at the problem
Multiprocessor machines & stacklessSeems like an important direction, even to the point of justifying core language changes
Why I Love Python ©2001 www.BruceEckel.com
Other Languages
C# bores me. Removes the interesting/useful features of both Java & C++. I’d use one of those languages first.
Ruby. I’ll wait and see, but my impression is that it doesn’t do more for me than Python (or not more enough).
Why I Love Python ©2001 www.BruceEckel.com
NerdsOnBicycles.com
On the New Zealand bike trip, Bill Venners & I decided it would be a good idea to host technically-themed bike tours
Run by a professional company with all the amenities, the “sag wagon” etc.
We thought a Python-themed trip might be an interesting beginning
Grand Tetons? Send email if interested
Why I Love Python ©2001 www.BruceEckel.com
Life is Short(You Need Python)
OR:
No Warrantee
Not Fit for Any Particular Purpose(You Need Python)