Python vs. Java: Source Code to Execution

Python vs. Java: Source Code to Execution

There are some common characteristics with writing and running Python and Java programs. Here's a basic list of what usually happens.

1. You write code in that language within an IDE or a text editor. This file is called the source file.

(For more details on the structure of the code, check out this article on program structure)

2. You save the source file, giving the filename a special extension.

If you had a program named "helloworld" in Java, you'd save it as "helloword.java" In Python, you'd save it as "helloworld.py"

3. You compile the source file. You use a program called the compiler (usually called from within the IDE) which produces a separate file that can be executed by the system or interpreter*.

In Java, the "helloworld.java" file is used to create a class file named "helloworld.class" In Python, the "helloworld.py" file is used to create to a pyc file named "helloworld.pyc"

4. You execute the file and see the results of your program. In most cases, your IDE will have the option "Compile and Execute", so you can do step 3 and 4 with one click or key stroke.


* Python and Java are both "interpreted" languages, so when you compile the source code, you get another file that is interpreted by the language's interpreter to get a result. C and C++ are "compiled" languages, so when you compile the source code, you get code that the machine can directly run. It's faster because it's machine specific and doesn't require an interpreter. However, it's machine specific and probably won't run on another system. With interpreted languages, you can run the compiled code on any machine as long as the language's interpreter is there - more portability.

More by this Author

  • 4 Chords on a Piano
    2

    One of my new favorite iPad apps is the Virtuoso Piano. This free app is very nice and has nearly all the features an eager and noob piano player like myself would enjoy (there is also a Pro version with more features...


Comments

No comments yet.

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working