Incorporating Scheme-Based Web Programming in Computer Literacy Courses
Total Page:16
File Type:pdf, Size:1020Kb
Incorporating Scheme-based Web Programming in Computer Literacy Courses Timothy J. Hickey ∗ Department of Computer Science Brandeis University Waltham, MA 02254, USA Abstract erful) subset of Jscheme[2] – a Java-based dialect of Scheme. The tight integration of Java with Jscheme allows it to be easily embedded in Java programs and We describe an approach to introducing non-science ma- hence makes it easy for students to implement servlets, jors to computers and computation in part by teach- applets, and other web-deliverable applications. Jscheme ing them to write applets, servlets, and groupware ap- is an implementation of Scheme in Java (meeting almost plications using a dialect of Scheme implemented in all of the requirements of the R4RS [4] Scheme stan- Java. The declarative nature of our approach allows dard). It also includes two simple syntactic extensions: non-science majors with no programming background to develop surprisingly complex web applications in about half a semester. This level of programming provides a • javadot notation: this provides full access to context for a deeper understanding of computation than Java classes, methods, and fields is usually feasible in a Computer Literacy course. • quasi-string notation: this simplifies the pro- cess of generating HTML. 1 Introduction The javadot notation provides a transparent access to Java and the quasi-string notation provides a gentle path from HTML to Scheme for novices. It also pro- There are two general approaches to teaching a Com- vides a convenient syntax for generating complex strings puter Literacy (CS0) class. The most common approach of other sorts (such as SQL queries). These two exten- is a broad overview of Computer Science including hard- sions will be discussed at length below. ware, software, history, ethics, and an exposure to in- dustry standard office and internet software. On the Jscheme can be accessed as an interpreter applet (run- other end of the spectrum is the CS0 class that focuses ning on all Java-enabled browsers) or as a Java Network on programming in some particular general purpose lan- Launching Protocol (JNLP) application. Both of these guage, (e.g. Javascript [9], Scheme[5], MiniJava[8]). provide one click access to the Jscheme IDE from stan- dard browsers. It can also be downloaded as a jar file The primary disadvantage of the breadth-first approach and run from the command line as a standard read-eval- is that it tends to offer a superficial view of computing. print-loop program. The depth-first programming approach on the other hand often requires a substantial effort just to learn the syn- Jscheme has been built into a Jakarta Tomcat webserver tax of the language and the semantics of the underly- as a webapp which allows students to write servlets ing abstract model of computation, leaving little time and JNLP applications directly in Jscheme. This web- to look at other aspects of computing such as internet server typically runs on the instructor’s machine, but technology or computer architecture. students can easily download and install the server on their home/dorm PCs as well. Several authors have recently proposed merging these two approaches by using a simpler programming lan- In the sequel, we explain, in detail, how Jscheme can be guage (e.g. Scheme[5]) or by using an internet-based used to teach non-science majors in a large lecture class programming language (e.g. Javascript[9], MiniJava[8]). how to build fairly sophisticated servlets and applets in a six week section of a Computer Literacy course. The In this paper we describe a five year experiment in com- approach described here is very similar to the approach bining these two approaches using a small (but pow- used in the Autumn 2001, “Introduction to Computers” course at Brandeis University, but it reflects changes ∗This work was supported by the National Science Founda- that will be incorporated in the next year’s version of tion under Grant No. EIA-0082393. the course. The course and the underlying language have been evolving steadily over the past five years and course has as its goal teaching almost all of the Scheme will likely continue to do so. language in an introductory course. This leaves little time is left for other topics (e.g. computer architecture, This approach to teaching CS0 is feasible only because chip design, internet programming, ethical and legal is- of the declarative style of programming that is possible sues in computing), but that can be a worthwhile trade- in Scheme, together with the extremely simple syntax off. and semantics of Scheme. In the Jscheme approach we provide an introduction to We posit that this web-programming based approach only a subset of the language (introducing lists only to- would work with other declarative languages (e.g. Haskell ward the end) and we introduce some high-level declara- or Prolog), but would be infeasible with imperative lan- tive libraries for teaching an event-driven model of GUI guages such as Java or Perl. Scheme however is ideally construction. Since the Scheme section of the course suited to this application because of the relative sim- requires only about 6 weeks, it leaves the other half of plicity of its syntax and semantics. Both of which can the course for standard Computer Literacy topics. be stumbling blocks for novice programmers. Although the particular languages and techniques that 3 Role of Programming in CS0 we use may not be the best match at other institutions, we feel that the general approach could be easily repli- cated using other languages provided care is taken to make the syntax and semantics that must be learned as We take a language-based approach to Computer Liter- simple as possible. acy where each section of the course focuses on one par- ticular ”layer” of computation and explores that layer through the predominant language. The students learn how to use each language to control this level of compu- tation (although we do not currently have them program 2 Related Work in real assembly language or build real CMOS devices). A rough outline of the curriculum, which shows the con- text of the web-programming part of the course is shown The need for a simple, but powerful, language for teach- below: ing introductory CS courses (CS0 or CS1) has been dis- cussed recently by Roberts [8] who argues for a new language, Minijava, that provides both a simpler com- • 1 week HTTP and the structure of the Inter- puting model (e.g. no inner classes, use of wrapper class net: IP addresses, ports, sockets, services, routers, for all scalar values, optional exception throwing) and gateways. Use of telnet, dig, traceroute, ping, a simpler runtime environment (e.g. a read-eval-print portscan to illustrate these issues. loop is provided). Jscheme can be viewed as an even more radical simplification of Java in that it replaces • 2 weeks HTML/CSS – the thirty non-style HTML the syntax of Java with the syntax of Scheme (matching tags and 10 basic CSS properties. Copyright is- parentheses and quotes is the only syntactic restriction) sues. while maintaining access to all of the classes and objects • 3 weeks Scheme Servlets – quasi-string nota- of Java. tion, abstraction, conditional execution, lists, file I/O, email, database access. Security, privacy, Another recent approach to CS0 courses is to use Javascript cookies, ethics. to both teach programming concepts and to provide a • 3 weeks Scheme Applets/Groupware – GUI vehicle for discussing other aspects of computing such components, layout, callbacks, animation, network- as the internet and web technology. For example, David ing primitives, groupware components. Doctor ap- Reed proposes teaching a CS0 course [9] in which about plet, Turing Test. Halting problem. Substitution 15% of class time is devoted to HTML, 50% to Javascript, model. Software licenses. and 35% to other topics in computer science. The Jscheme approach allows for a similar breakdown but in addition • 1 week Assembly Language/Pcode - von Neu- allows the students to also build servlets, applets, and mann architecture, memory-mapped peripherals, GUI-based applications. memory, speed, bandwidth, cacheing, super-scalar architectures. Operating Systems, file systems, A third related approach is to teach Scheme directly as time sharing, ... a first course. The MIT approach, pioneered by Abelson • 1 week CMOS/Logic Circuits - semiconductors and Sussman [1], is not suitable for non-science majors (P/N-type), gates, circuits, adders, latches and as it requires a mathematically sophisticated audience. bits. A gentler introduction to Scheme[5] has recently been proposed as a CS0 course which is appropriate (and Observe that the course contains a signficant amount of in fact important) for students in all disciplines. This non-Scheme material that would be found in most typi- cal Computer Literacy courses (such as copyright issues and ethical questions dealing with servers), but with dents (using a tabbed pane with a separate tab for each this programming-based approach these issues are more student). Each student can also connect to many TAs meaningful as the students are able to write servers that (again using the tabbed pane model). Students can ask create logs and must deal with the resulting ethical ques- each other for help if no TAs are available. This tool tions. has only been available as an early prototype in the re- cent CS0 course, but will be fully deployed starting in Summer 2002. 4 Courseware 5 Scheme Servlets The main language used in the course is Jscheme1 [2, 3, 6] an open source implementation of Scheme in Java. It is almost completely compliant with the R4RS stan- Files which appear in the Jscheme webserver student di- dard 2 [4] and also provides full access to Java using rectory with the extension sssp are interpreted as Jscheme the Java Reflector syntax shown in Figure 1.