Developers Club geek daily blog

1 year, 2 months ago
Hello, dear readers.

Recently we were interested in Zed's series of the Show "The Hard Way" which it would be desirable to translate into Russian at least partially. As occasionally we really do not look for easy ways, it would be desirable to begin with the book about language C:

Dig only down

A series is oriented first of all to beginners. For those who love language C and also for their opponents believing that it is better to start with something more simply we publish a little reduced Evan Miller's article written at the end of last year. Perhaps, depending on reaction to this article, we will decide to translate and publish in addition a fragment from the book of Mr. Shaw or even his answer to the criticism stated by Tim Hentenaar for now we invite you under kat where, from our point of view, the most general reasons for benefit of relevance of this book are stated.

When I learned to drive the car (to me then was slightly more than 15), mother insisted that I practiced on fatherly Mazda Miata: it was the silvery two-door cabriolet with folding top.

To manage "Miata" it was difficult. Not only that in it there was no automatic transmission, in addition from this machine it was almost impossible to glance back. The sun so fried thoroughly plastic back glass that on folded folding top, appear, it was possible to cook sandwiches.

"Miat" was not also the safest machine at all, and the Mazda Motor Corporation company did not even try to approve the return. It was just available machine which it is pleasant to ride, such budget BMW. I remember, fatherly "Miata" was such narrow and stocky that when I went by it on the federal trunk, even thoughts crept in: "And if I try to slip on it under the semi-trailer, the long-distance truck driver will notice something"?

Still we had a minivan and the SUV — larger and reliable machines with transparent back glasses. Many parents would prefer to teach the teenager to driving on them. But not my mother.

"Once you will appear at a party" — she explained to me with confidence to which Nostradamus would envy — "and there will be a machine which nobody will be able to conduct because it will have a manual switching of speeds. And you have to manage, and it is necessary to study it now, otherwise will never cope with the switch handle".

To master a manual transmission — not the most interesting occupation, and I think that I would never be engaged in it if not that prophetical authority whom mother held at our place. But, having acquired skill, I as a result could go by "Miat" within authorized speed, without filling in a driver's seat then and tears.

Since then there passed many years, and I noticed interesting pattern. We, proud minority — the tempered masters of manual transfer — were much more skillful, than those who got used to rely on the automatic transmission. We owned machine more surely, imagined better how the car engine works. Even if we never happened to glance in a transmission, we knew that it "the raising transfer" in an automatic box as with its help to save gasoline. We knew that mean mysterious digits 1 and 2 under a text of "Drive" what they can stand in good stead when you move down on a slope. And in each timepoint we probably at the intuitive level imagined better what happens to machine — better, than adherents of an automatic box.

I do not regret that I mastered manual transfer in due time though I and did not happen to bring these essential benefit to society – for example, I never operated under a rapid fire by ambulance car in which orphans would sit. Simply manual gear shifting — good skill, will prevent nobody. I think that I the more drivers will own it — the better.

The kind reader, I wrote all this not to advertize myself as the excellent driver of low budget cabriolets, and not to oppose domination of automatic boxes in the automobile industry. Actually, I just see important parallels between distribution of such boxes in automotive industry and the Python language — in programming.

Python is convenient, in many respects it considerably exceeds language C. But if you accustom the teenager to go by an automatic transmission, then can be almost sure that he also will not think to master switching of speeds. Advising neophytes to study Python, we produce neophytes who will never try to write a code on C. I think, it is bad.

Expressing this opinion, I appear in minority therefore especially I want to explain my point of view here. Not so long ago Python pressed Java as the most popular input programming language learned at universities. Eric Raymond, the author of the program article "How To be a Hacker" recommends Python as the first language. It certainly Peter Norvig in the well-known work supports "Teach Yourself Programming in Ten Years". Paul Graham even tells about specific "Paradox of Python".

Today, if you see advertizing in the spirit of "How to learn to program for the X weeks" — can be almost sure that to you Python will suggest to study.

Contrary to surface attractiveness of Python — its syntax, interactivity, library support, wide community and excellent documentation — selecting it as the first programming language, you face a serious problem. The programmer, only aware Python, does not possess sufficient ideas of operation of the computer. He can perceive C as the mystical art causing mixed sensation of fear and hostility. Fear — because the programmer was told that by C it is put, and hostility — because difficulties of C allegedly are obsolete remnants of more ascetic times. There was even a new truism: "human time is more valuable processor".

