Fall2006.PythagoreanTheoremInJavaAndPython History

Hide minor edits - Show changes to output

Changed lines 99-100 from:
The above is a generic, simple (rather typical?) programming task. Given human cognitive limitations (e.g., the [[http://www.well.com/~smalin/miller.html | 7 plus-or-minus 2 rule]]), it is not surprising that programmers report at least a 3 times increase in productivity when they move from Java (or C/C++) to Python.
to:
The above is a generic, simple (rather typical?) programming task. Given human cognitive limitations (e.g., the [[http://psychclassics.yorku.ca/Miller/ | 7 plus-or-minus 2 rule]]), it is not surprising that programmers report at least a 3 times increase in productivity when they move from Java (or C/C++) to Python.
Changed lines 109-110 from:
# Miller, G.A. (1956), "[[http://www.well.com/~smalin/miller.html | The Magical Number Seven, Plus or Minus Two: Some Limits on Our Capacity for Processing Information]]", ''The Psychological Review'', vol. 63, pp. 81-97.
to:
# Miller, G.A. (1956), "[[http://psychclassics.yorku.ca/Miller/ | The Magical Number Seven, Plus or Minus Two: Some Limits on Our Capacity for Processing Information]]", ''The Psychological Review'', vol. 63, pp. 81-97.
Changed lines 101-102 from:
Also, the above comparison does not capture the amount of effort required to master each of the required concepts. Some concepts are easier to master than others (e.g., "statement terminator" vs. "class"). Also, a single concept may be easier to master in one language vs. the other (e.g., "input" or "method/function").
to:
Also, the above comparison does not capture the amount of effort required to master each of the required concepts. Some concepts are easier to master than others (e.g., "statement terminator" vs. "class"). Also, a single concept may be easier to master in one language vs. another (e.g., "input" or "method/function").
Changed lines 105-106 from:
!!Reference
to:
!!References
Changed lines 5-6 from:
->"When teaching Smalltalk to 20 nonprogrammer adults, they were able to get through the initial material faster than children, but, just as it looked like an overwhelming success was at hand, they started to crash on problems that didn't look to me to be much harder than the ones they had just been doing do well on. ... E.g., make a little database system that would act like a card file or rolodex. They couldn't even come close to programming it. Such a project was well below the mythical 'two pages' for end-users we were working with. After showing them the solution, I realized this little program contained 17(!) nonobvious ideas. And some of them were like the concept of the ''arch'' in building design: very hard to discover, if you don't already know it."
to:
->"When teaching Smalltalk to 20 nonprogrammer adults, they were able to get through the initial material faster than children, but, just as it looked like an overwhelming success was at hand, they started to crash on problems that didn't look to me to be much harder than the ones they had just been doing so well on. ... E.g., make a little database system that would act like a card file or rolodex. They couldn't even come close to programming it. Such a project was well below the mythical 'two pages' for end-users we were working with. After showing them the solution, I realized this little program contained 17(!) nonobvious ideas. And some of them were like the concept of the ''arch'' in building design: very hard to discover, if you don't already know it."
Changed lines 76-78 from:
x = raw_input()
y = raw_input()
to:
x = input()
y = input()
Changed line 92 from:
# input (i.e., @@raw_input()@@)
to:
# input (i.e., @@input()@@)
Changed lines 3-4 from:
Here are two typical programs to calculate length of the hypotenuse of a triangle given the length of the two legs, in Java and in Python.
to:
Alan Kay, in his paper "[[http://www.metaobject.com/papers/Smallhistory.pdf | The Early History of Smalltalk]]" states:

->"When teaching Smalltalk to 20 nonprogrammer adults
, they were able to get through the initial material faster than children, but, just as it looked like an overwhelming success was at hand, they started to crash on problems that didn't look to me to be much harder than the ones they had just been doing do well on. ... E.g., make a little database system that would act like a card file or rolodex. They couldn't even come close to programming it. Such a project was well below the mythical 'two pages' for end-users we were working with. After showing them the solution, I realized this little program contained 17(!) nonobvious ideas. And some of them were like the concept of the ''arch'' in building design: very hard to discover, if you don't already know it."

In this context, here are two typical programs, in Java and in Python, to calculate length of the hypotenuse of a triangle given the length of the two legs
.
Changed lines 101-102 from:
Also, the above lists do not capture the amount of effort required to master each of the above. Some concepts are easier to master than others (e.g., "statement terminator" vs. "class"). Also, some concepts may be easier to master in one language vs. the other.
to:
Also, the above comparison does not capture the amount of effort required to master each of the required concepts. Some concepts are easier to master than others (e.g., "statement terminator" vs. "class"). Also, a single concept may be easier to master in one language vs. the other (e.g., "input" or "method/function").
Added lines 107-108:
# Kay, A. "[[http://www.metaobject.com/papers/Smallhistory.pdf | The Early History of Smalltalk]]", ACM SIGPLAN Notices, Volume 28, Number 3, March 1993.
Changed lines 1-2 from:
!!Programming Effort Comparison
to:
!Programming Effort Comparison
Added lines 7-8:
!!Java
Added lines 64-65:
!!Python
Added lines 97-100:
Also, the above lists do not capture the amount of effort required to master each of the above. Some concepts are easier to master than others (e.g., "statement terminator" vs. "class"). Also, some concepts may be easier to master in one language vs. the other.

It would be interesting to generate a relative index of difficulty by, say, counting the number of lines used in a typical CS book to explain each of these concepts.
Changed line 44 from:
# you may instantiate an object within its own class (i.e., chicken-and-egg paradox)
to:
# you may instantiate an object within its own class (i.e., ''chicken-and-egg'' paradox)
Changed line 37 from:
# special method @@main()@@ (program entry point by Java VM)
to:
# special method @@main()@@ (i.e., program entry point by Java VM)
Changed lines 97-98 from:
# McConnell, J.J. and Burhans, D.T. (2002), "[[http://fie.engrng.pitt.edu/fie2002/papers/1142.pdf | The Evolution of CS1 Textbooks]]", 32nd ASEE/IEEE Frontiers in Education Conference, November 6-9, 2002, Boston, MA, pp. T4G1-T4G6.
to:
# McConnell, J.J. and Burhans, D.T. (2002), "[[http://fie.engrng.pitt.edu/fie2002/papers/1142.pdf | The Evolution of CS1 Textbooks]]", 32nd ASEE/IEEE Frontiers in Education Conference, November 6-9, 2002, Boston, MA, pp. T4G1-T4G6. [-"The average size for the Java books in our study is 2.25 times the average size of the Fortran books and 1.95 times the average size of the Pascal books. From the perspective of a course, the authors of three of the four Java books we examined expect that their entire book (averaging 880 pages) will be covered in one semester. This amounts to 22 pages per class or about 66 pages per week that a student is expected to prepare." -]
Added lines 97-98:
# McConnell, J.J. and Burhans, D.T. (2002), "[[http://fie.engrng.pitt.edu/fie2002/papers/1142.pdf | The Evolution of CS1 Textbooks]]", 32nd ASEE/IEEE Frontiers in Education Conference, November 6-9, 2002, Boston, MA, pp. T4G1-T4G6.
Changed lines 91-92 from:
The above is a generic, simple (rather typical?) programming task. Given human cognitive limitations (e.g., the [[http://www.well.com/~smalin/miller.html | 7 plus-or-minus 2 rule]]), it is not surprising that programmers report at least a 3 times increase in productivity when they move to from Java (or C/C++) to Python.
to:
The above is a generic, simple (rather typical?) programming task. Given human cognitive limitations (e.g., the [[http://www.well.com/~smalin/miller.html | 7 plus-or-minus 2 rule]]), it is not surprising that programmers report at least a 3 times increase in productivity when they move from Java (or C/C++) to Python.
Changed lines 91-92 from:
Given that this a rather typical (generic, most frequent) programming task, it is not surprising that programmers report at least a 3 times increase in productivity when they move to from Java (or C/C++) to Python.
to:
The above is a generic, simple (rather typical?) programming task. Given human cognitive limitations (e.g., the [[http://www.well.com/~smalin/miller.html | 7 plus-or-minus 2 rule]]), it is not surprising that programmers report at least a 3 times increase in productivity when they move to from Java (or C/C++) to Python.
Changed lines 95-97 from:
# Bill Manaris, "[[http://www.cs.cofc.edu/~manaris/index.php/Fall2006/Python | Python vs. Java in Intro to CS Courses]]", a collection of resources and incomplete thoughts.
to:
# Miller, G.A. (1956), "[[http://www.well.com/~smalin/miller.html | The Magical Number Seven, Plus or Minus Two: Some Limits on Our Capacity for Processing Information]]", ''The Psychological Review'', vol. 63, pp. 81-97.

# Manaris, B. (2006)
, "[[http://www.cs.cofc.edu/~manaris/index.php/Fall2006/Python | Python vs. Java in Intro to CS Courses]]", a collection of resources and incomplete thoughts.
Changed lines 5-6 from:
Consider the number of new concepts/"nonobvious ideas" required to master in order to write each of these programs.
to:
Consider the number of new concepts/"nonobvious ideas" required to master in order to comprehend/write each of these programs.
Changed lines 29-30 from:
For the Java program, a programmer needs to know the following concepts/"nonobvious ideas":
to:
For the Java program, a programmer needs to master the following concepts/"nonobvious ideas":

# libraries (i.e., @@import java.util.*;@@)
Changed line 33 from:
# class visibility (public vs. private, etc.)
to:
# encapsulation and information hiding (e.g., @@public@@ vs. @@private@@, etc.)
Added lines 54-55:
# class member method invocation (e.g., @@input.nextInt()@@)
# iterators (e.g., @@nextInt()@@)
Added line 57:
# hierarchical composition (i.e., @@System@@ constains object @@out@@)
Changed lines 74-75 from:
For the Python program, a programmer needs to know the following concepts/"nonobvious ideas":
to:
For the Python program, a programmer needs to master the following concepts/"nonobvious ideas":
Deleted line 81:
# statement terminator (i.e., @@;@@)
Changed lines 87-95 from:
# return statement
to:
# return statement

!!Conclusion

Given that this a rather typical (generic, most frequent) programming task, it is not surprising that programmers report at least a 3 times increase in productivity when they move to from Java (or C/C++) to Python.

!!Reference

# Bill Manaris, "[[http://www.cs.cofc.edu/~manaris/index.php/Fall2006/Python | Python vs. Java in Intro to CS Courses]]", a collection of resources and incomplete thoughts.
Changed line 53 from:
# output
to:
# output (i.e., @@System.out.println@@)
Changed lines 68-84 from:
(:sourcend:)
to:
(:sourcend:)

For the Python program, a programmer needs to know the following concepts/"nonobvious ideas":

# module (i.e., @@from math import *@@)
# function
# blocks (i.e., indentation)
# statement terminator (i.e., newline)
# functions may or may not return a value
# parameter passing
# statement terminator (i.e., @@;@@)
# variable
# assignment
# input (i.e., @@raw_input()@@)
# output (i.e., @@print@@)
# algebraic expressions
# return statement
Changed lines 31-50 from:
* class
* class visibility (public vs. private, etc.)
* class name must be the same as program file name
* method
* special method @@main
()@@ (program entry point by Java VM)
* static vs. non-static methods
* arrays (i
.e., @@String[] args@@)
* command-line parameter passing (i.e., @@String[] args@@)
* class instantiation
(class vs. object)
* you may instantiate an object within its own
class (i.e., chicken-and-egg paradox)
* data types
* primitive data types vs. non-primitive data types
* variable
* assignment
* variable declaration
* input
* special class
@@Scanner@@
* input streams, e.g., @@System.in@@
*
output
to:
# class
# class visibility (public vs. private, etc.)
# class name must be the same as program file name
# blocks (i.e., @@{ ... }@@)
# method
# special method @@main(
)@@ (program entry point by Java VM)
# static vs
. non-static methods
# void vs. value returning methods
# parameter passing
# arrays
(i.e., @@String[] args@@)
# command-line parameter passing (i.e., @@String[] args@@)
#
class instantiation (class vs. object)
# you may instantiate an object within its own class (i.e., chicken-and-egg paradox)
# statement terminator (i.e.,
@@;@@)
# data types
# primitive data types vs
. non-primitive data types
# variable
# assignment
# variable declaration
# input
# special class @@Scanner@@
# input streams, e.g., @@System.in@@
#
output
# algebraic expressions
# Math library (i.e., @@sqrt()@@)
# return statement
Changed lines 1-4 from:
!!Program Comparison

Here are two typical programs to calculate length of the hypotenuse of a triangle given the length of the two legs, in Java and in Python.
to:
!!Programming Effort Comparison

Here are two typical programs to calculate length of the hypotenuse of a triangle given the length of the two legs, in Java and in Python.

Consider the number of new concepts/"nonobvious ideas" required to master in order to write each of these programs
.
Added lines 29-50:
For the Java program, a programmer needs to know the following concepts/"nonobvious ideas":

* class
* class visibility (public vs. private, etc.)
* class name must be the same as program file name
* method
* special method @@main()@@ (program entry point by Java VM)
* static vs. non-static methods
* arrays (i.e., @@String[] args@@)
* command-line parameter passing (i.e., @@String[] args@@)
* class instantiation (class vs. object)
* you may instantiate an object within its own class (i.e., chicken-and-egg paradox)
* data types
* primitive data types vs. non-primitive data types
* variable
* assignment
* variable declaration
* input
* special class @@Scanner@@
* input streams, e.g., @@System.in@@
* output
Changed lines 1-2 from:
!!Programming Effort Comparison
to:
!!Program Comparison
Changed lines 3-4 from:
Here is a program to calculate length of the hypotenuse of a triangle given the length of the two legs, first in Java and then in Python.
to:
Here are two typical programs to calculate length of the hypotenuse of a triangle given the length of the two legs, in Java and in Python.
Changed lines 7-8 from:
import static java.lang.Math.*;
to:
Changed line 22 from:
return (sqrt( (a*a) + (b*b) ));
to:
return (Math.sqrt( (a*a) + (b*b) ));
Changed lines 7-8 from:
to:
import static java.lang.Math.*;
Changed line 23 from:
return (Math.sqrt((a*a)+(b*b)));
to:
return (sqrt( (a*a) + (b*b) ));
Changed lines 29-30 from:
from math import sqrt
to:
from math import *
Changed lines 32-33 from:
return(sqrt(a*a+b*b))
to:
return(sqrt( (a*a) + (b*b) ))
Added lines 1-37:
!!Programming Effort Comparison

Here is a program to calculate length of the hypotenuse of a triangle given the length of the two legs, first in Java and then in Python.

(:source lang=Java header="Pythagorean Theorem in Java." tabwidth=3 -trim :)
import java.util.*;

public class Triangle
{
public static void main (String[] args)
{
Triangle t1 = new Triangle();
Scanner input = new Scanner(System.in);
int a = input.nextInt();
int b = input.nextInt();
double c = t1.hypotenuse(a, b);
System.out.println(c);
}

public double hypotenuse(int a, int b)
{
return (Math.sqrt((a*a)+(b*b)));
}
}
(:sourcend:)

(:source lang=Python header="Pythagorean Theorem in Python." tabwidth=3 -trim :)
from math import sqrt

def hypotenuse(a, b):
return(sqrt(a*a+b*b))

x = raw_input()
y = raw_input()

print hypotenuse(x, y)
(:sourcend:)