COMP 2103 — Programming 3 Part 1 Jim Diamond CAR 409 Jodrey School of Computer Science Acadia University
1 Course Objectives We shall cover the C programming language, emphasizing • – procedural programming techniques – correctness – robustness – portability the GNU/Linux operating system, emphasizing • – tools and utilities for efficient and effective programming – the C programming interface with the Linux operating system the use of the shell as • – a command interpreter – a scripting language debugging • an introduction to modifying other people’s “mystery code” • (if time permits) Jim Diamond, Jodrey School of Computer Science, Acadia University
2 General Information • Read course outline at http://cs.acadiau.ca/~jdiamond/comp2103/comp2103.pdf this document refers to other documents you must read – Getting help • – ask questions in class! – my office hours (CAR 409): MWF 8:30–9:30, other times TBA and/or by appointment – if you need to see me at other times, e-mail or phone me and we can set up a meeting time – TA contact hours, if desired by the class, shall be announced RSN – the lab supervisor (Kelvin in CAR 208) is also be available for help To pretend to know when you do not know is a disease. To know that you do not know is the best. — Lao Tzu Jim Diamond, Jodrey School of Computer Science, Acadia University
3 Reference Materials • C for Java programmers by Dr. Tomasz M¨ uldner (2000) – designed for people who already know Java – includes “programming idioms” and related topics Programming in C by Stephen G. Kochan (4th edition, 2014) • – this has more detailed explanations of C constructs Computer Science: A Structured Programming Approach Using C by • Behrouz A. Forouzan and Richard F. Gilberg (3rd edition, 2005/06) Shell programming references • – Unix Shells by Example by Ellie Quigley (4th edition, 2004) – Bash-Prog-Intro-HOWTO (free download) – Advanced Bash-Scripting Guide (free download) – although some “internet shell experts” pooh-pooh this document Jim Diamond, Jodrey School of Computer Science, Acadia University
4 Next Things To Do • For next class, read http://staff.washington.edu/jon/pubs/safety-critical.html – think about it, don’t just skim it – be prepared to discuss this and/or answer questions on a quiz Self-evaluation quiz: go to Acorn, COMP 2103 • – you have six minutes for the 11 short questions Jim Diamond, Jodrey School of Computer Science, Acadia University
5 Course Environment • All course work shall be done using Linux – have Linux on your laptop by Wednesday! The course outline points to some tutorials to get you started • – start reading them today! (This means you!) • Put “learn about regular expressions” on your to-do list – we shall briefly cover these later in the course, but an in-depth knowledge will serve you well for as long as you do computing • I will not use Acorn for assignments – read your Acadia e-mail – and look in http://cs.acadiau.ca/~jdiamond/comp2103/assignments/ Jim Diamond, Jodrey School of Computer Science, Acadia University
6 Assignment Submission: 1 • Assignments are submitted via https://cs.acadiau.ca/~jdiamond/course2016/student – read the docs (at my web site) which explains how to submit a problem solution using Course2016 – before the deadline, you can re-submit problem solutions as many times as you like: submit early, submit often – and then check your submission! – after the deadline, you may only submit a solution to a given problem if you have not already submitted – so after the deadline make sure you do it correctly on the first try! Jim Diamond, Jodrey School of Computer Science, Acadia University
7 Assignment Submission: 2 • Course2016 automatically applies an adjustment factor for assignments submitted early or late; the current scheme is Hours Early ≥ 72 ≥ 48 ≥ 24 ≥ 0 ≥ − 24 < − 24 Adjustment Factor 1 . 20 1 . 10 1 . 05 1 . 00 0 . 67 0 . 00 The final grade for a particular solution is calculated by multiplying the marker’s grade by the above adjustment factor The Course2016 system should be set up and ready to go later today • – just in case you have problems figuring out how to submit your assignment, do not wait until the last minute – that is, try logging in later today and looking at the system Jim Diamond, Jodrey School of Computer Science, Acadia University
8 Useful Tools To Know (Right Away) We shall use the bash shell (command interpreter) to enter commands • and to write programs – we shall see how a command-line interface can be a very powerful tool compared to a GUI – there are other shells available; I prefer zsh for interactive usage, other people like ksh , tcsh , or others yet – more on this topic in a couple of slides . . . • Web browsers: firefox is (probably) already installed on your system – others ( opera , chromium / chrome , epiphany , . . . ) are available for – download; go wild Any of the commands “ acroread file.pdf ”, “ xpdf file.pdf ”, • “ okular file.pdf ” and “ evince file.pdf ” will display a PDF file on your screen, if you have those programs installed – or double-click in your file browser and see what happens Jim Diamond, Jodrey School of Computer Science, Acadia University
9 A Few Useful Commands man <something> — read the manual page for <something> • – e.g., man man gives you the “man” page for the man program apropos — discover “man” pages dealing with a word of interest • apropos file – e.g., shows you a one-line summary of many man pages, each of which deal with files ls — l i s t files • man ls – there are many, many options; read grep — look for a string (or a regular expression!) in one or more files • – or in the output of another program! cp , mv and rm — c o p y, m o v e (rename) and r e m ove (delete) files • mkdir — m a k e a new dir ectory • exit — terminate the shell program • more , less and most — programs for browsing text files or textual • output of other programs Jim Diamond, Jodrey School of Computer Science, Acadia University
10 RTFM: Read The (*cough*) Fine Manual Jim Diamond, Jodrey School of Computer Science, Acadia University
11 Real (Non-toy) Editors Most (80%? 90%? 95%?) of your (programming) time spent at your • computer will be entering and editing program or data files • A poor editor will slow you down immensely , compared to a powerful editor – learning a powerful editor will pay for itself many times over Two good choices: • vim (“ vi i m proved”): vi is the standard Unix text editor, available – on most (all?) Unix systems – clones (like vim ) available for most OS’s (not just Unixes) – two modes: input and command emacs : the all-singing, all-dancing editor – it can do effectively anything (including emulating vi ) – – extensively customizable – you can extend the editor (i.e., add functions and capabilities you want) by writing “emacs lisp” functions – there are various tutorials for both editors: learn (at least) one!! Jim Diamond, Jodrey School of Computer Science, Acadia University
12 GUIs vs. Command-Line Master Foo Discourses on the Graphical User Interface One evening, Master Foo and Nubi attended a gathering of programmers who had met to learn from each other. One of the programmers asked Nubi to what school he and his master belonged. Upon being told they were followers of the Great Way of Unix, the programmer grew scornful. “The command-line tools of Unix are crude and backward”, he scoffed. “Modern, properly designed operating systems do everything through a graphical user interface.” Master Foo said nothing, but pointed at the moon. A nearby dog began to bark at the master’s hand. “I don’t understand you!” said the programmer. Master Foo remained silent, and pointed at an image of the Buddha. Then he pointed at a window. “What are you trying to tell me?” asked the programmer. Jim Diamond, Jodrey School of Computer Science, Acadia University
13 GUIs vs. Command-Line (continued) Master Foo pointed at the programmer’s head. Then he pointed at a rock. “Why can’t you make yourself clear?” demanded the programmer. Master Foo frowned thoughtfully, tapped the programmer twice on the nose, and dropped him in a nearby trashcan. As the programmer was attempting to extricate himself from the garbage, the dog wandered over and piddled on him. At that moment, the programmer achieved enlightenment. ( http://catb.org/esr/writings/taoup/html/gui-programmer.html ) Jim Diamond, Jodrey School of Computer Science, Acadia University
Recommend
More recommend