writing an interpreted language

This is a discussion on writing an interpreted language within the C++ Programming forums, part of the General Programming Boards category; Hm, I better avoid one- lined posts then!...

  1. #16
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Hm,
    I
    better
    avoid
    one-
    lined
    posts
    then!
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  2. #17
    Registered User Aran's Avatar
    Join Date
    Aug 2001
    Posts
    1,301
    you people are so hucking filarious.

    way to take something and make a lame joke out of it... sheesh.

  3. #18
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >How difficult would this be to do?
    It shouldn't be terribly difficult, the hardest part would probably be coming up with a grammar for the new language that is both easy to use, understand, and can be broken down into C++ code with relative ease.

    >Will the langauge that i create have any potential for use?
    Probably not unless everyone loves the syntax and working with it. Then it may become widespread and become one of the popular languages...but this is a big if, there are a lot of languages that just don't take off.

    >i'm also looking for someone with a few years of experience
    >with varying programming languages to give me some syntax
    >ideas and general advice.
    The best advice I can give is to make the language as intuitive as you can. If it's easy to figure out then it will be easy to read and write quickly and efficiently. A good example of what not to do is the overloading of keywords and operators in C. The language is very compact, but much harder to understand and easier to mess up with because of things like static meaning two wildly different things based on the context.

    -Prelude
    My best code is written with the delete key.

  4. #19
    Registered User billholm's Avatar
    Join Date
    Apr 2002
    Posts
    225

    Talking

    Relax Aran

    It's nice to have a few good laughs once in a while (and from the other side of the world).

    (Well I've made five lines now yehey!!!)
    All men are created equal. But some are more equal than others.

    Visit me at http://www.angelfire.com/my/billholm

  5. #20
    Registered User billholm's Avatar
    Join Date
    Apr 2002
    Posts
    225
    By the way, Aran, if you're gonna make an intuitive language, try modeling it on BASIC.

    BASIC may not be a choice for most people here, but it is as near as can be to natural language.

    Prelude's right. C is much too complex for intuitive usage even with its relatively small number of keywords. (Thus it would be a confusing model.)
    All men are created equal. But some are more equal than others.

    Visit me at http://www.angelfire.com/my/billholm

  6. #21
    Registered User Aran's Avatar
    Join Date
    Aug 2001
    Posts
    1,301
    hmmm, yeah.. this could quite possibly be a whole hell of a lot of fun to do.

    I've gotta do some research on writing compilers/linkers and i've gotta learn assembly.

    This sounds like it could turn into one hell of a project.

  7. #22
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Well, that is certainly the most thorough way to do it! But believe me, a much more managable project would be to have the compiling and linking done by an existing compiler! Then, all you would have to do is :

    (1) Parse the new language input.
    (2) Generate the C/C++ text.
    (3) Feed the output directly into the command-line of, say, a mingw compiler (not forgetting to specifiy the project name, etc..)
    (4) If the executable compiles, click on it and enjoy!

    BTW: Personally, I do not like the idea of using defines to do the work. My advice would be to parse it.

  8. #23
    Registered User billholm's Avatar
    Join Date
    Apr 2002
    Posts
    225
    Right!

    I've read somewhere that interpreted languages are more versatile than compiled ones. Java (I think) is a interpreted language. That's why it has a good memory management scheme (it has an automatic garbage collector).
    All men are created equal. But some are more equal than others.

    Visit me at http://www.angelfire.com/my/billholm

  9. #24
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    C and C++ ARE interpreted languages! It is only because of the hard work of the developers of the languages that we are able to turn our words into compiled programs. Of course, first the text is interpreted, and then the result is compiled and linked...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  10. #25
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    One line post

  11. #26
    Registered User billholm's Avatar
    Join Date
    Apr 2002
    Posts
    225
    >C and C++ ARE interpreted languages!

    Are you sure about that? I think 'preprocessed' and 'interpreted' mean two different things. C/C++ code is preprocessed (tokenized) before they are compiled. On the other hand, interpreted BASIC is really implemented line-by-line by the 'interpreter'.

    Ten line post!
    All men are created equal. But some are more equal than others.

    Visit me at http://www.angelfire.com/my/billholm

  12. #27
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    >C and C++ ARE interpreted languages!

    There is no such as an interpreted language or not interpreted language. A language is just a mathematical concept. But there are interpreters and compilers. An interpreter is just a piece of software which uses your source code as input, interprets it and runs the code. And a compiler is a piece of software which compiles your source code to machine language.

    >Java (I think) is a interpreted language. That's why it has a
    >good memory management scheme (it has an automatic
    >garbage collector).

    Java is compiled to bytecode. This bytecode is run by the JVM (Java Virtual Machine). The JVM also takes care of the garbage collection.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. d programming language - a better c++?
    By kypronite in forum Tech Board
    Replies: 12
    Last Post: 02-28-2011, 01:55 AM
  2. What Language are you writing in?
    By C-Compiler in forum A Brief History of Cprogramming.com
    Replies: 22
    Last Post: 12-24-2008, 10:51 AM
  3. assembly language...the best tool for game programming?
    By silk.odyssey in forum Game Programming
    Replies: 50
    Last Post: 06-22-2004, 01:11 PM
  4. Language of choice after C++
    By gandalf_bar in forum A Brief History of Cprogramming.com
    Replies: 47
    Last Post: 06-15-2004, 01:20 AM
  5. Enough language discussions.
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 06-13-2004, 09:59 AM

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