View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Discussion 4 - Brandyn Roemer


Types:

Java:
- Objects and primitive types (char, byte, short, int, long, etc)
- Strong typed language

Squeak:
- Everything is an Object, even an individual character
- Weak typed language



Signifying the end of a line of code:

Java: ";"

Squeak: "."




Comments:

Java: "/*" starts a comment block. "*/" ends a comment block. Also
has single line comments denoted by "//" characters preceding
the comment.

Squeak: ' " ' character starts and ends a comment block. No single
line comment equivelant like java's "//".



Location of classes/code:

Java: Each class is defined within a separate .java file.

Squeak: Code for classes exists within the Squeak environment and is
accessible through browsers, i.e. the SystemBrowser.




Methods:

Java:

1. Definition:

- with no arguments:
class OwningClass {
// ... code/data maybe ...
visibility returnType methodName() { /*code*/ }
// ... more code/data maybe ...
}

- with one argument:
class OwningClass {
// ... code/data maybe ...
visibility returnType methodName(type arg) { /*code*/ }
// ... more code/data maybe ...
}

- with two arguments:
class OwningClass {
// ... code/data maybe ...
visibility returnType methodName(type arg1, type arg2) { /*code*/ }
// ... more code/data maybe ...
}

- methods with more than two arguments follow the same pattern
that can be observed between one and two argument functions



2. Invocation:

- with no arguments:
instanceOrClass methodName

- with one argument:
instanceOrClass methodName: ARG

- with two arguments:
instanceOrClass methodName: ARG1 methodNamePart2: ARG2





Squeak:

1. Definition:

- with no arguments:
methodName

- with one argument:
methodName: ARG

- with two arguments:
methodName: ARG1 methodNamePart2: ARG2



2. Invocation:

- with no arguments:
instanceOrClass methodName

- with one argument:
instanceOrClass methodName: ARG

- with two arguments:
instanceOrClass methodName: ARG1 methodNamePart2: ARG2

- methods with more than two arguments follow the same pattern
that can be observed between one and two argument functions


3. Additional notes:

- "Methods" are actually "messages" in squeak. They are sent to the
specified receiver.
(java translation: receiver = caller and message = method)

- There is no difference in the definition of a method that returns
a value and one that doesn't. Class/static and instance methods
are defined the same - the only difference when creating them is
the selection of either the 'class' or 'instance' buttons in the
class browser.

- In the invocation section above, 'instanceOrClass' must be an
instance if the invoked method is an instance method, and must be
a class if the invoked method is a class/static method.

- All methods/messages in squeak are public and usable by anyone.



Setting Values:

Java: var = value;

Squeak: var := value;




String concatenation:

Java: Uses methods to do concatenation of String objects.

Squeak: "," character can be placed in between strings to concatenate them.
Since everything in squeak is an Object, even literal strings are
actually objects, and all strings interpret "," as a message, which
does the actual concatenation.




Operator Overloading:

Java: currently doesn't exist

Squeak: Exists






Cascading function calls:

Java: Capability doesn't exist.

Squeak:

Format:

receiver
firstMessage;
anotherMessage;
lastMessage.


All messages (along with their arguments if any) are separated by
";" instead of the "." used to signify the end of a line of code.
The exception to this is the last message in the list, which should
be ended with a "." to denote the end of the series of messages.





Order of evaluation:

Java: Uses precedence

Squeak: Evaluates left to right

Example:

- Input: 4 + 4 / 2

- Java-Output: 6

- Squeak-Output: 4

To get the same output in squeak that you would normally get in Java, you
must use parentheses. The above statement could be changed to:

4 + (4 / 2)

Which would also have a result of 6 in squeak.






GUI kits:

Java: swing and awt

Squeak: Morphic and MVC






Documentation/Documentation Capabilities:

Java:
- Extensive documentation and tutorials available online.
- Documentation very clear
- JavaDoc tool can be used to generate documentation from comments in
source files. Such documentation can then be viewed online/through a
web browser.

Squeak:
- ha
- Poorly documented generally
- "Poke-ability"/ability to view source of anything can help make up for
lack of useful documentation.





Execution:

Java:
- platform independent bytecode
- executed by a VM in the native environment

Squeak:
- platform independent bytecode
- executed by a VM within Squeak environment

Links to this Page