Wednesday, September 28, 2011

Scripting Language Versus Compiled Language

After reviewing some of the basic slides that John Zelle put up about Teaching Computer Science with Python, my student asked me what a scripting language was.  I compared Python to C and then threw in Java, a byte compiled language, to round out the comparison.

Program in C.

/* Hello World program */
#include<stdio.h>
main()

{   

printf("Hello World");


}

 Since we're on a Mac, the command in the terminal is:

gcc -o helloworld helloworld.c

Program in Java

class HelloWorldApp{     
public static void main(String[] args) {         
System.out.println("Hello World!"); // Display the string.    

}

}
byte compile the Java code:
javac HelloWorldApp.java

Run it:
java HelloWorldApp
Python

print ("Hello World")




Tuesday, September 27, 2011

Visual Python


I've been working with my son to develop 3D objects with VPython.  It's super cool and really rewarding.

This is the entire program for the green cylinder above:

from visual import *
rod = cylinder(radius= 1)
rod.green = .9
rod.red = 0
rod.blue = 0
It will also work with just this:
from visual import *

cylinder()


Awesome set of videos on learning to use visual python.

The only tricky part was that the visual library only worked with 32 bit Python.  Since I'm on Mac OS X, Snow Leopard, I had a 64 bit version of Python 2.7 installed.  I'm using a 32 bit version of Python 3.1 on the Mac in order to run visual.

You can find out what the architecture is with this:

>>> import platform

>>> platform.architecture()

('32bit', '')

>>> 


John Zelle and Python Programming: An Introduction to Computer Science




More awesomeness from John Zelle - found his slides for  Python Programming: An Introduction to Computer Science, 2nd Edition.

The book is great and the slides were a really nice find.  In addition to the slides for individual chapters to the book, the slides from SIGCSE 2003 were also incredible.