Skip to content

Tan Haoqiang

Abstract

Tan Haoqiang (谭浩强, born 1934) spent his first quarter-century at Tsinghua University as a political cadre, not an engineer. In 1978, aged 44, he began teaching himself BASIC; by the early 1980s he was teaching it on national television, and he went on to write the textbooks from which several generations of Chinese students learned to program. His C程序设计 (C Programming), published by Tsinghua University Press since the start of the 1990s, is by his own count the most widely sold university computing textbook in the world: 17 million copies by 2025, out of 55 million for all his books. Those figures come from Tan and his publisher and have never been independently audited. Among Chinese programmers the same book is a running joke, criticized for teaching compiler-specific tricks and code whose behavior the C standard leaves undefined.

Student Cadre

Tan entered Tsinghua in 1953 to study industrial electrification in the Department of Electrical Engineering. From his first year he was what Tsinghua’s president Jiang Nanxiang called a shuangjiantiao (双肩挑, “carrying on both shoulders”): a student who studied and did political work at the same time. He was branch secretary of the Communist Youth League in year one, a political counsellor in year three, and eventually chairman of the student union and deputy secretary of the university’s Youth League committee. By his own estimate, half of every academic year went to political work. The counsellor job added half a year to his studies, so he actually finished in March 1959, although his degree is dated 1958.

In 1956 he was one of about ten students moved into a new automatic-control class, the nucleus of the Department of Automatic Control founded in 1958. The department had too few teachers, so the class went to Beihang once or twice a week to hear Soviet experts lecture. His classmate Zhang Bo, one of the class’s strongest students, was kept on as a teacher. Tan stayed on the Youth League staff. As a student delegate he stood in the back row of a photograph with Mao Zedong, Liu Shaoqi, Zhou Enlai, and Deng Xiaoping on 1 February 1957, and sat in the front row at the Third National Youth Congress on 13 April 1958. “I never thought of becoming a computer education expert,” he said in 2025. “Never even thought of it.”

BASIC on Television

The opening came with the reform era. When China’s television university (the Central Radio and TV University, which had no classrooms and broadcast its courses on CCTV) wanted a course on BASIC, it could not find anyone at Tsinghua who had studied the language. Tan had not studied it either. He agreed anyway and, as he put it, “learned it and sold it on the spot,” teaching himself from foreign textbooks from 1978 and then moving on to Fortran. He bought an assembled computer between 1978 and 1980 because he could not write about programs he could not run.

The course book, BASIC语言 (The BASIC Language), written with Tian Shuqing and Xie Xiying, appeared from the Science Popularization Press in Beijing in December 1980. Tan began lecturing around 1981. The programs were recorded at Tsinghua’s audiovisual center and broadcast in half-hour slots in the afternoon, first for the television university and later as regular CCTV programming; after three or four years of live teaching the recordings were rerun. Tan’s own account puts the audience at one million viewers and the book’s sales at over 12 million copies. Material collected by his 2025 interviewer credits him with televised courses in seven programming languages. The BASIC book was his entry into what the encyclopedia covers in BASIC: The Language That Democratized Programming: a language designed for beginners, carried here by a broadcaster to a country with very few computers.

In 1985 Beijing merged the branch campuses set up after 1978 into Beijing Union University. Tan, until then vice-president of Tsinghua’s First Branch School, gave up administration there and taught computing at the university’s automation college. In 1984 he was among the founders, with Xu Zhenyu, of the National Association of Fundamental Computer Education in Universities (全国高等院校计算机基础教育研究会), which he later chaired; he is now its honorary president. He also chaired the Ministry of Education’s committee for the NIT computer-application certificate and was vice-chair of the committee for the National Computer Rank Examination. He retired in 2006.

C Programming

Tan’s method was to write for people who knew nothing, at a time when, as he said, “the leaders didn’t know it and the other teachers didn’t know it.” He wrote at home “from morning to night, after every meal,” and his output was correspondingly large. In 2001 he listed 130 books written alone or with co-authors, plus 18 series of 228 titles that he edited.

The book that outlived the rest was C程序设计. Tan dates its first publication to 1990; Xue Fei (below) gives the first edition as 1991. It went through numerous editions: the fourth (2010) was rewritten around the C99 standard, and the fifth carries ISBN 978-7-302-48144-7. It became a standard text for first programming courses at Chinese universities and for students preparing for the national computer examinations. Kernighan and Ritchie’s The C Programming Language was the reference abroad; in China it was Tan’s book.

The sales figures have grown with every retelling, and all of them come from Tan or his publisher:

Year Copies of C程序设计 claimed Source
2000 3.3 million Tan, in Tsinghua University news
2001 3.3 million Tan, in Guangming Daily
2010 7 million publisher’s author biography, 4th edition
2025 17 million Tan, interview with The Paper

In 2000 Tan, writing for Tsinghua’s news site, called 3.3 million “a world record for a book of its kind,” and in 2001 Tan wrote that “some people say I have set three world records”: for the BASIC book’s sales, for the number of computer books written, and for the total of about 44 million copies across everything he had written or edited. No auditing body is named for any of them. In the same article he noted that the newspaper China Computerworld (计算机世界) had ranked him second among the ten people who most influenced Chinese IT in the twentieth century.

The Critics

As the readership grew, so did the list of complaints, almost all of it written by programmers who had learned from the book. Two examples recur. Critics point to void main() in the book’s programs, which many compilers accept but the C standard does not define for hosted programs, where main returns int. More notorious are the exercises that ask students to predict the result of expressions such as (++i)+(++i)+(++i), which modify the same variable several times without an intervening sequence point. The C standard leaves such code undefined (see Fun Fact: C Undefined Behavior): the compiler may produce any value. One 2015 blog post ran the book’s example and got 22 with gcc where the book said 24. Other critics fault the book’s single-letter variable names, inconsistent indentation, and math-exercise drills, which they argue train students for exams rather than for writing maintainable code.

The criticism reached print from Tan’s own publisher. In October 2012 Tsinghua University Press issued 品悟C: 抛弃C程序设计中的谬误与恶习 (Understanding C: Abandoning the Fallacies and Bad Habits of C Programming) by Xue Fei, 502 pages on common C errors; in a review of his own book on Douban, Xue traced one example, a+=a-=a*a, back to the 1991 first edition of Tan’s text. Xue’s book was itself received badly by readers. In January 2023, during an online wave of complaints about Chinese university textbooks, Tan’s C book was again one of the most named, with users repeating that “the domestic computer exams only recognize Tan Haoqiang’s textbook.”

Tan has not answered the programmers point by point. In 2025 he described his work this way: “It is not high, precise, and cutting-edge; it is popularization. Not a monograph, but popularization.”

Readers

The readers who stopped him in the street were not the ones writing blog posts. On a trip to Wuhan a father and daughter asked for a photograph, explaining that three generations of their family had learned from his books. In the Shuang’an shopping mall in Beijing a woman pulled at his sleeve from behind, asked whether he was Teacher Tan, and put a programming question to him on the spot. When a reader in Tianjin wrote that he could not find the book in any shop, Tan bought three copies and mailed them, so the reader could pass two on.

📚 Sources