Wednesday, October 26, 2011

CS & IT Academia: Some Comments on Teaching Programming

A friend shared his views over email, a month back, on some of the posts related to teaching programming in CS & IT Academia.

Friend wrote:
I tend to agree a lot with Chittar (comment here) on this issue: a balance (between theory & practice) is needed; and it is most definitely possible. And here are my reasons, thoughts & comments:

Importance of theory: in my (extremely limited life in this field), I have seen that if you can think abstract, you tend to think more general, more clear and usually results in better design. Yes, to reach the level of abstraction, the starting point is concrete examples, but yes, one can move up to abstractions quite easily if one applies oneself. Here is where theory can really help. Decades of rigorous study had created some well tested abstractions (lists, pointers, heaps and so on, to name a few basic ones). For example, not just in the classroom, but often at work, I could prove that something was not possible for the simple reason that it was NP-hard. Or that it was equivalent to the halting problem and so we have to rephrase the question or relax some restrictions to make it work. Things like Turing machines are the way everyday concepts like Regular expressions work. I mean, it may be enough to know how to write regular expressions. But if you know why they work or how they are implemented, that is a non-functional bonus.

Eklavya Sai: Sure I can appreciate that knowledge of concepts like Turing machines and NP-hard makes one a more capable programmer. But my point is that it is not necessary for all programmers to know Turing machine or NP-hard concepts. If a programmer feels the need to know them he can always study them on-demand.
Look at OOP, for example. The word abstraction is part of the native vocabulary. The abstractions here are basically 'generalizations'. It is not difficult to see that cat & dog are in general, animals; but it takes a keen mind to 'realize/see' more real-world (Goodbye, poor Car extends Vehicle object-orientation tutorial: http://lists.canonical.org/pipermail/kragen-tol/2011-August/000937.html). 
For that, you need experience and training would definitely help - better so at the student phase, with limited to no pressure, than in Industry where mistakes could be fatally expensive.

I have to say that there are enough system/low level jobs these days. At major-cell-phone-company, I worked mostly on MW and at major-search-engine-company, spent a fair amount of time on their proprietary RTML compiler. Not to say that Application jobs are few: I did spend a good amount of time at major-search-engine-company doing application level work. However, to do application level work, you mostly need to know the framework - and you can generally use it well, once you get to know it.

Eklavya Sai: Perhaps we can call the Application work - IT work.

But to do system/MW work, it definitely helps to know a good amount of pure CS: lists, pointers, efficiency of algorithms, more efficient algorithms. Even for application level jobs, this knowledge definitely helps - I have seen a bit of such examples at work at both the above mentioned companies. It was trivial to prove that my implementation was better than other's simply because I could figure out the running time complexity of both the implementations and then it was simply a matter of stating the obvious - and this is no story - I actually did this a couple of times at work (major-cell-phone-company).

Eklavya Sai: Sure, I agree that efficiency of algorithms, mastery of design & analysis of algorithms etc. may be useful even in IT (applications) work. But my point again is that it is not a pre-requisite or an absolutely necessary skill. And further, it can be picked up on-demand if & when required.
Coming to the issue of student, teacher & parent responsibility: yes, in India, there is a focus on the importance of passing students (...in the student mindset, passing examinations are the key goals to be achieved - that earns parental approval...). In my 6 months at an-American-University, I have seen that the mindset is so very different here in the US: the onus is on the student and teachers/professors generally don't mind failing a student.

Eklavya Sai: I think that is a vital, vital point. I wonder what the statistics are for failures in 'Lab' programming courses in AICTE/UGC universities in India. I have not heard of any student failing in a 'Lab' programming course.

Perhaps the prohibitively expensive nature of schooling, even at public schools like an-American-University, ensures that mostly serious students come in.

Eklavya Sai: I think that is the great benefit of a market-driven system as against a state-subsidized system. As the schooling is expensive in the US mostly serious students enroll. And they would demand to be taught well. The market goes by value-for-money and accountability.

But the bottom line is this: a mindset change.

I tend to consider myself a polyglot (I heavily read Paul Graham). Not that I don't care what language I program in, but precisely because I care. Not saying that one language is better than the other. But I think after a point, you should be able to program in ANY language, independent of personal prejudices towards languages. And I am stating this simply to emphasize that I agree with Chittar on the fact that he believes in teaching programming independent of language. Infact, this is what the timeless book on programming (SICP: http://mitpress.mit.edu/sicp/) does. It teaches you Scheme in the first few pages - it is practically possible - and you learn to think about programs, rather than think about programs in C/C++/Java/Python or whatever.

Eklavya Sai: My considered view is that whether programming is taught in a language independent way or a language dependent way should be a collective choice of the teachers & students of an educational institution. Some like the elite tech. universities may choose the former but the majority may choose the latter. One particular way should not be imposed on all educational institutions and all CS/IT students.
I also have to agree with Friend1 (comment here) on this: you should introduce (as opposed to necessarily teach) as many languages as possible. The roster he has listed would sound like what I would like too and for similar reasons. How many people even know about these languages to even casually mention them for one of their merits?

Eklavya Sai: I think it is a question of available time and comfort-level of students. Expecting that all CS/IT students of all educational institutions should be introduced/taught Scheme, Smalltalk, Erlang, Haskell, Joy, Forth etc. seems quite impractical to me. Give the students the choice, I say. If students of some elite educational institutions want to be taught this way and the teacher agrees - wonderful. But if the majority of CS/IT students want to be taught C/C++, Java, PHP etc. then let the teacher teach them those languages. Later, if time permits, he can introduce students to Scheme, Smalltalk, ... But given the crunch for time that C/C++, Java courses itself have, I am doubtful whether there will be time for other languages introduction as part of the 'Lab' programming courses.
Bottomline: people who teach should also upgrade themselves, by personal motivation.

Eklavya Sai: Interesting point. I personally do not have the time nor the inclination to learn Scheme, Smalltalk, Erlang, Haskell, Joy, Forth etc. I am willing to teach languages that I know like Java/C/C++ and also pick up languages like PHP on-demand (if students have to be taught those languages). So I do my new programming language learning on a strictly on-demand basis as I prefer to focus on my non-CS/IT interests in my "free time".

Therefore I do not fit into your criterion. And so, should I stop teaching programming? I don't mind as I have a lot of non-CS/IT interests I can work on. Except that there is a great shortage in Indian CS & IT Academia of teachers who are knowledgeable and capable of teaching Java/C/C++. So I feel I should continue to teach programming if students want to learn Java/C/C++.

But I personally enjoy programming in C/C++ simply because it is more challenging. Programming with C/C++ allows you to go to the guts of the algorithm. Yes, for app development, they may not be what you want to do and Java would be a better option, but C/C++ also have a ton to teach - especially wrt what Chittar noted: they have direct proof of application of seemingly esoteric theoretic concepts.

WRT limitations of time in teaching in the classroom: X taught us C++ and integrated design into his classes. Personally, my first job is totally attributed to his classes. I had less than 6 hours to prepare for the interview at major-cell-phone-company. And just the line of thinking and reasoning with objects and classes, the assignments that he gave us on C++ topics like overloading, overriding, inheritance and so on got me through a 4 hour interview. Trust me, all we discussed was C++ (about 45 minutes) and OOP design (~ 3 hours). I am not saying X is the authority on teaching C++ nor am I saying that mine was a one-off chance in the interview. I was interviewed, I later found out, by one of the best respected architects at major-cell-phone-company. After he said yes, even though I did not really do well with my manager, I got the job with a great offer for a fresher at major-cell-phone-company. So, to summarize, it is definitely possible. But yes, the student's interest also plays a key role - it is symbiotic.

Eklavya Sai: I think you were very fortunate to be taught C++ by a dedicated and gifted teacher. The interesting point to me here is that you did not do too badly :) even though you were taught programming in a language-dependent way!!! You may have, on your own, studied language-independent books on programming and learned many other programming languages thereby becoming a more accomplished software professional. That's wonderful. So you may have used an on-demand self-learning method to gain the benefits of language-independent programming. The majority of students who learn CS/IT programming in a language-dependent way are free to do something similar to you to gain the benefits of language-independent programming.
WRT priorities of universities: in the US, there are two kinds: teaching and research. Yes, the teaching universities (that are not allowed to award PhDs), aim to become research universities. But they also focus on high-quality undergrad & masters programs. Here, people expect you to pick up programming on your own, after they introduce you to a language. This is not so much the case in India. If not taught, students usually throw a 'not-taught' tantrum!!

