Special moments in an AP Computer Science course
Person: *looking at my code* Why did you use "scan
" as the variable name? I use one-letter variable names, like "a
".
Me: *thinking* people like you are the reason we use jquery for addition
Me: It's more readable that way...
Friend: Yo can you help me, my code isn't getting the right month.
Me: Sure. *turns to his code*
Me: W... why on earth did you use single-letter variable names??
Person: That's how I roll.
Me: *squints at code* Um, ask someone else, maybe?
Person: Gotcha.
Person A: *to person B* So you use new
to create a pointer, like in C++ or C.
Me: Java doesn't have pointers.
Person A: Of course it does.
Me: Not really, no...
Person A: The new
keyword in C++ makes a pointer, it's just like that—
Me: We could look at JavaScript, the new
keyword doesn't make a new pointer there—
Person A: Why are you talking about JavaScript? That's not Java.
Me: Neither is C++.
Person A: I have seven years of programming experience, if you want to deny a verifiable fact, I won't stop you.
Me: I have five years of experience.
Person A: Stop talking. *turns to person B* Anyway. You need new
to create a Scanner
class...
Java doesn't really have pointers in the traditional sense. Rather, everything is an object. Java is object-oriented, after all.
Teacher: Class, lessons 12 to 14 are due tomorrow.
Person: Heh. I've finished like up to 27.
while
loops in lesson 17... finally...
Being tired of writing long, verbose Java code, I wrote a small language that compiles to readable Java code. I call it "stoj", short for "short to Java". Observe:
Original program, in Java
import java.util.Scanner;
public class Lesson_12_Activity_Three {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
double a = scan.nextDouble();
if(a < 0 || a > 100)
System.out.print("Not ");
System.out.print("Valid");
}
}
"stoj" code
Lesson_12_Activity_Three
Id@a?:a C0CB{"Not "p}"Valid"p
Comments
Post a Comment