Programming language Tutorial Book How to write: Learn from K&r!

Source: Internet
Author: User
Tags scala tutorial

Original address: Lax Language Tutorials
Andrew Binstock

Every year in the review of Jolt Awards books, I will be a number of language tutorial books are exhausted. Judging from these years of experience, these language tutorials are well written, but in addition, there are few bright spots. In other words, these books are very rigorous, very sophisticated, if the reader has sufficient strength, through their mastery of a language programming technology is not a problem. But even for the best-selling books, I could not think of any more words of praise.

One of the common shortcomings of these books is to complicate simple tasks. One of the biggest or most common problems is that the authors confuse the difference between a tutorial and a monograph that covers a language. For a variety of reasons, the publishing industry seems particularly keen on the latter genre, resulting in some startling tome. I have seen a book "Introduction" In the Java language, up to 1480 pages thick. It is obviously unreasonable to say that the primer is so thick. Needless to say, this book in-depth discussion of AWT and swing, and then flick a turn, and give readers a variety of third-party libraries, the study of the virtual machine is of course, and eventually end in parallel programming. Thankfully, this is the end of the book. Given that the book is now in its 4th edition, there is reason to think it embodies the author's final psychological expectations. That is, this is actually a tutorial and reference book. And since the weight of the book has reached 4.5 pounds (about 2.04 kilograms), I think it will probably only be used as a reference book. Mark Lutz's "Learning Python" is a similar one in the Python language book. Other language books, such as the "Pickaxe book", which introduces Ruby to Western readers ("Programming ruby:the Pragmatic Programmers ' Guide"), are well-deserved as such books. The first half of the book is a tutorial, and the latter half is a reference. This method is much better. Regardless of the length of the Ruby Tutorial (418 pages), it is justified to make it very popular for its quality only.

The second common problem is that the author forgets what the reader wants to do when he or she intends to learn a new language, and, of course, to write a few small programs to familiarize themselves with the grammar. However, many of the tutorials are only one or two lines of miniature code examples, just enough to demonstrate a feature, but not a single, useful program. If the language also has a built-in shell (or interpreter), such as Ruby, Groovy, and Scala, then the trend is becoming more pronounced.

For example, the Scala tutorial (programming in Scala), co-authored by Odersky, Spoon, and venners, can clearly reflect this problem. In the first 200 pages of this book, there is only one example of more than 20 lines of code, and most of them will not exceed 10 lines. [And in K&r (Brian W. Kernighan and Dennis M. Ritchie) The first example of a 20-line code appears on page 26th. As a result, according to my own experience, is to read a half-day book, also knocked a lot of code, thus learned a lot of functions, but has not written a bit of what to use the program. To be honest, this phenomenon is simply too common. Now I have two books in front of me, a clojure, a groovy, and this routine.

The last question is often found in a book that does not work: one who only wants to show the clever skill of a language or some small hack that can be done. Personally, the reader wants to learn the language, not to appreciate the language stunt. This problem is most commonly seen in functional languages, or as a tutorial that is intentionally designed to be better than a competitive language (Java for groovy) like groovy.

The key to the three questions that are difficult to understand is that there has been a good example for a long time: Kernighan and Ritchie's C programming Language (K&r). Compare this book with the other tutorials, and the difference stands. Starting with the most obvious place, the tutorial section of K&r has only 177 pages, followed by a 40-page addendum, and the appendix is an extremely concise reference. In this moderate space, any reader can easily read and finish all the examples. Secondly, most of the programs are above 20 lines of code, both for the corresponding purposes, and not to feel unfamiliar, and relatively complete. Even around page 125th of the book, the sample program contains the main () function. This is not a code snippet, but a short but real program. Finally, the interpretation of all the procedures in the book is very thorough, and successive, easy-to-digest. Without a simple list of features, all of the examples have an intrinsic clue that allows the reader to know at all times what basic knowledge they have and what basic knowledge they need to explore.

What does it not see in K&r? Most notably, the book does not explain the parts of each function function in the standard library. Java books should also erase this part. (the two most comprehensive books on the Java Knowledge System are the "Core Java" Volume I and Volume II, co-authored by Horstmann and Comell.) But in the 1800 pages of the two volumes, no tutorials are included, nor are they described as in the book. )

K&r also had no spoon-feeding sermons. The book must be looked at while thinking. All the information is there, but you have to do every example to understand the language. The author hopes that the reader of this book is very attentive and attentive, and will be ready to help you in the process of learning the language quickly, but will not force you to read one page after another about what is useless to understanding the language.

I'm afraid some people will say that C is just a small language, so it doesn't have to be a tome to introduce it. If you think so, please open your eyes and look at other C language tutorials to see which book is so thin and so well written as K&r. Otherwise, look at Javascript,javascript is a small language, but no book is short and easy to understand.

I would like to state that the books mentioned earlier were chosen for their own good, because these books seem to me to be the best course in the corresponding language field. Odersky, such as Scala, Thomas wrote Ruby, and Lutz Python, are the best starting points for learning the language. I just wish these books would be more like k&r.

--andrew Binstock
"Dr. Dobb's" editor-in-chief

Programming language Tutorial Book How to write: Learn from K&r!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.