6

I want to try and create my own very basic language, with it's very basic compiler. All using Java.

For now, it will only need to enable to 'programmer' to print things to the screen.

I had an idea for how to do this, and what I wanted to know is: Will this be considered an actual 'compiler', an actual 'language', and an actual 'virtual machine'? (All very, very basic of course).

My idea was to create a program which will serve as the 'IDE' (editor and compiler), and another one which will serve as the 'virtual machine'.

This means that the IDE will not compile the written code to some existing machine code, like the Java Bytecode, but will actually compile to some kind of compiled code made up by me.

This compiled code will only be understandable by my 'virtual machine' program, and will only be able to run inside this program. The 'virtual machine' program, will use high-level Java operations in order to understand and execute the compiled code.

The 'virtual machine' program will be a Java program, running on the JVM.

My question is: Conceptually, is this considered a virtual machine, and 'machine code'? If not, is this still considered a 'programming language', even though it's compiled bytecode can only run inside a specific program?

4
  • maybe you want to check out github.com/NiklasRosenstein/beak-lang. The code is documented a little (not well, not bad though) Commented Mar 3, 2014 at 9:23
  • 1
    If you are planning to do something like this, take a look at Xtext! Using it is certainly easier, than writing everything from scratch + you also get an IDE for your new language. Commented Mar 3, 2014 at 9:26
  • 1
    What's a point in implementing another virtual machine on top of JVM? Just generate JVM bytecode directly, it's a very easy and straightforward thing to do. Take a look at the ASM library. Commented Mar 3, 2014 at 9:29
  • And, yes, any form of translation from one language to another is a compilation, by definition. Any sufficiently complex language (not even necessarily Turing-complete) with a well-defined semantics is a programming language. Commented Mar 3, 2014 at 9:33

1 Answer 1

1

It would be considered an interpreter, and the compiled code would be byte code.

To be a "virtual machine" you'd need to create ways of interacting with "everything" on the PC that it runs. Giving your users/developers a "print to screen" feature is not a virtual machine.

http://en.wikipedia.org/wiki/Virtual_machine

Edit: You asked: "Also: Conceptually, would you say that a programming language that is only able to create programs that can run inside another program, is still considered a programming language?"

That depends on the features of this "other program". If you're asking about the JVM: yes. The wikipedia definition of programming language can be found here:

http://en.wikipedia.org/wiki/Programming_language

A programming language is an artificial language designed to communicate instructions to a machine

And we say that a virtual machine fulfills this property. So yes, Java (and other languages that compile to bytecode run by a proper virtual machine) is a programming language.

Sign up to request clarification or add additional context in comments.

11 Comments

What exactly is the difference between a compiler and an interpreter? Is the compiler in Eclipse a compiler or an interpreter?
Compiler doesn't run your program, that's the difference.
Also: Conceptually, would you say that a programming language that is only able to create programs that can run inside another program, is still considered a programming language?
Thanks. Would you say that a program that serves as a platform to run other programs, must have a 'constant connection' to the OS in order to be considered a virtual machine? I'm not sure, but I think that the technical definition to a VM is that it's another platform, onto which programs run. My hypothetical VM has a connection to the OS like any other program. Does it have to have a 'special' connectin to be considered a VM?
@Xabster, mind elaborating? What else is not a virtual machine then? SECD? STG? LLVM?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.