Thursday, November 3, 2011

Starting out with...

In order to get started with programming you have to have the correct tools. So here is a step-by-step guide to getting started with Python, C++, and Java for Linux, Windows, and Mac.

  • Linux: If you have a version of Linux on your computer then, congratulations! You probably already have everything you need installed. All you have to do is verify that some version of Python 2 is included with your OS. If for some reason Python is not included, just apt-get install, yum install, or zypper through terminal.
  • Windows/Mac: You can find an installer on Python's official website. Just click on the correct link (I'll be using the syntax for Python 2) and install like any other software. http://www.python.org/getit/
  • Compiling: Since Python is an interpreted language you don't need a compiler. 
  • Running: All you have to do to run a program is cd to the appropriate directory through terminal and then type "python [program name].py"
  • Linux: Once again, congratulations! Everything you need to run C++ is probably already on your computer. You'll need a text editor and a compiler. You can use any test editor you prefer, but emacs seems to be the top choice for C++ editing. The C++ compiler is g++. If either one of these is missing then just install them the usual way from terminal.
  • Windows: A popular option for windows users is Microsoft's Visual C++, which is a nice GUI that combines text editing and compiler. Visual C++ can be installed here: http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express
    Another option for the windows user is Cygwin, which can be used to create C++ in a Linux-like environment. Cygwin can be installed here: http://www.cygwin.com/
  • Mac: You can download XCode from the app store, which should have everything you need. For text editing, Macs come with text edit and text wrangler or you can download aquamacs (a Mac version of emacs) here: http://aquamacs.org/
  • Compiling: cd to the appropriate directory through terminal and type "g++ [program name].cpp" OR "g++ -o [output file name] [program name].cpp"
    g++ tutorials: http://pages.cs.wisc.edu/~beechung/ref/gcc-intro.html AND http://myweb.stedwards.edu/laurab/help/g++help.html
  • Running: With the first compilation just type "./a.out" OR with the second method type "./[output file name]"

  • Linux: You'll need to download the Java JDK package, which can be done the usual way through terminal. (it may be named OpenJDK). You can use any text editor
  • Windows/Mac: download the Java JDK packager here: http://www.oracle.com/technetwork/java/javase/downloads/index.html
    You can use any text editor, but a popular GUI choice is BlueJ, which can be downloaded here: http://www.bluej.org/
  • Compiling: cd to the appropriate directory through terminal and type "javac [program name].java" (make sure that the program name matches the class name that is in your code, otherwise you'll get an error) This will create a class file of the same name as your java file.
  • Running: type "java [program name]" (without an extension)
So you should be all set to start programming! Of course, if you have no experience then you'll probably appreciate some tutorials. The official websites for all three languages are very informative, and are a good place to start.

Java: http://download.oracle.com/javase/tutorial/java/index.html

NOTE: I will be using coding comments in some of the examples to explain what I'm doing, or to tell you what the output should be. In Python a comment is indicated by a hashtag/octothorpe/pound sign (#). In C++ and Java a single line comment is indicated by two forward slashes (//). A multiple line comment is started with a forward slash, followed by an asterisks (/*) and ended with an asterisks, followed by a forward slash (*/).

No comments:

Post a Comment