Eklavya Sai: I feel that it is unfair to blame CS/IT students in India without delving deeper. My impression is that most US university CS/IT departments have a far better balance of theory and practice than in India. Their lab. facilities would also be far better typically - as students pay through their noses for it. I think Indian CS/IT students would, in general, be as good as US CS/IT students. IMHO, it is the systemic problems in Indian CS/IT academia that needs to be addressed.
Testing is another thing that should be integrally taught with programming - atleast the Unit-test part of testing. And that should be graded. Strictly. I recently started using a performance library that measures kernel parameters. The author provided a fix for something and said that he 'extensively tested it'. My question was how can I believe him? I looked up the source code, found & read the tests and it was trivial to answer my question. And here is the best part - the author is a researcher at -a-US-university. So, it is possible AND necessary to teach testing by default. Yes, this is different from Chittar's exposition, but without exposure to basics, I think Chittar's recommendation is difficult - but if inculcated, would be an incredible tool in any CS/IT persons' arsenal.

Eklavya Sai: In an ideal scenario teaching programming and unit-testing together will be wonderful. And the unit-test-plan and unit-test-report would also be graded. Given the time available for 'Lab' programming courses and many other realities on the ground, I feel it will be quite impractical, as of now, for most CS/IT departments to teach and grade testing integrally with programming.
It pains me to state this: but most people who come into programming from non CS/IT backgrounds these days have this skill: 'Programming by copy-pasting'. I have seen people with over 6 years experience at major-cell-phone-company who copy-pasted stuff and it was out right wrong. They wrote test cases to make it pass, but I caught it at review. He did not understand simple OR vs AND. This may sound like a pathological case, but yes, that is the gist of not having theoretical & practical training.

