Stories
Slash Boxes
Comments

News for nerds, stuff that matters

Slashdot Log In

Log In

Create Account  |  Retrieve Password

Best Paradigm For a First Programming Course?

Posted by kdawson on Tue Dec 09, 2008 10:57 PM
from the buddy-can-you-paradigm dept.
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?"
+ -
story

Related Stories

This discussion has been archived. No new comments can be posted.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More
Loading... please wait.
  • All of them. (Score:5, Insightful)

    by Tokerat (150341) on Tuesday December 09 2008, @11:02PM (#26055371) Journal
    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.
    • Re:All of them. (Score:5, Insightful)

      by dcollins (135727) on Tuesday December 09 2008, @11:10PM (#26055423) Homepage

      Unfortunately, they can't all be first.

      • Re:All of them. (Score:5, Insightful)

        by mbrubeck (73587) on Tuesday December 09 2008, @11:55PM (#26055747) Homepage

        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:All of them. (Score:5, Insightful)

          by DerekJ212 (867265) on Wednesday December 10 2008, @12:05AM (#26055813)
          That explains why so many kids drop out of CS. I was greatly interested in the subject, but if my CS101 class had tried to throw all that at me and expect me to really grok it all in a single class, I would have been looking for a different major/school.
        • Re:All of them. (Score:5, Interesting)

          by i.of.the.storm (907783) on Wednesday December 10 2008, @12:16AM (#26055873) Homepage
          That's similar to what my first college CS course has been like. We used SICP [mit.edu] and it was a really interesting semester. We did functional, OO, client/server, and logic programming (or well those were the 4 paradigms that the prof considered the main ones) and it was pretty interesting. Since most people came in with OO experience only, doing functional programming through people for a loop at first. Of course, we did it all in Scheme, which is a cool language, too.
          • by Anonymous Coward on Wednesday December 10 2008, @01:22AM (#26056307)

            doing functional programming through people for a loop at first.

            Wow, that sounds pretty advanced. Functional programming, with loops, through people. I've never even heard of that new paradigm.

        • Re:All of them. (Score:5, Insightful)

          by martijnd (148684) on Wednesday December 10 2008, @12:44AM (#26056039)

          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.

  • Functional (Score:3, Insightful)

    by Anonymous Coward on Tuesday December 09 2008, @11:03PM (#26055377)

    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.

    • Re:Functional (Score:4, Insightful)

      by Anonymous Coward on Tuesday December 09 2008, @11:15PM (#26055469)

      The methods within an object are, of course, functional.

      Despite omnipresent side effects?

        • Re:Functional (Score:5, Insightful)

          by aiht (1017790) on Wednesday December 10 2008, @12:21AM (#26055911)
          "Functional programming" != "Program with functions in it"
          • Re:Functional (Score:4, Insightful)

            by gandhi_2 (1108023) on Wednesday December 10 2008, @12:45AM (#26056051) Homepage

            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.

    • Re:Functional (Score:5, Interesting)

      by El Cabri (13930) on Tuesday December 09 2008, @11:18PM (#26055491) Journal

      There are no two things more opposite to each other than OOP and functional programming. Functional programming is about FUNCTIONS, which are those that return a value that is completely determined by their arguments, not depending on, or modifying, any state. OOP is all about calling METHODS, which have values that are determined by both the arguments and the state of the object they're called on, and often are meant to modify that state.

      • Re:Functional (Score:4, Interesting)

        by Eli Gottlieb (917758) <<moc.liamg> <ta> <beilttogile>> on Tuesday December 09 2008, @11:51PM (#26055723) Homepage Journal

        And yet in an impure functional language a set of closures closing over the same variables are equivalent to an object with those functions implemented as methods.

      • 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:Functional (Score:4, Informative)

        by dkf (304284) <donal.k.fellows@manchester.ac.uk> on Wednesday December 10 2008, @04:22AM (#26057135) Homepage

        There are no two things more opposite to each other than OOP and functional programming. Functional programming is about FUNCTIONS, which are those that return a value that is completely determined by their arguments, not depending on, or modifying, any state. OOP is all about calling METHODS, which have values that are determined by both the arguments and the state of the object they're called on, and often are meant to modify that state.

        Not at all. I have used a pure functional OO language in the past (the name of which I forget) and what it did when you did an operation that would "modify the state" is return the new state as the result of the method. The same would be true for any language where all objects are immutable and variables are immutable.

        "Functional" means that the answer to an operation is determined entirely by the arguments to the operation and the nature of the operation itself, and that the operation does not change the state. (Functional languages are usually written in pseudo-mathematical notation, but not always.) "Object-oriented" means that your values (often structured values) know exactly what operations can be performed upon them that don't just see the object as an abstract token, that they encapsulate that notion, and that the language is written in "subject verb" form, not "verb subject". (That last point is just syntactic, but important.) Those two are entirely orthogonal properties.

        Obviously, you've mixed up "OO" and "Imperative OO"; imperative systems are all about state modification.

    • Re:Functional (Score:5, Insightful)

      by johnsonav (1098915) on Tuesday December 09 2008, @11:55PM (#26055753) Journal

      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.

  • Both (Score:3, Insightful)

    by nog_lorp (896553) * on Tuesday December 09 2008, @11:04PM (#26055381)

    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.

    • Re: (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

    • Re: (Score:3, Insightful)

      ...C and then Java. Several projects require writing the same program in each language.

      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!

  • by HFXPro (581079) on Tuesday December 09 2008, @11:05PM (#26055385)
    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.
    • Re: (Score:3, Insightful)

      I should mention anyone who is trying to peddle python against java against c are all barking up the wrong tree. Those are really all the same class of languages and offer no benefits over the other in terms of good practice, smart thinking, and great design.
      • by calmofthestorm (1344385) on Tuesday December 09 2008, @11:28PM (#26055583)

        I'm not sure of that, actually. C is not at all functional, and Java is only to a limited degree. In Python, all functions are first-class values. This means you can mix paradigms in a program. You have fully functional closures and capture.

        I grew up on asm and C, now I write Python that looks more like Lisp or Haskell. In the end, I'd say either procedural programming or functional for introduction to programming. OOP is kind of verbose and clunky for an intro class, and while it certainly has its uses in large scale projects, when we were taught it in school I just saw a bunch of cruft obscuring the (simple) tasks that were assigned.

      • by francium de neobie (590783) on Wednesday December 10 2008, @12:34AM (#26055981) Homepage
        Really? Last time I checked...
        1. There's no need to wrap a closure in a "function class" in Python. And I don't have to cast everything down to Object every so often. So while, theoretically, you can do functional programming in both Java and Python, in practice it is much easier in Python.
        2. There's no need to wrap the "main()" function in a class in Python - in fact, I can go without writing the main(). Looks like a minor point but it saves a good portion of your time for trivial programs. Also, I don't need to compile it.
        3. I have list and dictionary literals; I don't have to care what is the "type" of the list and dictionary when I create it - type of elements can be examined by duck typing or isinstance() if I need to - but usually it isn't needed; list comprehension is a really good time saver, makes the code easier to read as well.
        4. I have an interactive command line for doing experiments. I can even read manuals in the command line via the help() function.
        5. I have exec() in Python. It isn't as useful or as dynamic as eval() in Lisp, but that's something Java definitely cannot do on a language level. Sure, you can write a library that calls the Java compiler real time to emulate that... but I'm talking about the language itself.

        Doesn't look very "same class" to me. At least when I'm considering which language to use for solving which problem.

      • [C, java, python] are really all the same class of languages

        Really? For three "identical" things, I think they're quite far apart.

        C doesn't have native support for object-oriented programming. If you want to teach the students that, you need to embed pointers to vtables everywhere, you need parent-objects-as-members and you need massive hacks.

        Java doesn't have higher-order functions; you have to put your function pointer arguments inside classes. [C at least has function pointers]. By insisting that everything is put inside an object, procedural programming "looks OO" and might distort the students' view of what "real OO" is.

        Python doesn't have static types. On the other hand, it lets you teach procedural and object-oriented each in their most natural ways. It also lets you teach ideas that will recur in functional languages, such as higher-order functions, closures and lazy lists.

        More importantly, python lets you teach things without having to introduce a lot of overhead: "Why must closed-over variables be final? Why is it smart to feed my own anonymous Function class to MapIterator--a for loop is much shorter? Higher order--but it doesn't take a function, it takes an object! ..."

        I'd advocate python first, because it allows you greater flexibility in the choice of what to teach. Also, it's good for teaching algorithms: http://www.ece.uci.edu/~chou/py02/python.html [uci.edu]

        "The most encouraging part was that more than a few students wanted to implement the algorithms that were not assigned as homework problems. The students said they wanted to see the algorithms run and test their own understanding."

  • by EmbeddedJanitor (597831) on Tuesday December 09 2008, @11:07PM (#26055407)
    Give them a good understanding as to what is going on under the hood. It really helps them to connect the dots and really helps in the understanding of compiler/OS design, and basic concepts like "what's a stack?".

    Choose a simple 8-bit micro such as an AVR first, or an ARM. Something with a RISC architecture is nice and clean.

    Introduction to programming isn't what it used to be. Twenty or thirty years back that was often the first exposure a student had to programming. These days you'd be seriously concerned if a student showed up to a programming course and hadn't dabbled a bit at home.

    • Re: (Score:3, Informative)

      I'm going to agree with that. I had programmed in an imperative to mildly GOSUBby way in various microcomputer BASICs, Pascals, and standard Cs since pre-Kindergarten. However, one of the best college classes I had was the one where we were given a 6800 (later classes it was an 68HC11) on a board, with a few external circuits, and we learned every single op-code. Then, I knew what a computer (and a compiler) was doing.

      They'll have plenty of time to learn paradigms. Make them appreciate what those paradig

    • Amen, brother (Score:4, Insightful)

      by istartedi (132515) on Wednesday December 10 2008, @01:25AM (#26056325) Journal

      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?

  • Teach them All (Score:5, Informative)

    by Maple Syrup (27770) on Tuesday December 09 2008, @11:15PM (#26055471)

    The classic text SCIP [wikipedia.org] teaches multiple computing paradigms [mit.edu]. A fluent computer scientist should know all of them.

  • Linguistics (Score:4, Interesting)

    by denissmith (31123) * on Tuesday December 09 2008, @11:17PM (#26055489)
    Ways that meaning are encapsulated in different human languages can be a useful way to demonstrate the structural underpinnings of programming languages. Linguistics is more interesting than reading Boole and gives you a way to think about larger structures without tying you to a particular paradigm. All computer languages have strengths, all are inadequate. But so are human languages. There is a Korean word that expresses this exactly, but it doeasn't translate directly into English. :-)
  • Consider Python (Score:5, Informative)

    by Fished (574624) <amphigory AT gmail DOT com> on Tuesday December 09 2008, @11:19PM (#26055497)

    First off, a disclaimer: I'm actually not (much) of a Python programmer--I much prefer Ruby.

    However, my Dad teaches Math & Physics at the high school level, and got tapped to teach an intro to programming class this year. On my advice, he bypassed C++ (which he kind of knew) and Java, and taught it in Python using this book:

    He has been absolutely delighted with the book and with how well the students have done with Python as a first language. His comment has been that he wishes he had been exposed to Python instead of (many years ago) Fortran and (more recently) C++ -- he might have actually learned to program. ;) It seems that Python's a good choice--it's an easy language to learn, supports procedural, object-oriented, and functional programming, and has all the usual advantages of a dynamic language for programmer usability.

    Now if only they would do a version of that book in Ruby... :)

  • by ishmalius (153450) on Tuesday December 09 2008, @11:19PM (#26055505)

    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.

  • by rolfwind (528248) on Tuesday December 09 2008, @11:20PM (#26055511)

    Maybe even scheme although it is sometimes too minimalistic. Some languages such as C naturally incline toward a specific structure like imperative, some don't. But avoid C unless they are expected to write low level code.

    Why? Because out in the "real world", you are usually assaulted with C or it's derivatives. Not because these are the best languages, but they were faster when developed and took a strong foothold over the thinking of the programming community. It's rather a self perpetuating cycle like Microsoft Windows and operating systems. Another reason is that C/C++ is low level language masquerading as a high level one, with libraries to cover some of it's more glaring defiencies.

    Yes, they'll eventually have to learn C/C++ or a descendant, but that is not the point: it is because they'll have to learn C/C++ that you should teach them something else. Otherwise once you teach them C, mental inertia takes over and they'll be stuck in the C mindset for the rest of their lives and cannot imagine anything else. They'll have time enough to learn C in sophomore or later levels.

    Also, I wouldn't worry too much about "paradigms". Learn to attack problems one by one, making a program that fits each one best. Throw a lot of small coding problems at them, actually, to scale them up to bigger tasks. Thinking about a problem is great, but no reason not to learn coding by coding. I remember Paul Graham writing he never had used Object Orientation his entire life, although it would have seemed that some problems were initially screaming out for such a solution on paper. IMO, paradigms are usually taught as a way to evolve or grow a program an ongoing problem, so you don't end up with sloppy, spaghetti code - but I think experience and getting to see the big picture is more important than rigid paradigms. Afterall, most paradigms grew up from an person's experiences with one or a set of closely related problems that may not closely relate to another random set of problems.

    Stuff like rabid prototyping, etc, are in view more common sense (and better coding methods) than an exact paradigm.

  • None of them. (Score:5, Insightful)

    by Metasquares (555685) <slashdot@metasquared . c om> on Tuesday December 09 2008, @11:22PM (#26055525) Homepage

    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.

  • by mrchaotica (681592) * on Tuesday December 09 2008, @11:26PM (#26055563)

    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.)

  • by _greg (130136) on Tuesday December 09 2008, @11:32PM (#26055613)

    I recommend learning at least two languages representing significantly different paradigms during a programmer's formative period. In this instance I consider C, C++, Java, C# and the lot to be in the same paradigm - procedural.

    Haskell is a good language for exploring the functional paradigm. Smalltalk is good for object oriented. There are many good Prologs for learning logic relational programming. I recommend that a new programmer avoid multiparadigm languages until they have seriously explored programming in a more pure way in two or more paradigms.

    I used to recommend SICP, now I recommend CTM [ucl.ac.be].

    Also important is to (1) enjoy the programming you are doing and (2) work on programs which do interesting things and get you feedback from others.

  • by toby (759) * on Tuesday December 09 2008, @11:35PM (#26055633) Homepage Journal

    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.

  • by GaryOlson (737642) <slashdot.garyolson@org> on Tuesday December 09 2008, @11:38PM (#26055651) Journal
    Take a little from every one. Then promise you can deliver in whatever language your prospective future employer wants.
  • by blackcoot (124938) on Tuesday December 09 2008, @11:48PM (#26055715)

    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.

  • by micromuncher (171881) on Wednesday December 10 2008, @12:02AM (#26055783)

    I went to an unnamed university that did not teach languages specifically. First year was theory, basic architecture, and PDP11 assembler on a simulator. There was one introduction to structured programming with Pascal.

    Year two saw more theory including algorithms and data structures. The language chosen was modula-2 and we were expected to pick it up on our own. There was another low level course on hybrid 6502/68000 machines writing low level I/O in assembly. Again, we had to pick it up ourselves.

    Year three got fun with hardware; async circuits, build your own 68000 based computer, OS (multitasking) and database concepts. We also had our new software engineering courses learning all about CMM and such.

    Fourth year was simulation, HCI, write a compiler, and special projects. It was assumed we'd picked up C/C++ by that point on our own.

    There were three streams at our U; hardware, computer graphics, or knowledge sciences. There was a lot of math - that I didn't appreciate until after I left. But one I learned is why and how things work at a low level. It was a computer science degree.

    Programs like this don't seem to exist anymore; at least if they do they're more in engineering than compsci. This is really too bad. Because as one post already noted; the problem is one of problem solving vs. skills to get a job.

    I still use state machines, optimization, algorithms, data structures knowledge in everything I do. Most of the people I work with have no idea why I care about such things, but usually they're impressed that my stuff just works more better.

    IAE my advice to you is learn as many languages as you can because no one specific language or paradigm encompases computer science. Go do some lisp, smalltalk, java, and assembly programming... you'll see what I mean.

  • by Spazmania (174582) on Wednesday December 10 2008, @12:02AM (#26055789) Homepage

    I like C. I'm a C maven. But I'm *really* glad I didn't learn C first. My first programming courses were taught in Pascal. The good habits I learned there have saved me from writing really poor code when I graduated to more flexible languages like C.

  • Math (Score:3, Interesting)

    by spydabyte (1032538) on Wednesday December 10 2008, @12:04AM (#26055805)
    The basics of all computing, why we started building circuits, was mathematics. Algorithms was originally "dirty math" but now contains some of the most elegant mathematical proofs ever, due to the expansion of computing.

    An era ago computing majors were unheard of, they were applied mathematics majors.
  • by gordguide (307383) on Wednesday December 10 2008, @12:13AM (#26055849)

    " ... I'm interested in language-independent opinions that Slashdotters might have on this matter. ..."

    Slashdotters don't have any language-independent opinions. Sorry.

    • Brainfuck.
    • Re:The Basics. (Score:5, Insightful)

      by Sarten-X (1102295) on Wednesday December 10 2008, @01:47AM (#26056433) Homepage

      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.

      • Re:The Basics. (Score:5, Interesting)

        by smallfries (601545) on Wednesday December 10 2008, @06:15AM (#26057825) Homepage

        It sounds like you've missed the point. Not all languages operate on statements, with variables and assignment. These are common to imperative languages, which all fall under a single paradigm. The submitter asked which paradigm would be best to introduce someone to programming.

        Your lack of experience in other paradigms (not meant as a slight, 99% of all mainstream work is done in imperative languages) means that you have a similar educational history to what the submitter is considering. You consider imperative languages to be the whole world, rather than just a subset of it.

        Logic, or functional languages are very different. Learning them forces you to consider other approaches to programming than those that are evident in an imperative language. Making someone learn a functional language first can teach them a lot about programming in general. Especially when they move over to an imperative language, but they have a different bag of tricks to apply to problems.

        One of the first languages that I learnt as a child was Logo. It's a bit of style these days, although it was fairly common back on 8-bit home computers. At the time I though of it as a bit weird in comparison to the other languages that I used, but it taught me to think about programming in a different way. It is only with the hindsight of 20 years and a degree that I can see that "weirdness" was because it was functional.

    • by El Cabri (13930) on Tuesday December 09 2008, @11:23PM (#26055535) Journal

      +1 for that.

      I love functional programming but let's face it, computers are state machines and you cannot really program them without understanding how programs modify their state. Hoare. Dijkstra. Read them. Embrace them. Feel the pain of bending your mind around them.

    • by krischik (781389) <krischik&users,sourceforge,net> on Wednesday December 10 2008, @03:26AM (#26056871) Homepage Journal
      C is not a simple language.

      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++)
        {
        // do something
        }

      with:

      int i = 1;
      while (i < 10)
        {
        // do something
        i++;
        }

      2 characters and 2 Enter keys less - what a saving!

      compare that to the following Ada code:

      for I in 1 .. 10 loop
        -- 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++)
        {
        // 20 lines of something

        if (i = 5) i = 6;

        // 20 lines of some more
        }

      Which brings us back to "C is not simple but full of hidden surprises".

      Martin