Best Paradigm For a First Programming Course? 592
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?"
All of them. (Score:5, Insightful)
Functional (Score:3, Insightful)
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.
Both (Score:3, Insightful)
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.
Functional languages are phenomenal. (Score:5, Insightful)
well update them.... (Score:2, Insightful)
"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!
Re:Functional languages are phenomenal. (Score:3, Insightful)
Re:All of them. (Score:5, Insightful)
Unfortunately, they can't all be first.
Dumbest ask slashdot ever.. (Score:1, Insightful)
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 [slashdot.org].
Re:Both (Score:3, Insightful)
When I went to university, the first course was in C - which was basically just preparation for the second course, which was in Assembly (specifically, MIPS). I'd say that was the most important part - a good grasp of the fundamentals of computing is really the best thing that you can take away from university. From there, all of the languages (and even paradigms - we covered the main three) were quite a bit simpler to grasp, as you could look a little deeper into them and ask "What are we really doing here?". Stripping away the mystery of compilers and interpreters simplifies understanding dramatically.
Re:Functional (Score:4, Insightful)
Despite omnipresent side effects?
Re:Assembler... seriously (Score:2, Insightful)
Structured programming (Score:3, Insightful)
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.
None of them. (Score:5, Insightful)
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.
SCHEME, FOR THE LOVE OF GOD, SCHEME!!!!!!!!!! (Score:4, Insightful)
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.)
Re:Assembler... seriously (Score:2, Insightful)
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.
"excessive" reliance on libraries!?? (Score:3, Insightful)
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.
Re:Both (Score:3, Insightful)
Wow, how fucking useless can you get?! I'll bet half the students wrap their C code in a class and think they're done.
Now, if they had to write their programs in LISP and Java (or LISP and C), then they'd be getting somewhere!
problem solving first, programming second. (Score:3, Insightful)
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.
Re:All of them. (Score:5, Insightful)
Unfortunately, they can't all be first.
But you can still do several in a first programming course. That's exactly what my intro CS course did. We worked with a functional language, an object-oriented language, a low-level assembly language, a logic programming language, and also theoretical constructs like finite automata.
Re:Functional (Score:5, Insightful)
Definitely functional programming.
I don't think functional programming is the place to start for the majority of students. A procedural language has a much more direct relationship to the underlying machine code. If you don't want to start in assembler (and I don't advocate assembler for a first language for a lot of reasons), a language like C, which is high-level enough to not get bogged down in irrelevant details while teaching basic algorithms, yet is close enough to the metal to give the students a taste of the underlying hardware, is a good compromise. Functional programming, while closer to the underlying math, is so different from the instructions the machine actually executes that students may finish the class and still not have a clear idea how what they wrote directs the machine.
That said, my first development environment was HyperCard and most of what I have done since has been OOP. When thinking about a problem, my first instinct is to objectify it. But, I think OOP involves learning too much at once to be the ideal teaching paradigm. Think of how many lines of OO exist in a Java Hello World program. And think how much of that is meaningless to the student when they're still trying to learn the basics of println.
Re:Functional (Score:3, Insightful)
Remember, we are talking about people who have NEVER programmed before. And teaching them how to do it.
I believe it is easier for someone to first understand how to program with functions, and then, after they are comfortable, to put these functions into a greater "whole", as part of an object.
It really is all about building upon the fundamentals. Functional programming is a fundamental. OOP is building upon that knowledge.
It's just my opinion, though =)
Re:All of them. (Score:5, Insightful)
Re:SCHEME, FOR THE LOVE OF GOD, SCHEME!!!!!!!!!! (Score:1, Insightful)
Scheme and so on are swell and functional programming is cool... ...but name one significant real world application made in such a language.
Just one. Not some horribly obscure thing, but something you can walk into Best Buy and buy off the shelf. Something non-comp-sci dweebs have *heard of*.
*waits*
*crickets chirp*
*birds tweet*
I wager that about covers it.
Don't teach them a functional language. Teach them something *useful*. For better or worse, that's C++ in the real world, or *maybe* java. I don't think C++ is a particularly good language by any means, but it IS a useful language. Other languages have specialized niche applications, but C++ can build pretty much anything fairly well, from low level systems stuff to commercial games.
Well, that's your problem then ... (Score:3, Insightful)
" ... I'm interested in language-independent opinions that Slashdotters might have on this matter. ..."
Slashdotters don't have any language-independent opinions. Sorry.
Not sure about others, pleased with Python (Score:3, Insightful)
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)
Re:Functional (Score:5, Insightful)
Re:All of them. (Score:5, Insightful)
a logic programming language, and also theoretical constructs like finite automata.
Sounds like a great course -- however in most schools the professors will have long given in to the whining "this is not real world" crowd that sadly makes up most entry level computer classes.
Re:Functional (Score:4, Insightful)
someone called you captain obvious...but he/she is captain doesn'tknowthedifference.
functional programming (ocaml, et al) is quite a different thing than procedural. Procedural is imperative with procedures, which are often called functions, which almost sounds like functional programming, which often confuses the fucktard on /. that confused you for cpt. obvious.
yet another attempted plug at upping functional pr (Score:3, Insightful)
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
Your best answer is implicit by our answers.... (Score:3, Insightful)
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.
Re:Functional (Score:1, Insightful)
Apparently it isn't obvious at all. Most of the people in this thread don't know the difference between procedural and functional languages.
Amen, brother (Score:4, Insightful)
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?
Re:The Basics. (Score:5, Insightful)
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.
Maybe I'm being too obscure.... (Score:3, Insightful)
http://www.pbm.com/~lindahl/real.programmers.html [pbm.com]
Re:Teach them All (Score:3, Insightful)
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.
Re:Not at all (Score:2, Insightful)
That's "declarative" programming. Popular functional languages tend to be more declarative, but it doesn't have to be that way.
Only C is not simple (Score:4, Insightful)
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
Re:The Basics. (Score:3, Insightful)
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?
BASIC sucks! (Score:3, Insightful)
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.
Re:The Basics. (Score:3, Insightful)
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.
Re:All of them. (Score:2, Insightful)
That explains why so many kids drop out of CS.
Separate the men from the boys (or some other non-sexists cliché). Granted, we don't want to "scare" people away, but CS isn't/shouldn't be easy, so why slow down from the get go?
Re:The Basics. (Score:3, Insightful)
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.
Re:Weakest Precondition Calculus (Score:3, Insightful)
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.
Re:BASIC sucks! (Score:3, Insightful)
That's one of the things that makes it a good introductory language.
There's a reason why people who started computing in the 1980s are way ahead of people who started computing in the 1990s -- and it's because we all had a BASIC interpreter pop up as soon as we switched our computers on, while the 1990s generation's computers booted into a vastly less powerful DOS shell, and too many of them were sucked into Doom before they ever discovered the joys of qbasic.
Dropping people in at the deep end with classes and objects is crazy, when they don't even grok what a variable is yet. Nobody's suggesting making BASIC the basis of the entire course, but it's a reasonable place to start for the first week or two, while people are still getting their heads round what programming is actually about. Then move onto Scheme to teach them about abstractions. Save "real world" languages like Python and Java until they know something about what's going on underneath all that sugary syntax.