Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Learning programming languages

  1. Dec 7, 2015 #1
    Dear PF Forum,
    I read this link
    That makes me think, "How, straight with C++, do we teach programming language to someone who never knows progamming language?"
     
  2. jcsd
  3. Dec 7, 2015 #2

    phinds

    User Avatar
    Gold Member
    2016 Award

    By "straight with C++" do you mean teaching someone who knows nothing about programming the OOP aspects of C++ without their knowing any of the sequential programming basics? If that's what you mean, I think it could only be done at a conceptual level. That is, you could give them a fair amount of solid information about the principles of OPP constructs but it would be a terrible approach to have them try to do useful programming from that point without their first going back and learning the basics of sequential programming.
     
  4. Dec 7, 2015 #3
    I mean like your quote before Phinds.
    Teaching the "c" first than later (much later) the "++".
    I really love BASICA
    No procedures, just line numbers.
    No variable definition.
    It's the easiest language to teach someone about programming language.
    Later when they know how to program, we just skip GOSUB, RETURN, DEFINT, DEFDBL, DEF SEG, PEEK, POKE, and go straight to Pascal.
    And introduce them with just:
    Code (Text):
    program MyFirstProgram;
    { all variables here }
    { all goto Labels here }

    begin
    { all the instructions here }
    end.
    I call this BASICing Pascal.
     
  5. Dec 7, 2015 #4
    But on secound thought, I think it's wrong to introduce GOTO for someone who wants programming language for the first time.
     
  6. Dec 7, 2015 #5

    jtbell

    User Avatar

    Staff: Mentor

    When I taught an introductory programming course using C++, I used the following sequence, more or less:
    1. The basic process of writing, compiling and running programs (i.e. how to use programming tools), using very simple "Hello, world!" type programs that just do text output.
    2. Variables: int and double for numbers, and strings for text data. (Not char arrays and pointers; I used the 'string' data type.).
    3. Programs with both input and output.
    4. If-statements and loops.
    5. How to use functions that have already been written for you, e.g. library functions from the standard library.
    6. How to use member functions of objects that have already been written, e.g. strings and other objects from the standard library: myname.length() gives you the length of myname, etc.
    7. Grouping data together into vectors (I prefer these to plain old arrays) and structs.
    8. How to write your own functions, and design programs effectively using functions to organize tasks and sub-tasks.
    9. How to write your own classes (objects), and their member functions, and design programs to use them to organize your data and the actions that you do with them.
    I've probably left something out; it's been ten years since I last taught that course.
     
  7. Dec 7, 2015 #6
    Good steps.
    But I didn't see pointer?
    I find nowadays programmers don't know much about addressing modes.
    I am lucky, I ever studied programming in DOS.
    At least I can tell that in pascal: A = B + C; that would be
    mov AX,
    add AX,[C]
    mov [A], AX
    And all those segment : offset
     
  8. Dec 8, 2015 #7

    jtbell

    User Avatar

    Staff: Mentor

    I didn't do pointers until near the end of the course. Using the standard string data type means you don't need char*. Using vectors instead of arrays eliminates another place where pointers come up early in C. When passing stuff to functions I used references instead of pointers. The only thing left where pointers made sense was dynamic memory allocation using 'new' and 'delete'.

    In fact, I remember having trouble coming up with a situation involving dynamic memory allocation that I could use to motivate introducing pointers. "OK, here's what I'd like to do, but none of the tools we've learned so far can accomplish it. So here's something new: pointers." I don't remember what I used. (Hey, it was ten years ago!) Probably something involving linked lists.

    The guy who taught the upper-level computer science courses told me not to worry about it if I didn't do much with pointers. The students would study them in the computer architecture course anyway. That's where they did stuff like assembly language, addressing modes, etc.
     
  9. Dec 8, 2015 #8
    "Nothing can accomplish it" A very good phrase for pointer introduction. I remember, 20 years ago I used to teach programming language when I was in college for some cash. Just fire the pointer away.
     
  10. Dec 8, 2015 #9

    Mark44

    Staff: Mentor

    As I recall from many years ago, BASICA (and GWBASIC and several other variants of BASIC) had subroutines (called with GOSUB) and functions.
     
  11. Dec 8, 2015 #10

    Mark44

    Staff: Mentor

    Nope, that isn't Pascal. For assignment, you use := .
    Your first MOV instruction is missing something.
     
  12. Dec 8, 2015 #11
    Sorry, you have sharp eye, Mark!
    I typed to fast I think. I have been using pascal since 1990.
    Code (Text):
    var
      A,B,C: Word;
    begin
      A:=B+C;
      { assembly equivalence
      mov AX,[B]
      add AX,[C]
      mov [A],AX
      }
    end.
    Should use Word or Integer in Turbo Pascal works fine. In Delphi, should be Word.
    A little try (just try that this very time. 'Integer' doesn't work in Delphi in asm mode }
    Code (Text):
    var
      A: Integer;
      B: Word;

    begin
      B:=A; //works
      asm
        mov AX,A // syntax error
      end;
    end;
     
  13. Dec 8, 2015 #12
    I couldn't agree more. I started with BASIC on a C64 and produced nothing but spaghetti code just because it was possible. As BASIC was too slow to do something useful I then switched to assembler. That made it even worse. Learning programming this way was a really bad idea.
     
  14. Dec 8, 2015 #13
    What bad idea? Using GOTO or go straight to assembly after BASIC?
    Judging your first programming language is BASIC, I think you learned it at the 70's. If you study programming language in the 50's you'd be lucky just to have the punched card FORTRAN
     
  15. Dec 8, 2015 #14
    Starting with programming languages that doesn't force me to structured programming.
     
  16. Dec 8, 2015 #15
    But I find BASIC is very useful to teach someone the first programming language.
    After the pupil is experienced enough. Writing a pascal triangle or fibonacci sequence, he/she should immediately be taught Pascal, then after that, is just choices.
     
  17. Dec 8, 2015 #16
    That's what it is purposed for. And with a BASIC dialect that does not include GOTO it is even useful to teach good programming from the beginning.
     
  18. Dec 8, 2015 #17
    Couldn't agree more. NO GOTO, GOSUB. At least not GOSUB. Switch to Pascal before GOSUB.
     
  19. Dec 8, 2015 #18

    Mark44

    Staff: Mentor

    Why Pascal? I might be wrong, but as far as I know it's pretty much a dead language. After doing a little searching, I find that it still exists, though, as Delphi, which Borland sold off in 2008 to a company named Embarcadero.

    I don't know of many schools that teach Pascal/Delphi, and we don't get a lot of questions about it here, so it would seem that not a lot of people are writing code with Pascal/Delphi.
     
  20. Dec 8, 2015 #19

    Mark44

    Staff: Mentor

    Although the use of goto often leads to unreadable "spaghetti" code, and was excoriated in a paper by Edsger Dijkstra in 1968, its use is recommended in certain instances, such as for "end-of-function error handlers and for multi-level breaks from loops." -- Per Dennis Ritchie and Brian Kernighan from wiki article in link below.

    https://en.wikipedia.org/wiki/Goto
    Some quotes from Steve McConnell, in "Code Complete", pp. 348-349.
     
  21. Dec 8, 2015 #20
    Embarcadero still sells it for prices that nobody would pay just for fun. Thus there seem to be some professional users left. But I would also say that it is close to extinction.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook