6

I'm a relatively beginner programmer, who has done some Visual Basic, Python, and recently started looking into Java or C++ for a faster language. The main reason for these languages being faster seemed to be that they were compiled (or for Java, mostly compiled). This led me to the question, would it be possible to make an easier language like Python that is compiled for speed?

The advantages that interpreted languages have seems mainly to be the ability to have variables dynamic in scope and type. However, overall this (in my small experience) shortens code length by a small amount (probably under 10%, adding a public modifier or int is just one word). Also I'm not sure whether garbage collection is possible in a true compiled language (like c++), but it is available in java which is just about as fast/faster as C++.

Is it possible to make a language with very easy syntax (like Python), with a few small changes (static variables), and allow it to be compiled in Java/C++, and from there compiled into a very fast program?

For example: in the very limited view of java I have now, to print something you must write:

System.out.println("print this");

In Python 3, however, you write:

print("print this")

If someone wrote in this theoretical language print("print this"), it would be compiled to System.out.println("print this"); and then compiled into JVM bytecode. This type of language could probably shorten production time while still having a fast execution speed.

Mechanical snail
  • 29,755
  • 14
  • 88
  • 113
Guy Blanc
  • 833
  • 8
  • 14
  • I think you mean "interpreted", not "interrupted". Why wouldn't garbage collection be possible in a "true" compiled language? In any case, of course this is possible, ranging from trivial source-level translations to full-blown languages. There are a ton of JVM-based languages, for example. – Dave Newton Jan 02 '12 at 03:06
  • Take a look at the ML family of the languages. E.g., OCaml - it is pretty fast, and its type system makes it easier to use than anything like Python. – SK-logic Aug 06 '12 at 10:19
  • 1
    Many high-level languages are compiled into bytecode to run on a VM. Ruby is, so is python. Haskell is the most high level language that I know of which compiles down to machine code. – Cameron Martin Dec 29 '14 at 13:00

4 Answers4

2

Have a look at Nim which is a compiled language according to wikipedia and has some syntax familiar to python. I don't think it is fully released yet. However you can still get it.

It even allows for you to code in C, it can also interface with Lua an Python interpreters. Nim is a statically typed, imperative programming language that tries to give the programmer ultimate power without compromises on runtime efficiency. It has zero overhead iterators and works by compiling into C. Even C++ code can even be generated with it.

You can get the Aporia IDE at : https://github.com/nim-lang/Aporia https://en.wikipedia.org/wiki/Nim_(programming_language)

http://nim-lang.org/

Examples Hello World program is simply this:

echo "Hello World!"
2

Sounds like you are looking for the Holy Grail. I'd say it's possible. But you are going to need a large team of brilliant people. And time.

P.S. I don't see how Java is not fast enough for you. I love the Java programming language, I don't notice any lag compared to other programs written in different languages, and I've written entire programs in a day. In other words, fast development speed. It is also very easy to work with other people writing Java. With tools like eclipse, you can code simultaneously and use features like "compare/replace" to combine your work.

Duncan Calvert
  • 345
  • 3
  • 12
  • It doesn't have "super fast" development speed compared to more expressive languages, even *with* its stellar IDE support. Even if it did, because of its verbosity and ceremony, a more critical issue comes in the maintenance phase: it's just harder to read because of all the noise. – Dave Newton Jan 02 '12 at 03:09
  • 1
    @dave I can see what you mean. A lot of Java code can get hard to maintain after a while. What language would you be referring to by "more expressive"? Just wondering. – Duncan Calvert Jan 02 '12 at 03:18
  • 3
    Mostly any; it's not hard to top Java's model of abstraction. Lisps, Smalltalks, Rubies, Groovy, Scala, C#, heck, even JavaScript most of the time. – Dave Newton Jan 02 '12 at 03:58
1

Nim is a new high level language with complete low level features if you wish to use them. Used as a high level language, it is presumably rather safe. It also has well developed functional programming features. It "transpiles" to C, then binaries. (I think it's the perfect language -- Finally!) See: http://nim-lang.org/0.11.3/nims.html

If you just want a very simple high level language that "transpiles" to C, then binaries, there is Genie: https://wiki.gnome.org/action/show/Projects/Genie?action=show&redirect=Genie

blues
  • 11
  • 1
1

How about Scala? It's compiled to JVM's byte code and has many features usually found in scripting (dynamic) languages (anonymous functions, higher-order functions, delimited continuations, pattern matching, type inference, traits, mixins...) take a look at the wikipedia page for more details.

Óscar López
  • 232,561
  • 37
  • 312
  • 386