But Python and C — not just alternatives each other, where one language — slower and convenient replacement to another. Python it is also impossible to consider to perceive unconditional technology progress in comparison with S. Luchshe Python and C as the languages coexisting in independent parallel cuts of reality where C are one level closer to the machine.

Paul Graham picked up a beautiful metaphor (as always, the truth?) about the potential of programming languages which it describes as a peculiar vertical continuum. Languages with the minimum opportunities are located below, with maximum — above. Somewhere in the middle there is a hypothetical Blub language which slightly less than completely reminds C. Graham considers that users of Blub will despise all languages lying below than Blub in this continuum — Cobol, a machine language, etc. — and will not be able just to understand a possibility of those languages that lie above.

It is a magnificent image, but let's consider this metaphor on the other hand. Perhaps, Python lies higher than C, and Lisp is similar to cherry on cake of abstractions, but studying of Python or Lisp not too helps to understand, the computer on which this continuum is based how exactly works. Thus, in spite of the fact that Lisp-programmers seem omniscient inhabitants of heaven, in hierarchy of programming languages is not simpler to glance "down" at all, than "up".

Actually, I would even tell that it is more difficult to look down, than up. The pure Lisp-shchik considering a code C sees only nasty syntax, unfamiliar functions and mysterious comments about a cache lines. And the C-programmer, looking up, sees the whole bouquet of the things implemented on C.

Popularity of Python is connected with the fact that it takes in the described continuum a position above an average. It is more abstract than C and is more productive in work, but is not so abstract that your head went around from metaprogramming and a recursion.

The trouble is in what is equal as Lisp seems elaborate and excessive to the average Blub-programmer, and C makes similar impression on a pitonshchik. What pointers about which all speak are? "Sounds subtly (the pitonshchik reflects) and if I still somehow work without these pointers, I will do without them further".

Therefore pitonshchik in the majority will never begin to study C.

Undoubtedly, it is possible to make long and successful career in IT, without knowing C. However the culture of programming without studying of C gives a number of vicious effects which are directly connected with the fact that the person gets acquainted with programming on the example of Python.

First, less and less the people capable to write excellent programs. Perfectly to program — for the PC, mobile devices, the alien ships — you have to represent accurately as the computer and an operating system function at the lowest level. How many data structures find room in a processor cache? Why the code works slowly, and the built-in profiler claims that quickly? When I order to an operating system to make something that it really does? I think, all these things can be learned by heart, but nothing so helps to purchase necessary intuition as writing and optimization of a large number of a code on C.

You can object that it is more important to write more programs to this historical moment, than it is more than qualitative programs. Perhaps, from the economic point of view indeed. Technologies develop very quickly, there is no need to write filigree worked program which is necessary to nobody. But culture "just use Python", "computers now rather fast" and "let the problem is solved by iron" lead to deep system crisis: when enter a profession through Python and slight C, less these clever men will get to professional programming.

Moderate anger for a minute and listen to my arguments.

I consider that for such "clever men" who are going to study programming, Python as the first language is unattractive for two reasons. First, it is not so difficult to study Python. Key concepts of this language properly do not cling intellectual technicians and, respectively, do not cause a particular interest. To study Python, I would tell, a little boringly. All the same how to go to school where there are no profile classes.

The second mechanism was described by my acquaintance who registered in workshop on Python recently. She told that she with great pleasure learned cycles and functions. They were small, clear, self-sufficient. But then the teacher decided to show "all power of Python" and spent the occupation rest for writing of some useless applet with Python Twitter API.

The address with libraries — important skill, it to you will be confirmed by any professional developer. However if prematurely to get acquainted with libraries, then they erect the whole wall of abstractions at the sight of which smart people feel simply dumbfounded. And my acquaintance thought that she just about will begin to study the confidential laws managing computers; instead the teacher just rolled out before it the monolithic user application with absolutely impenetrable abstraction of client library. Without having mastered, first of all language — and without having learned to read the source code of this library — my acquaintance appeared without tools by means of which it would be possible to dig more deeply and to understand what occurs at the call chain basis.

