1 / 16

CSCI 273: Processing An Introduction

CSCI 273: Processing An Introduction. Programming Languages An abstract "human understandable" language for telling the computer what to do The abstract language must be translated into the low level language understood by the machine. Programming Languages How does a computer work?

Download Presentation

CSCI 273: Processing An Introduction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSCI 273: Processing An Introduction

  2. Programming Languages • An abstract "human understandable" language for telling the computer what to do • The abstract language must be translated into the low level language understood by the machine

  3. Programming Languages • How does a computer work? • The translation from a text source to machine code is accomplished by an interpreter or compiler • How does a compiler work? • How does an interpreter work? Instruction 1 0000 0000 0001 0000 0011 0001 (moving the number from memory location "3" to Register # 1) Instruction 2 0000 0000 0001 0000 0100 0010 (moving the number from memory location "4" to Register # 2) Instruction 3 0000 0000 0011 0001 0010 0011 (Adding Register #1 and Register # 2, and putting the result in Register # 3) Instruction 4 0000 0000 0010 0011 0000 0100 (Moving the contents of Register # 3 in Memory location "4")

  4. Compiler

  5. A Simple Java Program /* this is a simple Java program */ class Example { public static void main(String args[]) { System.out.println("this is a simple Java program"); } } Human Readable??

  6. Java VM assembly code (bytecode) • Bytecode is interpreted by machine-specific Java Virtual Machines (JVMs). • Bytecode consists of simple, step-by-step instructions for the JVM. public static void main(java.lang.String[]); Code: 0: iconst_0 1: istore_1 2: goto 30 5: getstatic 8: new 11: dup 12: ldc 14: invokespecial #23 17: iload_1 18: invokevirtual #27 21: invokevirtual #31 …

  7. How Java Works Source code is first written in plain text files ending with the .java extension. Those source files are then compiled into .class files by the javac compiler. A .class file does not contain code that is native to your processor; it instead contains bytecodes — the machine language of the Java Virtual Machine1 (Java VM). The java launcher tool then runs your application with an instance of the Java Virtual Machine.

  8. Java Virtual Machine • Java VM is available on many different operating systems. • The same .class files are capable of running on Microsoft Windows, the Solaris TM Operating System (Solaris OS), Linux, or Mac OS.

  9. But we’re using Processing • Processing is built on top of Java • Supports script-like coding • Easy to get simple programs up fast • But allows transition to full Java programming • Has built-in methods and classes to make drawing easy • Easy to export program to applet

  10. Processing Environment Menu Toolbar (run, stop, new, open, save, export) Tabs Text editor (this is where you type code) Message area (feedback, errors) Text output (print commands)

  11. Drawing in Processing • Automatic creation of display window • Window has a coordinate system for drawing

  12. Let's draw a point: point() • point(x, y) – draws a point at the location x, y • Try it in Processing: point(50, 50) Unexpected token: null – what the #@#$ !?! • Compiler errors appear in the bottom pane • All lines must be terminated with a semicolon ; • Try drawing several points

  13. Comments • Comments are non-program text you put in the file to describe to others (and yourself) what you’re doing • Important for being able to look back at your code and understand it • Single-line comments begin with // • Multi-line comments begin with /* and end with */ • Commenting and un-commenting lines useful for figuring out code

  14. Moodle - http://learnonline.unca.edu • If you are new to Moodle, a new account was created for you and the login instructions, including your password, was emailed to your UNCA email address.  If you forward your UNCA email to an external account, check the Spam/Bulk mail folder of that account for the email. • If you have forgotten your password, go to the Moodle login screen and select the Lost Password link.

  15. Lab 1 • Lab 1: Draw a 200 x 300 white canvas. Add 5 points and 5 lines. Revise the 5 points and 5 lines into a composition.

  16. Homework • Read pages 1-10 for our next class. • If you have a home computer, download and install Processing from processing.org

More Related