200 likes | 210 Views
Learn about modern programming languages, including Java, C++, Scala, and Go, and develop skills in reasoning about program correctness, debugging, and maintainability.
E N D
COMPSCI 220 Programming Methodology
What Have You Learned So Far? Java Java Java Java Java!!+a few algorithms & data structures
Different Tasks => Different Languages GLShader Arduino-C Python
The COMPSCI 220 Approach • You will need to learn many new languages to succeed in computer science • We’d love to spend 10+ years teaching you all the languages(but then you’d miss the new languages introduced in those years) • We don’t have 10+ years Thus, what we will teach you: • Principles that translate across any modern language, including Java, C++, Scala, Go, Swift • How to reason about programs for correctness, ease of debugging, and maintainability
A Modern Take On JavaScript COMPSCI 220-JS: Design to match other languages • JavaScript has been around for > 20 yearsMany old ways of programming still existNew features, abstractions, and capabilities have been continuously added • COMPSCI 220: An emphasis on modern JavaScriptChecks will disallow older features that have been supersededKnown bad coding practices are explicitly prohibited • Arbitrary JS code from the internet may not compileMuch of the internet uses older JS features, and often poor coding practicesYou should not be using code from the internet for assignments anyway • Anything you write in Ocelot will work outside class
What We Will Focus On (A Sampler) • First-class functions • Higher-order functions • Dynamic typing • Testing: unit, property based, reference • Functional programming • Abstract data types • Applications: Robotics, programming language implementation
Rules • Read the syllabusMore rules included in the syllabus • Work on your ownCheating = automatic F • Your code must compileDoes not compile = 0 on assignment • Late policy: four late days, then penalty per daySee syllabus for details
Rules • Deadlines are hard and non-negotiable • Exam: make-up exam or disability service requests must be approved one week before the exam. • If you fall ill on the day of exam and have to request a make-up, you must provide an official doctor’s note. • No accommodation will be made after the exam.
How To Succeed • Start assignments earlyYou will need to think about them before coding.Starting on the last day will not work well. • Come to office hours and discussionsThe quickest and easiest way to resolve doubts. Even faster than Piazza, email, text, facebook, twitter, etc. • Ask questionsIf you have a doubt about something, so will others. Those who don’t, will benefit from revision. You’re really helping everyone by asking.
JS: Basic Syntax; Using the Console let a = 42; // Declare a variable, and assign it a number. let b = 'Hello World'; // A string. let c = [0, 1, 4, 9]; // An array of numbers. const pi = 3.14159265359; // A constant. console.log('The value of pi is ' + pi.toString()); // Print to the console. console.log(c); // The console can display objects. let d; // Will not compile: need to initialize value. // The === operator in JS is equivalent to the == in other languages. if (1 === 1) { console.log('All is good.'); } function factorial(x) { let y = 1; for (let z = 1; z <= x; ++z) { y = y * z; } return y; }
Types in JavaScript • Static types: In Java, you have to specify the types of variables and methods. The Java compiler catches type errors before you run the program. • Dynamic types: In JavaScript, you do not have to specify the types in the program. The JavaScript evaluator catches type errors when the program is running. • Note: JavaScript has types. > typeof 1 "number" > typeof 2.3 "number" > typeof "Hello, world!" "String" > typeof true "boolean" Note: all numbers have the type "number", which is equivalent to the type double in Java.
Some Small Gotcha Points About JS • Instead of "==", use "===". Instead of "!=", use "!=="JavaScript does not treat "==" and "!=" the same way as other languages. We will not use this feature: remember, good programming practices. • The type of a variable can changeDo not deliberately use this feature. It hampers readability, and may lead to bugs. let a = 2;a = "Hello world"; • The value undefined has type "undefined". It is similar to null in Java.
Project 1: Image Processing Removed green and blue Grayscale Highlight edges Blur
COMPSCI 220 Homework Programming: • Submit on Gradescope • Autograder will only reveal full test results after due date. Only a few simple test results will be shown before. Written: • Fill in the answers, and upload pdf to Gradescope See course website for late policy