Best Paradigm For a First Programming Course?
Keyper7 writes "The first programming course I had during my computer science schooling, aptly named 'Introduction to Programming,' was given in C because its emphasis was on imperative programming. A little before I graduated, though, it was decided that the focus would change to object-oriented programming with Java. (I must emphasize that the change was not made because of any hype about Java or to dumb down the course; back then and still, it's presented by good Java programmers who try to teach good practices and do not encourage excessive reliance on libraries.) But the practices taught are not paradigm-independent, and this sparked a discussion that continues to this day: which paradigm is most appropriate to introduce programming? Besides imperative and object-oriented, I know teachers who firmly believe that functional programming is the best choice. I'm interested in language-independent opinions that Slashdotters might have on this matter. Which paradigm is good to introduce programming while keeping a freshman's mind free enough for him/her to learn other paradigms afterwards?"
If you go on to do anything comp sci related, you're going to need a good background in all of these methods of programming, their advantages and disadvantages. You'll need to know when it's appropriate to use each one, and why.
CAn'T CompreHend SARcaSm?
Definitely functional programming. OOP is an extension of this. The methods within an object are, of course, functional. I feel it's like trying to teach someone to drive with a manual transmission, in a city. It's better to let them learn the basics, and THEN learn the more complicated (and better) way to do things. Building upon the prior knowledge.
I am speaking as someone who learned functional first and then OOP, and who is now a (self-described) expert in OOP. Also, as someone who learned on an auto tranny first, and who is now a (self-described) expert at stick.
It's all about steps.
At my institution, the '101' and '102' courses are taught in C and Java respectively. The class I'm taking right now is these two classes combined, so my 'intro course' is taught in C and then Java. Several projects require writing the same program in each language.
Procedural is most like instruction list people are used to doing. However, it often leads to bad practices and sloppy coding. Object oriented can be good, but few people use object oriented beyond procedural wrapped in a class. It also is often hard to represent a good object system on paper. Functional languages to vary degrees are very nice if you didn't learn procedural before hand and can think of problems as smaller problems. People usually have trouble with them because they have learned Basic, C, etc. Logic languages are extremely powerful in that you only describe what you want, not how it should go about being computed. That isn't quite true, but think of them as more of set theory and logic. However, they can be somewhat awkward to teach.
Reserved Word.
just give the courses funky and updated names like
"Whiplash and programming, what they have in common"
"the 7 do's and don't of baning your head against a wall learning OOP for beginners"
that should do the trick!
How about instead of asking this you just go read the article posted hours ago about the creator of c++ and his views on education?
http://news.slashdot.org/article.pl?sid=08/12/09/2017242.
I wonder if something more basic might be in order.. My degree is in Philosophy, so I had to take symbolic logic. There was a CS guy in my course though who actually went to the department and said, "this should be on the CS curriculum, because we really don't formally learn logic." Here's the guy who taught me @ John Carroll: http://www.jcu.edu/philosophy/gensler/lc/index.htm
I've always thought that Java as a first language was a mistake. Students are forced to learn two concepts, structured programming and object orientation, at the same time. They should master one, then the other. For object orientation being second, it is not just a programming style, it is also an essential facet of design.
Functional programming can come third. I know that a lot of FP people would disagree. But I really don't think that the beginner student would have a clear grasp of scope, stack frames, or method references until they learn something easier first. But, hey, third semester is not so late.
I've found that good students tend to do well with any paradigm you introduce them to, while bad students do poorly no matter the paradigm. Few seem to be in the middle. I would argue that the choice of starting language or paradigm is therefore not as important as people think it is.
*I teach an introductory data structures & algorithms course. The school I teach at just switched from C++ to Java.
My first language was not Scheme -- I learned bits of LOGO and [Q|Visual|Ti-calulator] Basic as a kid. However, my first course at University was taught in Scheme, and it was by far the best computer science class I've ever had. Since then, my school has tried teaching freshmen Python, Java, and Matlab and they've all sucked horribly in comparison.
(LISP, ML, Haskell, etc. would probably be just fine too.)
"[Regarding the 'cloud,'] ownership was what made America different than Russia." -- Woz
+1 to that.
Seriously, assembly is great and all, but people are idiots. Assembly would just scare them away.
While I would rather the field be smaller so that there's a higher chance of me being employed, I realize that I would probably not be interested in comp sci if I was thrown assembly the first day.
Re-inventing the wheel is the pathology.
One of the most significant advantages of Java *is* the availability of mature libraries! They are there to be used.
you had me at #!
if it were up to me, i would teach a first course in computer science using only pencils (maybe pens for the foolhardy) and paper. i say that as someone who has t.a.'d a lot of programming classes.
the issue, at least as far as i've observed, is that until a student has a solid ability to start decomposing a problem using top-down and bottom-up approaches, trying to teach them any kinds of programming language or algorithms is pointless. it's like having a carburetor and no car.
i would suggest that c.s. instruction, especially at the early phases, should aim to make students spend a lot of time asking questions like: "what information do i need to solve this problem?", "what is the easiest useful thing i can do to help solve this problem?", "what's missing from my solution?", "is it easier to break this step down more or just do it right here?", "how can i join X and Y to do Z?", etc. once you get students asking those questions, picking up programming languages is a lot easier: they know what they want to do, all they need to focus on is how.
" ... I'm interested in language-independent opinions that Slashdotters might have on this matter. ..."
Slashdotters don't have any language-independent opinions. Sorry.
In my senior year of high school, my senior project was essentially an independent-study intro to programming.
My advisor suggested Python (version 2.4 at the time), and thought that C/C++ was a bad idea for an intro language (C++ had been my initial suggestion)
I was pleased with the result; I felt that Python's straightforward English-like syntax, lack of funky punctuation as a structural construct, as well as not having to start scripts with declarations or somesuch, meant that I didn't get bogged down in arcane language features as I was trying to practice basic concepts.
(I came into that with no code-writing experience beyond simple HTML/CSS/JavaScript)
I listen to both RIAA and non-RIAA stuff if I like the music, tangential business/politics nonwithstanding.
I started reading the story intro and wondered if it wasn't another ploy to get a discussion going on functional programming since I've seen these quite a number of times in the last month. Sure enough, there was the plug and look at all the functional fan boyz talking it up.
Earlier it was multi-core programming, now this 'best paradigm for a 1st prog course'. What next, best compiler or maybe best OS for running functional programming applications?
FYI, the answer is OOP.
LoB
"Anyone who stands out in the middle of a road looks like roadkill to me." --Linus
About half of the posts thusfar, on /. of all places, display a lack of understanding of the programming paradigm-sphere.
How many posts here just extolled (or decried) the virtues (or problems) of "functional" programming languages like C and C++? Functional is not Procedural. Functional != just programming with functions.
Even here, among the (arguably) nerdiest nerds on to ever move mice... many people don't really know. So maybe you need to start there...a sampler course with various paradigms and languages so people will actually know how all these things fit together. Some functional OCaml, some imperative::procedural C, and some imperative::OO Java. Mix it up.
THL phish sticks
Although, maybe, just maybe you should start them with BASIC. In other words, mirror the history of exposure that my generation got--slow BASIC, assembly to make it faster, high level procedural languages like Pascal, object oriented dreams, object oriented nightmares, and then that wierd thing called functional.
Yes, I know functional came before 8-bit micros; but for a lot of us the history I've outlined above is how it all progressed. I know I'll get flamed for this, but for many years you could come out of school without knowing anything about functional programming and do just fine. It seems like that's changed in the past few years; but we'll have to see if it really sticks. The recession might help it, since the complaint about not being able to find employees comfortable with functional programming will be mitigated by all the tech layoffs...
The bottom line though, is that underneath all that stuff you have a machine. Assembly gets you as close to that machine as possible. Everything else is just a cute wrapper for the machine. Too many CS grads have no feel for that "foundation". What if architects learned nothing about foundations?
For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
Rather than a specific paradigm, you should focus on what almost all languages have in common. Almost all languages operate on statements. They have variables to store data. They get input and produce output. These simple concepts are mind-numbingly dull for anyone with experience, but most new students I've seen haven't done programming before. I feel that students should enter the world of programming with some understanding of the terms used and the core functions. To this end, my personal opinion is to use a language like the old (not Visual) BASICs.
It is sad that BASIC has fallen out of favor now. Complaints of bad code, lack of power, and old age have tarnished its good reputation with little real reason. Most of the complaints I hear stem from seeing BASIC code in environments where it simply doesn't make sense. As an educational tool, it's the perfect introduction.
If I were ever to teach such a course, the first day would be a simple program, that just ENDs. Consider the basic concept there. The program starts at the beginning and runs until it's told to stop. It runs a single command. Such a simple program also allows time to understand the process of compiling. Next, I would introduce data, using a Hello World program (with an END statement, of course). There, we get data, output, and commands running in series. Again, these concepts are things we take for granted, but are of vital importance.
I'd move on to input, assigning variables, order of operations (8th grade WAS good for something!), and probably some basic conditions. If I were really into it, I'd throw in some logical operations for good measure. With the commands being in plain English, it's easier to ignore the details of the language, and focus on what the statement actually does. Best of all, there's no extra code with no apparent purpose. No importing or including libraries at the top of the program, no class declaration, just meaningful code.
After that comes the most important part of any BASIC curriculum: abandoning BASIC. Move to functions, or objects, or whatever popular concept strikes your (or better yet, the students') fancy, and don't return to BASIC again. By that time, the student should have a solid understanding of how general programming works, so they can focus on adapting to whatever paradigm comes next. In fact, I'd recommend against even telling the students they were using an unstructured language. Use BASIC as a way to understand the code itself, before trying to understand how it fits into the big picture of the program.
You do not have a moral or legal right to do absolutely anything you want.
http://www.pbm.com/~lindahl/real.programmers.html
No sig today...
Reading the paper on HtDP, and one of the funniest conclusions is that female students seem to prefer the HtDP approach over traditional SICP or "Welcome to Java" classes by a factor of 4.
Maybe the lack of girls in Computer Science has just been because the teaching has sucked.
That's "declarative" programming. Popular functional languages tend to be more declarative, but it doesn't have to be that way.
C is not a simple language.
// do something
// do something
.. 10 loop
// 20 lines of something
// 20 lines of some more
The C language specification is 500+ pages and a horrible read. C only appears simple on the surface but is full of nasty hidden surprises. The later being the reason why the language standard is such a horrible read.
I also disagree with you on the base of the for loop. The C for loop is just a while written on one line. Syntactic sugar without additional abstraction. And even as syntactic sugar a failure because you don't save any keystrokes. Compare:
for (int i = 1; i < 10; i++)
{
}
with:
int i = 1;
while (i < 10)
{
i++;
}
2 characters and 2 Enter keys less - what a saving!
compare that to the following Ada code:
for I in 1
-- do something
end loop;
Ok, it does not save keystrokes either - but it does add some higher abstraction and I is constant inside to loop - so no hidden surprises here, like in:
for (int i = 1; i < 10; i++)
{
if (i = 5) i = 6;
}
Which brings us back to "C is not simple but full of hidden surprises".
Martin
Brainfuck is fine. It's Turing complete, right, and the only thing to programming is learning rules, and learning to type.
The real question is, what are you trying to teach? Programming and algorithms would be easy to teach in Python (or a lisp), user interface design would be good in Java or .net (vb or c#), web technologies would be good in Ruby, and systems programming would be good in C.
Are you trying to teach software development? What other things can you get students to memorize (or "learn", as fashionable people like to say - there is not much difference since education is in a controlled environment - yes I know that good teaching can make a difference). The stages of software development? The rules of XP? Scrum terminology? How about svn?
How can anyone seriously consider a language that is MISSING almost all of the modern features needed to express your programming intents?
Write a medium-complexity program like the ubiquitous Towers of Hanoi problem in BASIC, and then in a modern language like Scheme or python. Compare the source code of the two programs and then tell me what language is better for introducing programming concepts.
I cut my teeth on BASIC as well, but really, it's a pretty terrible language for a beginner. The syntax is decent, in theory, but in practice, it's most of the older BASICs had weird little picky things involving spacing and stuff like that. And when you do mess up the syntax, you would only get "SYNTAX ERROR" without any explanation of what was wrong or how to fix it.
Variables don't have to be declared before use, so small typos in variable names cripple programs rather than resulting in compiler errors. This makes it much tougher for new users to debug their own programs.
The syntax also doesn't allow you to separate your code into blocks, so things like IF statements are a pain since they require using a GOTO if you want to do more than one statement. This makes the code harder to read and understand. Spaghetti code is a necessity in most BASICs.
Beyond that, being able to build functions or procedures or subroutines or some form of reusable code is fundamental to teaching intro programming. The GOSUB command exists in BASIC, but it doesn't make sense in any simple way. If you understand already what a subroutine is, then GOSUB makes sense, but otherwise, it's just confusing. Named function/procedure calls are much cleaner and easier for starting students to understand.
Obviously these issues could be solved by using a more modern BASIC, but then you lose most of the easier syntax because they've complicated it in order to add the new language features.
For starting students, I think what you really want is a language where they don't have to worry about syntax at all, where they can just get used to putting programs together. Languages like Scratch or Alice I think are very nice first languages for students to learn. Unfortunately, Scratch lacks procedures and it's difficult to build completely new projects in Alice because you have to understand things like where to place the lights and the camera in a 3-d world.
Alternately, a language like Logo which has fairly light-weight, but consistent syntax is also useful.
Right now, I'm working on modifying Scratch to meet my needs for teaching introductory programming. Specifically, I'm seeking to add user-defined functions/procedures and to be able to make projects for students to complete where they have a goal to accomplish and have a limited set of statements available to complete it.
In teaching Intro to Computer Science using Logo, I've found that a few students will want to just use Forward, Left, Right, Pen Up, and Pen Down to accomplish everything, even situations where they really should be using Repeat statements or building procedures. I want to add in a mechanism such that they'll need to use those tools to solve the problem. So if their task is to draw a square and they only have two "Forward" statements and two "Right" statements available, but they have a "Repeat" which they can use, then they'll learn to use the Repeat by necessity.
Plus, by limiting the search space, they're more likely to be able to find an answer by trial-and-error at first. In the long run, you don't want people programming by trial-and-error, but that's how most all of us learned to begin with.
You're out of your mind.
At that stage in the game, the budding student doesn't even understand what he doesn't understand, so he has no ground for knowing whether his previous self-taught, website, book, mentor, or school-provided education is gold or garbage.
A good professor will take people from ground zero on day one and move at a blistering pace that still lets the hard workers keep up. I started a college CS program not knowing anything of the discipline, with two good friends that basically slept through the first two semesters and got better grades. I graduated from the program, and they did not.
Your elitism is misplaced.
Strange that you say that, because I've always considered most human directions to be far more declarative than imperative.
For instance, "go to the store and buy milk". If you were to try to reduce that to imperative instructions, it would be a nightmare. In fact, nobody has done it, because it's so hard to describe in terms of the myriad possible states and branches.
Along the way, you do all kinds of optimization, too. If there's traffic on the main street, you might take side streets. If one checkout line is longer, you might choose the shorter one. If one brand is on sale, you might buy that one.
Social scientists are inspired by theories; scientists are humbled by facts.