ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel
  • »
  • Technology»
  • Computers & Software»
  • Computer Science & Programming»
  • Programming Languages

Python vs. Java: Source Code to Execution

Updated on December 31, 2010

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.

Comments

    0 of 8192 characters used
    Post Comment

    No comments yet.

    Click to Rate This Article