Title: CSE 655 Programming Languages
1CSE 655 Programming Languages
- Summer 2010Dr. Robert F. Mathis
- DL250, by appointment,generally before and after
class - 4 credits, but only 3 lecture hours(implies a
lot (10) of outside work) - Expect to learn a lot and enjoy being done
2CSE 655 Planning Su09
- PL/0 compiler traditional (imperative) languages
- Lisp (functional) and its interpreter
similarities - XML/XSLT string matching (declarative)
- Patterns in programming
- Mid-level constructor, façade, singleton, etc.
- Low-level loop, selection, exit, exception
- Parameterized types generics, templates
- Event-oriented programming, concurrency,
distributed programming, web services - Environments Eclipse and its extensions
3655 Class Web Site
- http//www.cse.ohio-state.edu/
bmathis - All other pages are linked off this site
- Bookmark and consult frequently
- Primary means of out of class communication
- bmathis_at_cse.ohio-state.edu
4CSE Textbook
- Concepts of Programming Languages, 4th, 5th, 6th,
7th, 8th Ed, by Robert W. Sebesta, - Study outline for use in note taking
- Not many days devoted to text material,but
relevant throughout course. - In class text-related slides are almost all
directly from the text and keyed to it.(Copies
of the slides really not efficient.) - Use class time to integrate your reading and
instructors perspective.
5CSE 655 Textbook - Sebesta
6Sebesta 9th Edition
- Physical text v. electronic text
- Robert W. Sebesta, Concepts of Programming
Languages, Ninth Edition, http//www.coursesmart.c
om/givecoursesmartatry?xmlid9780136076896__instr
uctor2187380
7Exams and Grading
- Midterm Thursday, July 22 download
- Final Wednesday, August 25 download
- Short answer, closed book, referring to text,
class, and programming assignmentsprevious
examples linked from web page - Project students propose and implement
functional requirements for a language processor,
due - Mid 25, Final 25, Project 40, other 10
8CSE 655 Midterm Download
- This midterm is being released at 800am,
Thursday, July 22, 2010and MUST BE RETURNED by
e-mail to mathis.28_at_osu.eduby 12 noon
Friday, July 22, 2010 -
- Rename the file into which you put your answers
to include your last name. -
- Take this test as if it were a one-hour in-class
closed-book exam. No reference to notes, other
people, or web resources. By returning this test
you are certifying compliance to these rules. -
- Start with the Word (1997-2004 .doc format)
(preferred) or text version, and then fill in
your answers to make a file to return. -
9655 Programming Project
- Requirements for project - mostly non-functional
- Students determine functional requirements
- Most Common hybrid compiler / interpreter for
small language with C/Java-style syntax - Primarily individual, some 2-person groups
- Build on what you already know (e.g., CSE 560)
- Project done in stages
- Work with grader on submission demo
- Possible alternatives may be proposed
- No Perl implementations Java encouraged
10Course Expectations
- Broad perspective on computing
- How programs are developed executed
- Knowledge of alternatives in programming
- Specific information about traditional language
processing concepts - Specifics of programming languages considered in
the common knowledge domain of computer
scientists - Prepare for 50 more years of programming
11Instructor Bob Mathis
- Ph.D. Ohio State, 1969 (7th grade in 1959)(U.
Arlington HS 62, Asst. Dean Grad School 74) - Sun Certified Programmer Java 2 Platform
- Former Convener ISO Java Study Group
- Former Chairman US Technical Advisory Group
(CT22) on international standardization of
programming languages - Former Chairman X3J13 Common Lisp
- Former Convener ISO Ada Working Group (WG9for
Ada83 and Ada95) and former Director,Ada Joint
Program Office, DoD/OSD
12General History With Implementation
- Spring 1971 course project involved a little
interpreter similar to BASIC one students
project became NCR product - Spring 1980 converted PL/0 into Little Ada
compiler and tool set far ahead of other
partial implementations at the time - Winter 1987 Lisp processor served as experiment
for new approaches - 1995-97 experiments with early versions of Java
virtual machines - Winter 2007 Java program to generate MySQL
batch programs
13What Kind of Person Are You?
- There are 10 kinds of people in the world those
who understand binary and those who dont. - Everybody is divided into two categories
- Those who divide people into categories, and
- Those who dont
- People who use programs People who write
programs people who write programs that write
programs people who write programs that write
programs that write programs
14Loading a MySQL Table from CSV
- Real programmers use multiple languages when it
helps solve the problem - This example uses Java and MySQL
- Problem situation
- CSV (comma delimited) file, possibly output from
Excel spreadsheet, with headers - Load into MySQL table
- (Some databases sort of have this functionality
built in, MySQL didnt)
15CSV to MySQL Commands to Data
- Generate MySQL commands
- Create a table with field definitions(initially
text, later hand-edited to numbers, etc.) - Read in field names from first line of CSV
- Build MySQL batch commands
- Once table created, load data using rest of CSV
- Build MySQL batch commands to do it(dont do it
now, build command for later) - Output these MySQL commands(first phase all
based on first line) - Run MySQL commands with same CSV file
16Program to Generate MySQL Batch
- main
- argument with name of file
- read first line of file to get headers
- write SQL to
- create table
- load table from file
- comma delimited
- ignore 1 lines
- close files
17Java Program to Generate MySQL
- Read first line of file
- Break apart on commas (new simplification in
Java 6) - Add varchar as field data type
- Write create table command withheader/field
names and data types - Write load data command withheader/field names
as values names - Note Java without exception handling
18In C/ ltargs0gt _build.txt
- drop table if exists ltargs0gt
- create table ltargs0gt ( ltheaderDefinitionsgt
) - load data infile ltargs0gt .csv
- into table ltargs0gt
- fields terminated by ',
- enclosed by '\"
- lines terminated by '\\r\\n
- ignore 1 lines
- ( ltlistOfValuesgt )
19Part 1 Read First Line for Headers
- public class BatchCodeToLoadAFile
- public static void main(String args)
- // argument with basic name of file to read
from - // read first line of file to get headers
- String fileName "C/" args0 ".csv"
- BufferedReader in new BufferedReader(
- new InputStreamReader(
- new FileInputStream(fileName)))
- String line in.readLine()
- String result line.split(",")
20Part 2 Create Header Definitions
- StringBuilder headerDefinition new
StringBuilder() - StringBuilder valueList new StringBuilder()
- for (int i 0 i lt result.length i)
- resulti resulti.replace('\"', ' ').
- replace('\"', ' ').trim()
- headerDefinition.append(resulti "
varchar(40), ") - valueList.append(resulti ", ")
-
- // take out comma at end
- headerDefinition.deleteCharAt(
- headerDefinition.lastIndexOf(","))
- valueList.deleteCharAt(valueList.lastIndexOf(","
)) - String headerDefinitions headerDefinition.toSt
ring() - String listOfValues valueList.toString()
21Part 3 Write the Batch SQL
- PrintWriter pw_build new PrintWriter(
- new File("C/" args0 "_build.txt"))
- pw_build.println("drop table if exists "
args0 " ") - pw_build.println("create table " args0 "
(" - headerDefinitions ")")
- pw_build.println("load data infile '" args0
".csv" - "' into table " args0
- " fields terminated by ',' "
- "enclosed by '\"' "
- "lines terminated by '\\r\\n'"
- " ignore 1 lines"
- " (" listOfValues ") ")
- pw_build.close()
-
22Running Batch in MySQL
- After logging onto MySQLand chosing your
database \.ltfilename_of_batch_programgt - Steps
- Get CSV file
- Java program to generate batch program
- Run batch program
- Source, translate, run result
23Modify Program for Another Purpose
- Read in CSV (comma delimited)
- Use first row headers as tag names
- Output rest of file with XML marked-up
- Basically same first part as before(repeated
next slide) - Then write XML file(not just code to be executed
later)
24Part 1a Read First Line for Headers
- public class ConvertCSVtoXML
- public static void main(String args)
- // argument with basic name of file to read
from - // read first line of file to get headers
- String fileName "C/" args0 ".csv"
- BufferedReader in new BufferedReader(
- new InputStreamReader(
- new FileInputStream(fileName)))
- String line in.readLine()
- String headers line.split(",")
25Part 2a Create Header Definitions
- // clean up tag names
- for (int i 0 i lt tag.length i)
- tagi tagi.replace('\"', '
').replace('\"', ' ').trim() -
- PrintWriter pw_xml new PrintWriter(
- new File("C/" args0 ".xml"))
- pw_xml.println("lt?xml version\"1.0\"
encoding\"ISO-8859-1\" ?gt" - "lt" args0 "gt)
- while ((line in.readLine()) / null)
- String record line.split(",")
- // clean up values in record
- pw_xml.println("ltrecordgt)
- for (int i 0 i lt record.length i)
- pw_xml.println("lt" tagi "gt" recordi
"lt/" tagi "gt") -
- pw_xml.println("lt/recordgt)
-
- pw_xml.println("lt/" args0 "gt)
- pw_xml.close()
26Multi-Lingual Programming
- Previous examples are extended outlineslots more
details, error checking, testing - Languages are tools to help write programs
- Think about the program you want,think about the
resources available in alanguage, possibly use
more than one - New ideas will come from or be explained in terms
of older languages - Big step from student to professional
27Summary Basic Structure of CSE 655
- First half (10 days) (grading midterm)
- Read the text traditional topics
- Study PL/0 and Lisp and a little XML
- Plan your project
- Second half (grading project final)
- Implement your project
- Advanced concepts in programming
- Throughout
- Language features to build on
- Talk about a couple of languages at a time
28CSE 655 First Ten Days
- 1 General Introduction, text 1 2
- 23 About Pascal, compilers interpreters, virtu
al machines, traditional parsing, project
basics, text 3 4 9 10 - 45 Lisp, functional programming, alternate view
of programming, text 15 16 - 6 XML/XSLT, pattern matching
- 78 Low-level patterns, text 5,6,7,8,9,10,14
- 9 Review/Catch-up 10 Midterm
29PROVERBS FOR THE MILLENNIUM
- Home is where you hang your _at_.
- The email of the species is more deadly than the
mail. - A journey of a thousand sites begins with a
single click. - You can't teach a new mouse old clicks.
- Great groups from little icons grow.
- Speak softly and carry a cellular phone.
- In some places, C\ is the root of all
directories. - Pentium wise, pen and paper foolish.
- The modem is the message.
30PROVERBS FOR THE MILLENNIUM
- Too many clicks spoil the browse.
- The geek shall inherit the earth.
- Don't byte off more than you can view.
- Fax is stranger than fiction.
- What boots up must come down.
- Virtual reality is its own reward.
- Modulation in all things.
- Give a man a fish and you feed him for a day,
teach him to use the Net and he won't bother you
for weeks. - There's no place like your homepage.
31Illuminati -Digerati
- Illuminate (Indiana Joness father)
- Light up, make bright, help explain
- Enlighten spiritually or intellectually
- Illuminati 18th Century Bavarian Secret Society
center of conspiracy theories (e.g., Lord
Croft, Angels and Demons) - Illuminati of the Grand Recursive Order of the
Knights of the Lambda Calculus (Scheme
underground) - Illuminate Online ISP io.com
- Digerati popularized by Edge magazine
- Digerati people skilled with or knowledgeable
about computers
32Philosophy Computer Science
- Practical philosophy (love of knowledge)
- Computer Science
- How programs are developed
- How programs are executed
- Program development
- Programming languages, development environments
- Software engineering
- Digerati people skilled with or knowledgeable
about computers - Computers are everywhere, in everything, related
to everything, and analogous to everything (learn
by analogy and relationships)
33 - ? CSE 655 Course Introduction
- Basics of Programming Languages ?