Interpreter?

This is a discussion on Interpreter? within the C++ Programming forums, part of the General Programming Boards category; Hi all, this justa question for you all, I use a compiler for my programs that works great, but my ...

  1. #1
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,479

    Interpreter?

    Hi all, this justa question for you all, I use a compiler for my programs that works great, but my dad told me that if I got an interpreter installed, it would check the code line by line to scan for errors, I do know interpreters exsist, but, do you think I should stick with my Dev C++ compiler anyway and just tell my dad he doesnt know what he's on about, I heard interpreters are great for beginers, but they slow the execution down

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    but my dad told me that if I got an interpreter installed, it would check the code line by line to scan for errors,
    Doesn't your compiler do that?

  3. #3
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,479
    Yes it does, but I heard an interpreter checks it as you type it, not show you all the errors in one go like a compiler does

  4. #4
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    Yes it does, but I heard an interpreter checks it as you type it, not show you all the errors in one go like a compiler does
    I've never heard of that, which doesn't mean a whole lot.

  5. #5
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    >>Yes it does, but I heard an interpreter checks it as you type it, not show you all the errors in one go like a compiler does

    I can believe that, but it can also be annoying as hell depending on how it's done (just look at VB - you can't click anywhere until you've finished the line, otherwise it pops up a messagebox whining about a syntax error and sends you right back). Besides, all that changes is that the interpreter detects 'syntax errors' while you're typing, and the compiler detects them after you're done; as long as you learn what the compiler errors mean, and start from the first one and make your way down the list re-compiling after fixing each error, a reputable compiler will probably even work better than an interpreter, especially in terms of standards compliance.

    And, as for running through the code line by line, any decent debugger should allow for this anyway.

    If you really like using an interpreter though, it doesn't mean you have to get rid of your compiler - you can write your programs and test them in the interpreter, and compile them later when you're done and want to distribute them.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  6. #6
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    There is to the best of my knowledge no C++ interpreter in existence. Certainly there is not one that checks syntax as you type.

    Neither would you need an interpreter for that, just a source parser.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #7
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    Overall, you're better-off sticking with your up-to-date popular compiler. I don't know of any C++ interpters. (I haven't searched.)

    But, your dad is right. My first computer, a Commodore 64 had a BASIC interpreter in ROM. My first PC came with a BASIC interpreter too.

    The interpreter runs one line at a time. When you hit a run-time error, the computer would report the line it was running when the error occurred. (Your debugger can simulate this... but that adds another layer of shtuff you have to learn.)

    There were no linker errors... There was no linking!

    I heard interpreters are great for beginers...
    And, you are right too. That was a great way to learn the concepts of programming... statements, variables, loops, conditional branching, etc. But, those days are over. Now, you are almost forced to start-out with a more complex language and more complex tools.

    ... but they slow the execution down
    Right again! The CPU has to convert each line to machine language before it can run that line. Besides converting the code to machine code in advance, a compiler can optimize by "looking-at" more than one line at a time... It can optimize a loop. An intrepeter can only "see" one line of the loop at a time.

    Another disadvantage is that the intrepeter has to be loaded and running before you can run the application. If you give the program to a friend, you'll have to give him/her the intrepeter too, along with instructions. ...Or, you can compile it first!

    With a compiler, the trick is to test-compile and test-run you program as you are writing it. Beginners should only write one or two lines of code between tests. Modern compilers and fast computers make this quick and easy. (In the old days, programmers would take a coffee break while their program compiled... Or maybe a lunch break.. or maybe they would let the compiler run overnight! )

    It takes a bit of practice to learn which lines to add each time... If you just write the first 5 lines of code, the program won't compile... You have to write empty-loops and empty-functions, and fill them in a few lines at a time, etc. Learning to program is a lot more fun when you know where to look for the errors.

    Professionals use the same technique. As you gain experience you can write more lines of code (i.e. whole functions) before test-compiling and test-running.
    Last edited by DougDbug; 06-10-2005 at 01:45 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Interpreter Features Question
    By audinue in forum C Programming
    Replies: 0
    Last Post: 10-19-2008, 08:29 AM
  2. Unix Command Interpreter Help
    By ashford74 in forum C Programming
    Replies: 14
    Last Post: 09-26-2008, 04:28 AM
  3. interpreter
    By abuashraf in forum C Programming
    Replies: 4
    Last Post: 04-01-2008, 10:10 AM
  4. Replies: 0
    Last Post: 04-06-2007, 05:55 PM
  5. Most pointless idea ever: Interpreter
    By Trauts in forum C++ Programming
    Replies: 5
    Last Post: 02-09-2003, 06:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21