Well, JIT is a tool to circumvent weak spot of interpreted languages and bring it closer to native in perfomance.
I do not see advantage on your suggested compile-on-first-run and native source-based program: I you have properly configured compiler, you can create program from source code just by launching makefile
Compile-on-first-run have disadvantages: imagine something of scale of MS Office. Now imagine how long you will wait until launch on first run. Also there is questions of portability (run program from flashdrive on windows, them move it to the Mac), where compiled version wold be stored and what to do if source was changed after compilation.
Those users will not understand what JRE or compiler which will compile your program on first run is too. Many projects provides make.bat/make.sh/... fole which you just need to doubleclick.
Compilation is slower than waiting for copying all files and some little work with registry/config. And interpret languages have one advantage: you can run program without installing/compiling, you do not need to clean your system after you done with it and it will work on any conforming interpreter.
The language used very much does affect the program. If minecraft was written in machine language it would run almost instantly.
it very well does not. if you write it in machine code its not going to run instantly. its going to run as fast as it can. the gcc compiler compiles to machine code. why do you think that doesnt run instantly?
Also yes I know C++ does use a bit of machine language
no. it uses assembly (i think). its not going to use machine code because it doesnt know what binary file format is going to be used (typically ELF, but i will frequently use bin as well). did you know ELF requires a header? so it wouldnt be possible to run that inline machine code even.
though it doesn't matter because all programming languages use machine language somehow.
if i write a brainfuck to c compiler in python then the compiler isnt using any machine code at all.
You don't just have a programming language. There just a language. You write it into a file and then compile using a program. All that program does is read the language and converts it into machine language.
no you just have a programming language. i dont have to do anything at all to code i write. you write it into a file and then you can use whatever tools you want to execute it. and no. all a compiler does is read in a host language and output an equivalent in another format
Though it depends on the language because if a C++ compiler converted a line of code printing hello world into three lines of machine language then clearly if a Java compiler converted it into one line then it would be more efficent and less laggy in Java.
no it depends on the tools used. languages dont matter.
Abramus, try rewrite that in a much simpler way seeing as I didn't even understand a sentence of that because you formatted it so badly.
no. you just didnt understand it. for an improperly formatted sentence look at the fifth quote
I thought what LB was getting at with the compile on first run was something kinda like Java, where it's compiled to an optimised bytecode, then an engine on the target computer will translate the bytecode while running, but save all the bits it's translated into an actual executable so that it's all ready the next time with no need to re-translate. Am I right LB (sorry if not)?
SatsumaBenji wrote:
Personally I think Java is pretty wasteful on resources
Shh... You will attract rapidcoder.
Someone called me?
Actually Java *is* wasteful on resources, but in a much different way than you think and most of the time it does not matter that much. GC is *not* the reason. Java's GC in a well written application runs fine with just as little as 110-130% of the live data set size, which is damn close to typical fragmentation overhead of a manual allocator.
Java is wasteful on resources, because some idiot thought associating a lock with every object would be a nice idea (one word of data) and because there is no way to inline objects right now (however, Java 9 is hopefully going to change this) and you must use pointers and lots of indirection. Also JVM takes quite a few MBs itself, so Java is a poor choice for small apps. Forget writing apps running in 16 MB or RAM - that's not Java's territory.
Fredbill, you're kidding, right? Mobile phones and their apps have some of the worst performance I've ever seen. Sometimes when my phone runs the GC, it freezes completely for several minutes and I cannot even turn it on or off or force it off.
It depends on the application really. A poorly made application (which Android is a HUGE attraction of) is going to perform slowly. I've run various nice looking games and demos on my LG G Flex and they run flawlessly. Granted, I have the hardware to back it up I guess but that's kinda the point.
As someone who's worked on a Minecraft-like game, I can tell you that Minecraft is actually written pretty well from a performance standpoint. They had a lot of insight that you wouldn't get from game programming experience (see Notch's only blog post on terrain generation; it might seem simple but it's actually really smart).
And Robert'); DROP TABLE Students;--, writing a C++ version of Minecraft wouldn't actually be illegal. Network interfaces are not protected under copyright law.
Just backing way up here. A bunch of people made a comment which I disagree with:
Language has nothing to do with performance
If you think of a language in terms of syntax and semantics and consider any code which compiles into machine code, then technically you'd be right. However, each language introduces it's own flavor of paradigms and this affects the optimization of the machine code.
C++ introduced some very useful concepts over C. I'm specifically thinking of dynamic memory allocation and polymorphism. These concepts make life much MUCH easier for programmers. Avoiding them can make code incredibly complicated, however they are very expensive operations. By using a language such as Ada or Pascal, you are forced to consider each step involved and can optimize for your particular purpose.
Therefore I postulate that language does affect performance.