Eklavya Sai: Oh! I have seen copy-paste programming being done by CS/IT graduates as well. But I agree that programmers who neither have a CS/IT background nor an IT-Finishing-School/Private-IT-training background may be more prone to copy-paste programming. I also have seen countless programmers who have ZERO CS/IT formal academic background but were far superior programmers as compared to many CS/IT graduates.

You have good programmers and bad programmers irrespective of whether they have formal CS/IT academic background or not. It is a company's responsibility to assess potential software developer employees properly before they are given software development jobs. If they somehow got through the assessment mechanism, once they are found to be incompetent, irrespective of whether they are CS/IT graduates or not, they should be asked to relocate to some other activity or become competent by undergoing appropriate study & training.
Let me conclude with some general thoughts: Education/schooling is a time where one can learn from example to a great extent (unless you do some research kind of problem). The cost of making mistakes while learning in the class is quite less compared to that of doing so in real projects. While students may not have the wisdom to understand this, instructors should have the wisdom and courage to take necessary action. One can learn a lot by studying works of others: not everyone is a prodigy. Even whom/what you copy is a reflection on your taste/preferences. One can learn a good deal about how/why an algorithm works by studying it in all its theoretical abstraction aided by good working examples running in parallel. Algorithm design for example, is a very little taught discipline, but is very essential for great progress. It could mean the difference between Top-US-Product-Development-Companies and Indian-Software-Consultancy-Companies; no, I don't mean to belittle the latter companies, but what they do and are capable of doing is very, very fundamentally different from that of Top-US-Product-Development-Companies.

Eklavya Sai: My focus in this blog is on teaching programming in general as against teaching sophisticated algorithm design & analysis. "Programming-in-general" would include basic algorithms for searching, sorting involving data structures like arrays, vectors, linked lists, hash tables, maps etc. But it would not delve into deep analysis of these algorithms and their efficiencies. Of course, Top-US-Product-Development-Companies would want CS/IT graduates who are very good at design and analysis of algorithms besides being good at programming in general. My understanding of most CS/IT academia in the country is that Design & Analysis of Algorithms is taught as a separate 'theory' course. I do not want to comment on that course as it is outside the scope of my 'Lab' programming courses interests.

No comments:

Post a Comment