Think Python
An anonymous reader writes "In a neverending effort to spread the word about free quality online programming books, here is a Python programming book. 'How to Think Like a Computer Scientist: Learning With Python', by Allen B. Downey, Chris Meyers, and Jeffrey Elkner is a copylefted work available in multiple formats at Green Tea Press: HTML , PDF, LaTeX. Compliments of the online books what's new page."
Am I the only person who thought the title of the book was "How to Think Like a Computer Scientist: Learning With Monty Python"?
Man, it's early.
True 'Computer Science' covers a lot of areas, mostly fundemental, including Computer Theory, Electronics, Mathematics, Logic, Processor Theory and Design, to name but a few.
The majority of today's CS Courses seem to fall into two broad categories, 'Software Development', and 'Systems Management'. Whilst these are both elements of computer science, they do not encompass computer science as a whole.
Universities are more and more often cutting out the core Computer Science components of their courses, such as Electronics and Computer Thery, which is a shame - whilst the courses leave graduates with an understanding of 'How' to do certain tasks, they are left with no understanding of 'why' they are done that way, because they have no real understanding of how the Computer Systems they are carrying out tasks on actually perform their functions.
NDFSM's are important, Karnaugh Maps are important, Understanding the CPU F/E Cycle is important too - bring back real CS to our Universities!
Disclaimer: I meant what I thought, not what I wrote! What? You can't read my Mind? Oh dear!
This book doesn't strike me as a book on how to think like a Computer Scientist, except insofar as Computer Scientists generally make lousy Software Engineers. There are no descriptions of the advantages of object oriented programming, discussions of theoretical topics, and in general very little encouragement to view programming as a science. Basically, this appears to be just a book on the Python language, written for someone who has never programmed before. That's a fine thing, don't get me wrong. My brief look even makes me think it could be an effective example of such a book. At the very least, I think it's hyped wrong.
However, from a software engineering point of view, I find it damning that the book forgoes any explanation of the practice of, or motivation for, writing maintainable code. I consider that unforgivable in a beginning programming book. You absolutely have to impress on newbies early the importance of documentation, sensible structure, logical variable naming, good class hierarchy, etc.
I consider this especially true for Python, which is an interpreted non-declarative language (making maintainabilty all that more important). Python is, conversely, also especially well designed as a platform where such concepts could be taught. It largely overcomes the occasional weaknesses of its design philosophy by consciously including language features such as built in support for docstrings, well crafted namespaces, modules as first-class citizens, etc.
Yet, these language features are barely given a nod in this book.
It's books for existing programmers that can afford to skimp on these areas.
Feynman doesn't have a fucking clue about anything outside his own field. He's a prime example of one of these arrogant beings who believes nothing is more important than their field of choice.
Of course Computer Science is a science - take any introductory CS course and you will come across many formal theorems and hypothesis-based discoveries.
Examples:
Halting problem - this is essentially derived logically from basic premises.
Neural networks - these are constantly the subject of scientific study in much the same way as geneticists study rats.
That's because it's not about Software Engineering, you fool. It's about Computer Science.
Software Engineering is essentially the application of CS to real world projects - and the current fashions in SE should be a separate course entirely. It's more about psychology and HR than it is about Computer Science.
From the opening section of each book: 1.1 What is a programming language?
Java is an example of a high-level language; other high-level languages you might have heard of are Pascal, C, C++ and FORTRAN.
Python is an example of a high-level language; other high-level languages you might have heard of are C, C++, Perl, and Java
Both C++ and Pascal are high-level languages; other high-level languages you might have heard of are Java, C and FORTRAN
C, a language without file i/o, without bound checking, and with direct access to ports is high-level? If you say the libraries chucked into a C load makes it so... Then Assemebler is a high-level language, too.
Last I heard was Binary Code=0, Assem=1, C=1.5, Fortran, Cobol, & Basic were about 3, ADA, C++=5.
Perl was not even in the picture, because it was scripting language
Also high-level languages does not equal easier code or does not make it faster code... It does makes more strict to code, more following the limited ways the authors of the langauge thought you should think (like the use of GOTOs :-). Low-level languages allow the coder the freedom to get the job done and not comprise the functions to limits of the authors, and it requies the coders to truely think like computer sceincist. Look at ADA for what is wrong with really high-level langauge. See how limiting the langauge can be made. And how much time is need to see up the coding effort.
PS: maybe these are great books, but I stopped reading there, because how can it teach to "Think like Computer Sceincist" when it does not know about the basics of computer sceince?
While Python is my favourite language, I think it's rather silly to teach Computer Science and especially basic algorithmics with a language that doesn't have pointers.
At low level, pointers are everything, and low level is what you want to teach when you're teaching basic data structures and algorithms. There's simply no point in demonstrating list implementation with an interpreted language that has very efficient native lists, dictionaries, etc. C/C++ or Pascal are much better for that; with them you can teach real implementations, not toy ones.
On the other hand, Python might be ideal for teaching advanced algorithms such as sorting and string algorithms, as those are more "high-level" problems and low-level pointer-messing is no longer needed nor desired. Python has very beautiful string and list operations, which make such algorithm implementations cleaner.
Also, Python might be ok for the very first Basics of Programming course with respect to pointers, as they don't really teach any algorithmics there. However, the weak typing (very late binding) would be a problem in this case. Beginners will have enough trouble understanding the language without the need to handle implicit types. I'd very much suggest a strongly typed object-oriented language such as C++, Java, or Eiffel, where the types are always explicit. For an algorithms course this isn't so much a problem.
For some classes, such as AI, there's simply no winner for Prolog, and perhaps Lisp, but many Python features such as easy string manipulation and other middle-level data structures make it temptating for many subjects such as Automata and Formal Languages. It would be interesting to have a good Python interface to a Prolog interpreter; one that is well integrated with the syntactic philosophy of Python.
Hmm... to be honest... the "Feynman Lectures on Computation" are just about as absurd as the "Goedel Lectures on Biochemistry" (these don't really exist... I'm just being sarcastic). The original poster's comments on Feynman had some merit.
The phrase that you quote here displays a mind-boggling ignorance about exactly what "Computer Science" is. Software Engineering is, indeed, "like Engineering" but there are many branches of Computer Science that deal *purely* with the abstract. I do Formal Language Theory and Automata Theory for a living and I just can't see how these fields are about "getting something to do something". Feynman, like most people, has missed the science for the telescope.
The real joke is that things like the Church-Turing thesis could not possibly be MORE about "natural objects". In the abstract, I can define a machine that can solve the halting problem. Heck, I can define a machine that solves any problem I want! The Church-Turing thesis tells us about a PHYSICAL limitation on computing. In this universe, you can only build a machine that will compute *these* functions.... But what if I live in a universe where time has no meaning? All of a sudden, I get a *very* different Church-Turing thesis.
There is no question that Feynman had some brilliant insights in physics, but I have to admit that when I read the Lectures on Computation, not only did I lose a small amount of respect for him... I found myself actually outraged. Many intelligent people will read these lectures and believe them... I mean, after all, they're written by Feynman, right?
Computer Scientist's have enough trouble trying to explain to people that, no, we don't just sit around installing Windows network drivers all day without a respected and intelligent person like Feynman adding to the problem.
After having a quick look at bits I'm qualified to assess (I'm not a Python programmer, but do have plenty of background in CS, C++ and other related topics) I'm not convinced at all that I'd want to learn from this book.
Much of the preface by Jeff Elkner basically compared C++ to Python and has a go at the deficiencies of C++. It would be more convincing if he knew the return type of main(), the name of the standard header <iostream> and what a statement was. Three fundamental mistakes just in discussing "Hello, world!" is not a good sign for the author's level of knowledge and understanding.
Trying to put aside my bias, as I like C++ as a practical language, I examined the appendix on creating a UDT for fractions to form a second opinion. Here, they do the obvious simple things to create a rational number class, and nowhere do they make the basic sanity check that your denominator is not zero. Surely one of the basic tenets of OO theory is that you always maintain your class' invariant properly? Their class may be a fine demonstration of Python's OO features -- I don't know, I'm not familiar enough with them to judge -- but it's a lousy demonstration of either good CS or good OO.
From these observations, I have to ask whether I'd actually want to learn Python from this book. If I do, how will I ever have any faith that what I've learned is correct and in good style?
If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
You have failed to understand the point of Computer Science (pun intended). Python is a terrific language for teaching CS because it has the basics of discrete structures: lists, maps (in Python, called dictionaries), tuples, and atomic data types such as strings, ints, and reals. That's all you need.
There's really nothing you can't do once you have lists and maps. Don't object that you can't have O(1) access-time arrays -- you can do that with a map.
I challenge you to describe any algorithm at all that can't be implemented without pointers. If you think you need pointers, you just aren't thinking like a computer scientist.
For some classes, such as AI, there's simply no winner for Prolog, and perhaps Lisp
In general, you are absolutely correct. Of course, this is opinionated and others may disagree. But remember, you can use any Turing-complete language to simulate any other Turing-complete language (that's the entire definition of Turing-complete). Which means I can write a C interpretter in Prolog if I want (and I'm feeling particularly masochistic), and therefore I can simulate pointers using Prolog.
Oh, but you cry "That can't possibly be efficient!" Right again. But you've again missed the point of Computer Science. CS is about efficient algorithms, not efficient programs. That's something we leave to the software engineers and other "implementors." Us CS freaks think about what can be done, we don't actually do it ;-)
That said, I don't know if I would teach a begining computer science course in python. At my University, our general intro to CSE involves a two class series teaching generic basic theory wrapped around a programming language. We used to teach them with C and C++ but just recently moved to Java. I have been a TA for these classes before. Based on my experiences, I think there are both pluses and minuses to the idea of teaching these classes in python.
Benefits:
- Python is extremely easy to learn, as mentioned before. Much easier than C, C++, or Java.
- Python works really well with Tk, which would make it easy to build out skeleton code (multiplatform skel code at that) for the students using windowing and graphics. Students are 100% happier if they can see what they're working on reflected graphically. Makes it more fun to show off. This is why our projects usually include basic games.
- BASIC Python is truly, completely, multiplatform, working identically on Mac, Win*, and *nix. Some specialized functions in modules don't support all platforms, but nothing that would be important to a begining student. Support issues would be MUCH simpler than C or C++. God, we had huge headaches trying to support MSVC, CodeWarrior, CodeWright, Borland, etc. . .
- There is a great installer script available that will build python modules into either standalone exe's or distributable directories. (Available here if you've never seen this before)
But, there are also some downsides that would have to be weighed. These are:Looking away from basic intro classes, python is great to know. I did a lot of AI code sketches in python, and have used it to slap together simple programs at work. However, I would consider it a tool to be learned after the basics have been beat in. If I had learned python first, it would be a lot harder to force me to do everything in C later.
-s
- - - - - - - -
Don't worry, being eaten by a crocodile is just like going to sleep in a giant blender.
If you actually look at the book in question, you'll see that the original poster was correct: it's not about computer science at all. It's a Python programming book with a marketing angle relating it to computer science.
If you really want a book which teaches "How to Think Like a Computer Scientist", try SICP. For a good summary of the book, see this comment from the recent "Best Computer Books" article.
At low level, pointers are everything, and low level is what you want to teach when you're teaching basic data structures and algorithms.
Conceptually and from a computer science perspective, the object references present in languages like Python, Java etc. are equivalent to pointers in all the ways that matter for representation of data structures and algorithms. In the academic community and elsewhere, it's generally considered beneficial to teach such things without reference to the machine pointers which you're referring to, since machine pointers carry a lot of baggage that's unrelated to the abstractions involved in data structures and algorithms.
There's simply no point in demonstrating list implementation with an interpreted language that has very efficient native lists, dictionaries, etc.
To refute this, let me offer a tutorial: A Gentle Introduction to ML. If you work through this tutorial, you'll very soon begin implementing functions in the ML language for basic list operations and the like - functions that already exist in the language. And guess what: the implementations that the beginner typically comes up with in that tutorial are very close to the actual implementations that ML uses - the tutorial gives some examples of actual implementations for comparison.
This high-level operation doesn't even cost much -languages in the ML family, including OCaml, regularly are top performers - see e.g. Doug Bagley's language shootout. They can perform on par with languages like C because their type systems allow sophisticated compile-time optimizations to be performed, and their high-level abstraction features are supported by optimizations such as tail recursion.
C/C++ or Pascal are much better for that; with them you can teach real implementations, not toy ones.
If you believe that C/C++ and Pascal are good languages for teaching computer science, you don't know much about modern computer science. All three of those languages have very weak type systems and lack basic features that allow the construction of high-level abstractions.
Pascal is all but a dead language in the CS community nowadays. The primary use for C is as a decent portable assembler. Learning C has very little to do with computer science, and absolutely nothing to do with teaching computer science concepts.