What are the highest level languages that can be compiled?
What are the highest level languages that can be compiled to executables? When I say compiled to an executable I am not referring to bytecode, but native assembly code like in the C, C++ sense.
EDIT: One issue that I'm having is that clients have ssh access to my server in a limit access acount. They need to run some of my scripts but I don't want them to see the source code. A Python script (or any other script) cannot be executed without read permission unli开发者_开发知识库ke a natively compiled program which only needs execution privileges.
Any language can potentially be compiled. .net contains a native code generator (NGEN) that translates bytecode into native code, and could potentially be used to create native binaries. And really, any language that compiles to bytecode could have the same capability.
It starts getting tricky when you get into scripting languages (Python, PHP, Perl, etc). In those, it's usually easier to bundle the script with an interpreter in a single executable. But there's nothing preventing someone from writing a PHP or Perl compiler, except that both languages' "eval" functions would pretty much require the ability to parse and execute text -- meaning you'd end up with an interpreter at least linked to the program anyway.
The bigger question is, "At what level does it stop being worth it to compile?". To that, i'd answer "when you're running code that has to be able to interpret itself". IE: i wouldn't bother trying to compile any language that has an "eval" statement/function, unless i were allowed to remove the statement/function.
My vote would be for Java + GCJ. More information about GCJ can be found at:
http://en.wikipedia.org/wiki/Gcj
It can skip bytecode and compile directly to machine code.
Many Lisp dialects have native code compilers, as do Haskell, OCaml, and Standard ML.
You are confused. The point of computer programming languages is that they can be automatically executed, and ultimately that always means compiling to machine instructions. Therefore by definition, programs in every language can in principle be turned into executables. Some don't actually take that step and are content with interpreted byte code, but most languages do have translators for native code (even Java, for example, has JIT compilers that produce processor-specific opcodes instead of byte code).
The only difference is that higher languages need a bit more of the compiler infrastructure to be included in the executables; no compiler can get rid of the garbage collection mechanism, or run-time type information, or it wouldn't be the same program anymore. But a computer programming language that couldn't be automatically translated to something runnable would be pretty pointless.
Apart from intentionally dysfunctional languages like Malbolge, or course, where writing "Hello world" was a multi-year effort...
精彩评论