Slashdot Mirror


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."

25 of 200 comments (clear)

  1. There are other books in this series by Tonetheman · · Score: 3, Informative

    This books has been translated to other programming languages (like C++ and Java)... so if Python is not for (it should be) you can read those too.

  2. Thanks to Online Books by Taco+Cowboy · · Score: 5, Interesting



    Thanks to Copylefted Online Books, I now can read the books before I buy.

    On my bookshelf, seven of the books were bought after I read their online version.

    I live in a third world country where there is no Towers bookstore, nor Borders, nor Barnes - there is NO WAY for you to know how good a book is without first buying the book - the bookstore here do NOT allow you to read the book !

    The idea of Copylefted books really help me, and many others who are in the situation of buying books not knowing if the books are good or not.

    Thanks again !

    --
    Muchas Gracias, Señor Edward Snowden !
    1. Re:Thanks to Online Books by Gaetano · · Score: 3, Interesting
      Another option for you may be to subscribe to a service like Safari from oreilly. I subscribed and use it daily. Basicly you can check out books from oreilley and several other publisher for 45 days at a time (when you can then check them back in if you want another book).

      Its not too expensive compared to how much technical books cost in some countries outside the US I have visited. The Safari service is about 10 dollars a month (US) for 5 books and 15 dollars for 10, and so on.

  3. Question by citizenc · · Score: 3, Insightful

    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.

  4. Re:How to think like a computer scientist by affenmann · · Score: 4, Interesting

    I think part of the problem is the name `Computer Science', which gives a wrong impression of what the core of the poodle really is. That's like calling Astronomy `Telescope Science'. I have met so many people who didn't want to study CS at all - they just wanted to learn `installing Linux and setting up a web server'. This has regrettably put universities under pressure to change their curriculum...

    Some universities (eg. Edinburgh) have started calling it `Informatics', which is much more appropriate. (In fact in Germany, and probably elsewhere, it was always called `Informatik'.)
    Maybe there should be CS *and* Informatics.

    Uhm, guess that was offtopic.

  5. Dive Into Python by jonwiley · · Score: 4, Informative

    Another excellent free book for Python is Dive Into Python by Mark Pilgrim. It is available in HTML, PDF, Word 97, Windows Help, plain text, and XML formats.

    This book has plenty of examples and pointers to further reading on each subject. It features good layout, use of colors, and typography which makes for easy reading and comprehension.

  6. Re:Where are they ? by JonahC · · Score: 4, Informative
    You can go here to get a list of all the available versions in the "How to think like a computer scientist" series:

    http://www.ibiblio.org/obp/thinkCS.php

    I was actually quite surprised to find this article on slashdot. You see, I'm the author of the Perl script which converts the LaTeX source to HTML. I hope nobody finds any blatant problems with the online book websites...

  7. How about how to think like a Software Engineer? by hacksoncode · · Score: 5, Insightful
    I should probably quit whining and write my own copyleft book, but I skimmed through this book, and I'm not all that impressed.

    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.

  8. Did the author get paid? by AmericanInKiev · · Score: 3, Interesting

    Does anyone know if the author of the book gets paid by Green Tea for donating or "copylefting" the book?

    I'm working on the theory of collecting tax deductions for copylefted art, and this contribution is a great example because it closely resembles historically donated items. If the author donates the artwork to the right organization - he could by my reading of the IRS be paid in tax deductions.

    Does anyone know of cases in Open Source / Copyleft where tax deduction are being used to help cover expenses?

    I'm sure that the competition - i.e. Microsoft uses every tax deduction in the book. Are Open Source contributers playing by the same rules - or are we handicapping ourselves by ignoring the tax benefits of donation?

    If anyone can provide examples of copylefted donations and how you documented it for tax purposes - I'm interested.

    I believe there are Billions of dollars in potential government funding just waiting to be collected by Open Source artists. Lets go get it!

    AIK

    1. Re:Did the author get paid? by sheldon · · Score: 3, Interesting

      I believe what you are on is the road to jail for tax evasion.

      The IRS does not allow you to donate your time and deduct your perceived cost from your taxes. It's highly illegal because it is quite obviously prone to abuse.

      So in the case of your artwork example. If you go out and buy a painting for $20,000 and then donate that painting to a non-profit charity, you may deduct the $20,000 or whatever the current market value is of that painting.

      However if you go out and buy a canvas and some paints and then make your own painting to give to charity. The only thing you may deduct is the cost of the canvas and paints, i.e. the supplies. Now if you sold the painting at auction for $20,000 and then proceeded to give that $20,000 to charity, you may deduct the $20,000, but you're also showing the $20k as income so it's a net-zero-sum game.

      The same is going to be true of a book.

  9. Pointers required by magi · · Score: 3, Insightful

    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.

    1. Re:Pointers required by cheezedawg · · Score: 5, Insightful

      I think it's rather silly to teach Computer Science with a specific programming language at all. Computer Science is not about teaching people how to program.

      To me, Computer Science is a very cool blend of:
      - Discrete mathematics
      - Computation theory
      - Linguistics
      - Complexity theory
      - Logic
      - Probability

      None of these rely on programming at all, let alone a specific language or whether that language has pointers or not. Programming is only an application of Computer Science.

      You gave example of an AI class- to me, the core of AI is learning about first-order logic and predicate calculus, searching and graph traversal heuristics, reasoning, and natural language processing. I know this list isn't complete, but the point is that these concepts are for the most part independent of programming. Sure, you can start off by teaching somebody a specific implementation in Lisp or Prolog, but then they only know program AI in Lisp instead of how to apply AI concepts in any setting.

      --
      "The defense of freedom requires the advance of freedom" - George W Bush
  10. Re:Computer 'Science'? by Lictor · · Score: 4, Insightful

    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.

  11. a review by bcrowell · · Score: 4, Informative

    I've written a review of this book on The Assayer. The book is self-published (the authors run Green Tea Press), and one of the things people don't realize about self-publishing is how hard it is to attract reviews. (Actually, it's hard in ordinary publishing, and even harder in self-publishing.) Without reviews, you don't get much credibility. So if there's a free book in The Assayer's database that you've read, please write a review!

  12. Misnamed book by Animats · · Score: 3

    "How to think like a computer scientist" is a bit much for this book. It's an introduction to Python programming, and at best, a mediocre one. It's aimed at the overpopulated "first book on programming" market. The book reads like a BASIC programming manual of 25 years ago.

  13. You miss the point(er) by pclminion · · Score: 4, Insightful
    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.

    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 ;-)

  14. Re:Computer 'Science'? by hysterion · · Score: 4, Informative
    Those are hard things to tell an Caltech Alumnus :-)

    No doubt, Feynman was a very, very good physicist. But he was also a genius at self-promotion, and his cult has gone way overboard as a result. It's well-established by now that some of the ideas he's famous for were first published by others.

    (Not that he wasn't honest about it sometimes. I think he's on record, for instance, crediting Stueckelberg for the renormalizion of electrodynamics, and for the idea that positons are electrons travelling backwards in time. See e.g. this timeline, or the last chapter of this book.)

  15. Python is a GREAT language, but. . . by stevarooski · · Score: 4, Insightful
    Python is an excellent languange that I've been using for about 8 months now. Anyone who has ever programmed before can pick it up easily just by reading the [very thorough] documentation at python.org. It also has an rabid support base via newsgroup, who are excellent at answering questions.

    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:
    1. Python is extremely easy to learn, as mentioned before. Much easier than C, C++, or Java.
    2. 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.
    3. 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. . .
    4. 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:
    1. I have yet to find a solid dev environment that includes a great debugger. Yes, emacs can be set up to help a bit, and the default program included with the windows install is ok (albiet a bit flaky), but I would want a rock solid, easy to use complete dev studio for my students.
    2. I REALLY dislike any language that depends on white space. Miranda and Haskell are two other examples of this. Its a pain to move blocks around and anyone who doesn't use an editor with auto-indent is screwed. Also, unless tabs are set to spaces, computers with differnt tab stops will see your code differently, which can be a problem if code is emailed, etc.
    3. As has already been mentioning, not too much one can teach about memory management and pointers with python. . .
    4. Sounds kinda strange as a complaint, but too much is built in. I have this complaint about java too. As an example, I would much rather have an early homework be a sorting algorithm and then have them reuse this algorithm in other homeworks than let them just type "xxx.sort()". Not that this isn't a great feature for experienced programmers, its just that begining students should have to do sorting, reversing, duplicating, etc themselves at first.

    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. :o)

    -s
    --

    - - - - - - - -
    Don't worry, being eaten by a crocodile is just like going to sleep in a giant blender.
  16. Re:Computer 'Science'? by panurge · · Score: 3, Interesting
    Many years ago I went for interview to the CS department of the University of Leeds, England. Things were going well until I asked the full professor interviewing me if we were going to learn anything about the hardware side of computing. He looked down his nose at me, drew in his breath and said "My boy, we don't concern ourselves with the doings of technicians". (Leeds is not precisely in the forefront of advances in modern computing.)
    However, for the last hundred years or so it has really been increasingly difficult to separate science and engineering. More and more, scientific hypotheses can only be tested when sufficiently advanced engineering comes along. There have always been "whiteboard scientists" (i.e. theoreticians) who resent this.
    But most great scientists were skilled engineers as well. Galileo, Newton, Bunsen, Babbage, Turing...

    I think the terminology is the problem. We don't talk about "Physics science" or "Biology science", so why "computer science" or "rocket science"?
    Why not just computing and rocketry?

    While I'm having a rant, there's also a problem with degrading the word "engineer". MCSEs and such are basically technicians, not engineers. Perhaps if we admitted that the people who implement systems using standard components that just have to be set up correctly (although this may be a challenging role) are technicians, then we could accept that most "computer scientists" are actually trained as engineers, that this is a highly skilled and challenging professional role, and the number of real scientific researchers is not that great. Just like physics and chemistry nowadays, in fact.

    I would suggest that the test of a pseudoscience is that it doesn't create a heirarchy of engineers and technicians because, basically, it doesn't work and there would be nothing for them to do. You don't get sociological engineers designing ever better societies, and socio-technicians building them just as fast as people can throw money at them. (At least, the attempts, such as Marxist-Leninism, have been abject failures). But you get plenty of sociologists. On this basis, computing, with its deep organisational structures, is an extremely successful science-based system. Arguments about testing hypotheses are irrelevant: real scientists tend not to work like that anyway.
    Scientific proof has been conventionally about other people reproducing your results. But if the nature of your science/engineering is that you can rapidly produce millions of copies of your concept or invention, this becomes trivial. If I claim to have invented (say) a graphics chip architecture that can draw polygons twice as fast as the previous best for a given clock speed and die size, I prove this by marketing the product, not by publishing and waiting for other labs to build a copy and duplicate my result.

    --
    Panurge has posted for the last time. Thanks for the positive moderations.
  17. Not about computer science; try SICP instead by alienmole · · Score: 3, Insightful
    That's because it's not about Software Engineering, you fool. It's about Computer Science.

    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.

    1. Re:Not about computer science; try SICP instead by alienmole · · Score: 3, Insightful
      We want it for free :(

      The link I gave to SICP includes the full text in HTML. How much more free do you need it to be? It's accessible by clicking the link on that page which reads "Full text! The complete text in HTML". Unintuitive, I know, but that's the kind of thing you'll learn to understand as a computer scientist...

      though many of the critics are ineed covered in the book: naming of variables, abstracting and not hardcoding stuff, making it readable, making it generic, wrapping code, etc.

      These things have very little to do with computer science, with the exception of abstraction (which has very little to do with "not hardcoding stuff"). What we have here is a situation where people who know absolutely nothing about the current practice of computer science are using the term to mean whatever they imagine it means.

      Variable naming, readability, wrapping code etc. all involve techniques which any good programmer should understand, academic or otherwise. But calling that computer science is like calling hammering a nail "civil engineering" or "materials science". The Python book, at best, could be described as an intro guide to software engineering, but even that's a stretch. It's really "how to program in Python", with a few technical terms introduced along the way.

    2. Re:Not about computer science; try SICP instead by alienmole · · Score: 3, Insightful
      I don't like math much though I adore logic)

      I also tend to prefer the logic side of things. A lot of computer science of the kind that SICP deals with has to do with mathematical logic, which I find more logic-like than math-like. For that reason, I love the lambda calculus, which is what almost all functional programming is based on.

      If you like logic, and you like programming, you *must* learn the lambda calculus - it'll give you new insight into the meaning of computer programming, and you'll probably enjoy it, too. It has applications to literally every programming language. If you're not already familiar with lambda calculus, the name sounds a lot more daunting than it really is. To start out with, you can think of it as a really simple and primitive programming language - almost the prototypical programming language.

      I'm not sure what the best intro source into lambda calculus is - the academic works are mostly heavier-duty than you really need. Some google searching definitely turns up some useful stuff, but offhand I don't know of a definitive intro site. However, SICP teaches a lot of the necessary fundamentals, since the Scheme language that it uses as a teaching tool is just about the closest language to the lambda calculus that there is. If you learn a bit of Scheme first, learning lambda calculus from the lay perspective is fairly straightforward. (I say "lay perspective" because it has some hairy mathematical underpinnings, which I mostly ignore, and that's OK for most purposes unless you're trying to prove mathematical theories.)

      (ie: I know to how to program, but not how to make good programs. Every tome i need to add unexpected features or when I review my old stupid ugly code, I am reminded of that fact :-)

      ...And then there's programming under a deadline, which is a whole 'nother story.

      I think that these academic topics can be excellent for improving one's design and thinking skills, at least I've found that to be the case. It's an indirect kind of thing, though, and experience is probably equally useful. Abstraction is key, though, whether you do it using object-orientation or modules in functional programs, keeping interfaces separate from implementations is probably one of the most important things, which people violate all the time. It doesn't help that many languages don't provide features to do this properly...

  18. Sorry, but you're confused by alienmole · · Score: 4, Insightful
    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.

    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.

  19. Re:Not convinced at all by elflord · · Score: 3, Insightful
    But think that your comment about main() might indicate a lack of understanding on your part, not on Elkners. I don't think that the ANSI C specification defines a return type for main() (I did a quick grep of the spec to check).

    The C++ spec certainly specifies that the return type of main() is int. It's covered in 3.6.1 of the C++ standard. (I'm pretty sure the same is true for C).

    Also, in practice, different implementations require different return types.

    They're not conforming implementations if they require that main() doesn't return int.

  20. Re:How to think like a computer scientist by JohnsonWax · · Score: 3, Interesting

    I think part of the problem is the name `Computer Science', which gives a wrong impression of what the core of the poodle really is.

    Well, yeah.

    I'd make the following analogies:

    • Computer Science ~= Physicist
    • Software Engineering ~= Electrical Engineer
    • Informatics and Coders ~= Electronics Technician

    CS is a science that deals with unravelling how information and logical systems function and developing frameworks to understand them. CS are most likely to determine the boundaries at which things can happen and to lay out how to practically approach that boundary.

    Software Engineering is an engineering discipline that deals with manipulating those systems to perform a needed task. They take the work of the CS and design systems to address specific problems. Quick and dirty is just fine, provided that all the needs are being met.

    Coders assemble the systems that the SEs design and informaticians maintain those systems.

    There's overlap among all of them to some degree, and plenty of people do them all, but from an education point of view, if you mix them together, you get a mess - and most schools mix them together. It was easier to mix them in the past because the field was narrow. But now, you just can't do it.

    CS has become very deep, and you can't get into any of the real work if you spend your time dealing with SE and coding practices. SE has become very deep as well and you don't want these folks getting bogged down with the NP completeness proofs and whatnot, or with learning the programming tools too much. There's enough to do in all three areas that they need to be treated as different but complementary disciplines...