Is it possible to make a high-level compiled language?

I'm a relatively newbie programmer who made some Visual Basic, Python, and recently started learning Java or C ++ for a faster language. The main reason that these languages ​​were faster seemed to be because they were compiled (or for Java, mostly compiled). This led me to the question, is it possible to make a simpler language like Python that compiles for speed?

The advantages that languages ​​interpret are mainly the ability of dynamic variables in volume and type. However, in general, this (in my little experience) reduces the length of the code by a small amount (probably up to 10%, adding a public modifier or int is just one word). I'm also not sure if garbage collection is possible in a true compiled language (e.g. C ++), but it is available in java, which is about as fast and fast as C ++.

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

For example: in a very limited form of java I have to print something you have to write:

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

In Python 3, however, you write:

 print("print this") 

If someone wrote print("print this") in this theoretical language, it will be compiled into System.out.println("print this"); , and then compiled into JVM bytecode. This type of language can probably shorten production time, but it will have fast execution speed.

+6
source share
5 answers

You seem to be looking for the Holy Grail. I would say it is possible. But you will need a large team of brilliant people. And time.

PS I do not see how Java is not fast enough for you. I like the Java programming language, I do not notice any lag compared to other programs written in different languages, and I wrote entire programs in a day. In other words, the speed of rapid development. It is also very easy to work with other people who write Java. With tools like eclipse, you can simultaneously code and use features such as compare / replace to combine your work.

+3
source

I think that now there are many languages ​​aimed at this title. For example, there are Nim (formerly Nimrod), Go and Rust. They look like three big records in the high-level area of ​​high performance right now, if you consider C ++ as a relatively low level. Here is a summary of each of (imo) most suitable for use in production, at least:

Go seems to have a cross between C ++ and Java in terms of performance, and is pretty easy to learn (although its syntax is as long as Java). The syntax is pretty good and it has a lot of built-in concurrency functions, so it is definitely worth checking out. Here is an example of a greeting.

Rust, on the other hand, performs as well as C ++, and seeks to surpass it in the future. The syntax is pretty simple, and right now (alpha) it has a lot of built-in macros, including println! , which is similar to printing in Python, but has string formatting. The main problems, however, are that they are still in their early stages, and Mozilla bluntly stated that major changes would be made and that her security system, although very useful for troubleshooting, would probably be quite confusing for some people.

On a completely different level, there is Nim. It has a built-in GC such as Go (and Rust, but that's a different story), and cross-compilation with C. It seems that Python has taken a step too far and paid much attention to imperative procedures . Currently, performance is not so bad (although it is slower than Rust from the limited test that I ran), but the syntax and focus on imperative, procedural programming is the biggest factor in deciding to go with this language.

I think that these three languages ​​are at a high level, and all are high indicators, so yes, in my opinion, you can make a high level language.

Oh, and yes, garbage collection is certainly possible in a compiled language. Why not?

+2
source

Look at Nim, which is a compiled language according to wikipedia and has some syntax familiar with python. I do not think it is fully released. However, you can still get it.

It even allows you to code in C, it can also interact with Lua Python interpreters. Nim is a statically typed, imperative programming language that tries to give ultimate power to a programmer without compromising on performance. It has zero utility iterators and works by compiling in C. Even C ++ code can be generated with it.

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

http://nim-lang.org/

Examples The Hello World program is simple:

 echo "Hello World!" 
+2
source

How about Scala ? It is compiled into JVM bytecode and has many functions commonly found in scripts (dynamic) languages ​​(anonymous functions, higher-order functions, delimited extensions, type matching, type inference, attributes, mixins ...), look at the wikipedia page for more details.

+1
source

Nim is a new high-level language with full low-level features if you want to use them. Used as a high-level language, it is probably quite safe. It also has well-developed programming features. It "translates" to C and then to binary files. (I think this is the perfect language - Finally!) See http://nim-lang.org/0.11.3/nims.html

If you just need a very simple high-level language that "translates" to C, then the binaries are Genie: https://wiki.gnome.org/action/show/Projects/Genie?action=show&redirect=Genie

+1
source

Source: https://habr.com/ru/post/904873/


All Articles