Thread: Making Programming Language

  1. #1
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507

    Making Programming Language

    I was taking an assembly class in school and was wondering how exactly I could write my own programming language with it. IE would it be as "simple" as finding my operating system process startup code, and then telling it where to start executing assembly instructions? Or is there much more to writing a "simple" interpreter then throwing in some startup code and translating the language into asm? Thanks!

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Well there's a difference between an interpreted language and a compiled language.

    Basically, you need to write a parser - a program that reads in source instructions (from a file, for instance) and determines exactly what it is trying to say.

    And interpreted language would then just perform that action.

    A compiled language would then be converted into the native code for that platform (machine language).

    So if you want to make your own language, you need to write an interpreter or a compiler for that language - I would recommend doing such a project in C or C++ for a compiler. For an interpreted language - maybe even Java or something like that.

  3. #3
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    Cool thanks. Yah sorry I suppose I was aiming to make a simple compiled language as an experiment. I figured it would be something like just translating my language into the machine code...but once I write all that binary data into a file for instance...how could I find out how to get it executing on say an x86 vista platform? I have read all over that I would need startup code of some sorts.

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Not really.

    There are two completely different issues. One is making the operating system execute code. All that's required for this is to build a binary file that fits the executable format. Windows's PE format is very well documented. You don't need any startup code, really - not unless you have to prepare the environment for your programming language.

    The other is lexing, parsing and analyzing your language and generating code. This is completely different.

    If you want to play around with inventing a language, I really recommend you look into the LLVM project. It gives you a simple assembly-like language that you can use as your codegen target, and takes the tasks of optimizing said code and generating target-specific machine code off your shoulders.
    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

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, 02:55 AM
  2. The value of learning a new programming language
    By h3ro in forum General Discussions
    Replies: 21
    Last Post: 06-13-2009, 01:48 AM
  3. Why C Matters
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 136
    Last Post: 01-16-2008, 09:09 AM
  4. Making a Regional Language..
    By Coder87C in forum Windows Programming
    Replies: 1
    Last Post: 04-28-2004, 09:51 PM
  5. One Unique Universal Programming Language ?
    By zahid in forum A Brief History of Cprogramming.com
    Replies: 30
    Last Post: 01-29-2003, 12:36 AM