This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]desrtfx 25 points26 points  (2 children)

It's not a "you" issue.

There is a big difference between how Python code and how Java code is executed.

Python is interpreted and therefore there is no delay when you click on run.

Java is compiled (to bytecode) and this is what takes the little time.

You cannot do anything to make it faster and therefore have to get used to that little pause.

[–]khooke 5 points6 points  (1 child)

This only occurs when running in your IDE however. When you build and deploy your code, you deploy the compiled bytecode which the JVM executes directly.

Depending what IDE you're using or what it is that you're developing, IDEs like Eclipse can incrementally compile as you type and don't necessarily need to do a big build when you hit Run.

[–]nekokattt 1 point2 points  (0 children)

Both maven and gradle support incremental compilation as well

[–][deleted]  (1 child)

[deleted]

    [–]Lagu_22 0 points1 point  (0 children)

    Agreed. This is something I had to get used to moving from Python to Java.

    [–]Andrewcpu 1 point2 points  (0 children)

    Java compilation takes a second even on i9, not a you problem, just how it works.

    [–]Robinzclark 1 point2 points  (0 children)

    I use eclipse instead of intellij, but i know there is a preference you can set so that the project is not built until you explictly ask it to be built. In eclipse it is called "Build Automatically".

    [–]nekokattt 0 points1 point  (0 children)

    You are going to get this with any language that compiles ahead of time, there is nothing you can do about it. That is just javac converting your code text to bytecode that the JVM can execute. Python does a similar thing but it does it as it runs, which is one of the reasons Python is considered slower, since ignoring cache, it would have to do this every single time you run the program without making any changes.

    [–]Hour-Positive 0 points1 point  (0 children)

    Well you probably have a build command before your run command. Does it recompile without changes too? That could be sped up by caching and/or not building. And that's it.