Is it possible that a programming language has a interpreter and compiler? if yes, how ?
** I think RUBY has 开发者_开发问答compiler and interpreter **
thanks
Sure, you can have both. Besides the obvious examples of Java, Python, and now Ruby, you could write a native compiler for any of them if you really wanted to. I think there is a poorly implemented Ruby compiler out there.
Conversely, you could also write an interpreter for C, I think there are a few around.
There are technical reasons why a dynamic language like Ruby is difficult to write a compiler for and using an interpreter for C defeats the main advantage of writing C over languages like Ruby. That doesn't imply it can't be done.
In short, you can write a compiler or an interpreter, or both for any language and platform(native or VM) that you can get or figure out the specifications.
Some languages can be both compiled into platform specific runtime executables and be interpreted. For example Ruby can be interpreted by multiple interpreters, native ruby, ree, etc as well as "compiled" into native java code (which is not exactly a native executable) by JRuby.
精彩评论