"Just bad workshop got" — you will tell. But on this example I want to emphasize more large-scale problem: without having studied to start C, the programmer is deprived of the necessary tools allowing to understand what happens in the used system. If you — a smart and inquisitive pitonshchik, then soon get to the bottom of dense breeds of language C. Under these horizons, will tell you, "be afraid of dragons, bones and debuggers". Respectively, if you are not rather brave and will not ignore warnings "yes do not undertake you this C", you never investigate depths on which it is possible to get just out of curiosity.

On the contrary, the sishnik trying to understand a code fragment on C at worst will have to shovel a lot of heading files, the man-help and source code. But hardly some strange packet of Lisp or Python will get to it. Dig always down, but not up. Such is an essence of computers.

The motivation of the programmer happens double: or as it is possible to solve better a problem, or to understand how these or those things work. Undoubtedly, Python perfectly is suitable for a solution of tasks. Popularity of Python on startups and university courses testifies to it (including, on Data Science). If you are going to learn for all life only one programming language, then Python — the reliable, effective and reasonable choice.

But Python does not suit at all for those who are interested in the principles of operation of the computer. It is a problem as in the long term the best programmers turn out from the people overcome by thirst for knowledge. Perhaps, in the short term it is not the best employees — read at work of the book, implement some senseless optimization — but, having passed enough rabbit holes, they will be able to draw to you this map of the country of miracles.

In it, I believe, and the real problem with "programming without C" — and also with more global idea that input programming languages have to be "expressive" and "available to beginners" is. The guild of programmers loses just those people who could decorate with themselves it.

I want to emphasize that I do not mean people who want to combine programming with the main work (scientists, journalists, web designers, etc.). I speak about those who are interested in programming per se and think that I could succeed in this case once.

In brief I will stop also on why at universities teach Python (and earlier taught Java). The basic reason is that a task of universities – not in training programmers experts. At the majority of faculties just try to prepare as much as possible successful graduates who will go to postgraduate study or will find highly paid work. Neither that, nor another demands exclusive programmersky skill.

From the point of view of the teacher, the programming language is a material on which it is necessary to study fundamentals of information science: algorithms, data structures, etc. of Python — golden mean as it is easy to study it (professors are happy), and still it is used in commercial projects (professors just exult). Add here popularity of Python at universities, abundance of on-line materials, and also everywhere quoted (and seldom disputed) the statement that Python — "good educational language". Well with it can go not so?

It seems to me that the people getting to programming through Python miss the mass of all interesting. There is a popular belief that a programming high — to solve the diverse problems in the minimum code amount, with might and main using client libraries, other. It is fair in cases when the person has to be controlled with work, having met the deadline. But if your main motivation — to something to learn and to become the first-class programmer, then it will be much more interesting to write the programs working not so effectively, but leaving food for reflections.

For people who never programmed earlier, language C — the excellent exercise machine. Pointers and their arithmetics have no close analogs in the daily world. Learning this language, you will be to come across, apparently, senseless error messages and to deal with nondeterministic failures. If you have problems with arithmetics, then you can damage call stack; you will forget about simple check of edge conditions — and the heap will fall down as a house of cards. Sometimes it will want to you break to the monitor or to porydat on the keyboard.

But business is worth it: language C helps to gain a good impression that it does the computer. You will feel as the teenager battling against a manual transmission. Asking the questions "why?" and being dug in more and more deeply, you will gradually acquire model of processes, architecture of the processor, memory hierarchy, will understand an operating system, etc. This mental model, but not language C per se, will help you to orient with abstractions which wrote others and to create programs which once seemed to you inconceivable.

So, if you want to learn to program skillfully — in any language — that do not give in on arrangements to study Python or, God forbid, Lisp, and begin a way with C. On top smart types open, but if you want to conquer the mountain, then it is the best of all to climb up it from below.
About Zed Shaw's books

116 people voted. 30 people refrained.

The users only registered can participate in poll. Enter, please.

This article is a translation of the original post at
If you have any questions regarding the material covered in the article above, please, contact the original author of the post.
If you have any complaints about this article or you want this article to be deleted, please, drop an email here:

We believe that the knowledge, which is available at the most popular Russian IT blog, should be accessed by everyone, even though it is poorly translated.
Shared knowledge makes the world better.
Best wishes.

comments powered by Disqus