1 / 32

Computer Programming

Computer Programming. Why are People Afraid of Programming?. Don’t want to be a “nerd” Computer languages are hard What if I don’t understand? Why should I? Everything has already been invented. Why Should I Learn to Program?. Some people find it fun.

kent
Download Presentation

Computer Programming

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. Computer Programming

  2. Why are People Afraid of Programming? • Don’t want to be a “nerd” • Computer languages are hard • What if I don’t understand? • Why should I? Everything has already been invented.

  3. Why Should I Learn to Program? • Some people find it fun. • It is a satisfying means to an end – learn to use a wonderful tool • Learn a new way to think and improve general problem solving skills

  4. Computer Programming • What is computer programming? • Process of writing, testing, debugging, and maintaining the source code of computer programs. • What is a computer program? • A set of instructions that tells the computer what to do. There are many ways to give these instructions – how you do it matters. Learning to program helps shape your thoughts .

  5. Computer Programming • Where does code come from? • Written in a programming language from scratch • Modified from existing code

  6. Computer Programming • Why do we do it? • To create a program that performs a desired behavior. • There is some debate as to whether programming is an art, a craft, or an engineering discipline.

  7. Computer Programming • Programmers work to create code that is efficient (works without draining current resources) and evolvable (can become something bigger in the future) • Programmers hope their code is considered “elegant” (i.e. well written) • Programmers are generally given a list of requirements and then work to translate those requirements into something the computer can understand.

  8. Computer Programming • Programming is often compared to following a recipe. • Programming is about giving the computer step by step instructions to go about completing the task. • The instructions generally take the form of: • a direct statement • a conditional statement • a link to a group of statements • a loop around statements meant to be repeated for some amount of time.

  9. Computer Programming • Programming typically tries to break up large tasks into smaller, more manageable ones. • Often, the program is required to compute a result. • Programmers describe their code to others from within using documentation.

  10. Pizza Dough Recipe (Requirements)‏ 1. Gather Ingredients 2. Combine sugar (1tbs), salt (1tbs), olive oil (1tbs), flour (1c) in mixing bowl 3. Turn on mixer 4. Add 1/4 cup of flour 5. If dough comes off the sides go to step 6, otherwise go back to step 4 6. Knead 15 minutes 7. Let rest for at least 45 minutes in warm area • 1 dough ball

  11. N-Pizza Dough Program • Gather Ingredients • Combine sugar (N tbs), salt (N tbs), olive oil (N tbs), flour (N c) in mixing bowl • Turn on mixer • Add N/4 cup of flour • If dough comes off the sides go to step 6, otherwise go back to step 4 • Knead 15 minutes • Let rest for at least 45 minutes in warm area • N dough balls

  12. N-Pizza Dough Program • Gather Ingredients • Combine sugar (N tbs), salt (N tbs), olive oil (N tbs), flour (N c) in mixing bowl • Turn on mixer • Add N/4 cup of flour • If dough comes off the sides go to step 6, otherwise go back to step 4 • Knead 15 minutes • Let rest for at least 45 minutes in warm area Sequence of Statements • N dough balls

  13. N-Pizza Dough Program • Gather Ingredients • Combine sugar (N tbs), salt (N tbs), olive oil (N tbs), flour (N c) in mixing bowl • Turn on mixer • Add N/4 cup of flour • If dough comes off the sides go to step 6, otherwise go back to step 4 • Knead 15 minutes • Let rest for at least 45 minutes in warm area Variable • N dough balls

  14. N-Pizza Dough - Program • Gather Ingredients • Combine sugar (N tbs), salt (N tbs), olive oil (N tbs), flour (N c) in mixing bowl • Turn on mixer • Add N/4 cup of flour • If dough comes off the sides go to step 6, otherwise go back to step 4 • Knead 15 minutes • Let rest for at least 45 minutes in warm area Conditional

  15. N-Pizza Dough - Program • Gather Ingredients • Combine sugar (N tbs), salt (N tbs), olive oil (N tbs), flour (N c) in mixing bowl • Turn on mixer • Add N/4 cup of flour • If dough comes off the sides go to step 6, otherwise go back to step 4 • Knead 15 minutes • Let rest for at least 45 minutes in warm area Subroutines Mini-programs • N dough balls

  16. Programming Languages • There are hundreds of different programming languages. • A few basic types of instructions appear in all of them • Input (get input from the user) • Output (display data to the user on a monitor or printout) • Math (perform basic mathematical operations) • Conditional Execution (check for conditions and execute the appropriate sequence of statements) • Repetition (perform some sequences of statements repeatedly)

  17. What is Programming? • Using the tools of the language and the ideas discussed above is really what computer programming is all about • Computers only “understand” about 100 different types of instructions. However, there are millions of permutations of these. • Think Chess – 6 pieces that move in simple patterns – why is it a complicated game?

  18. Programming Benefits • Learning how to arrange a sequence of instructions to carry out a task is the most valuable thing you really learn. That involves understanding: • Mathematical and computational ideas • Coordinates, Variables, Random Numbers • Problem solving skills • Process of Design • Idea->Prototype->Experiments->Debugging->Redesign->New Ideas • Fluency with Digital Technology • To be fluent in language, you learn to read AND write – how to express yourself in the language. The same is true of programming – using the computer not just to interact but to create.

  19. Programming Languages • There are hundreds of programming languages and several categories where the languages fall • A few types include • Imperative • Structured • Procedural • Declarative • Functional • Logical • Object-Oriented • Event Driven • Scripting • Markup • Graphical

  20. Imperative Programming Languages • A programming paradigm (i.e. style of programming) that describes computation in terms of statements that change a program state. • In natural languages, the imperative mood expresses commands to take action. • Similarly, imperative programs define sequences of commands for the computer to perform.

  21. Structured Programming • Programming paradigm aimed on improving the clarity, quality, and development time of a computer program • Uses subroutines, block structures, and for or while loops • Idea emerged in the 1960’s. • ALGOL was an early example.

  22. Procedural Programming • Type of Imperative Programming derived from Structured Programming based on concept of procedure call • Programs contain a list of instructions telling the computer what to do, step-by-step, usually having a linear order of execution from the first statement to the second to the last, with occasional loops and branches to subprograms. • Procedures (aka: routines, subroutines, methods, functions) are subprograms that contain step by step instructions for the program to carry out. Can be called at any time during a program’s execution. • EXAMPLES: BASIC, Pascal, C

  23. Declarative Programming • Programming paradigm that expresses the logic of a computation without describing the control flow. • Describe what the program should accomplish instead of how to accomplish it. • Directly in contrast with imperative programming (describing algorithms in explicit steps) • Considers programs as theories of formal logic and computations as deductions in that logic space. • Examples include database query languages (SQL), regular expressions, logic programming, and functional programming

  24. Functional Programming • Programming paradigm that treats computation as the evaluation of mathematical functions. • Roots in lambda calculus. • Attempt to remove the “side effects” that can occur in imperative programming • Output value of the functions depends only on the arguments that are input to the function. Therefore, calling a function with the same inputs will always produce the same results. • Makes behavior of program more predictable • Examples include Common Lisp, Scheme, and is supported in Mathematica • Programming in a functional style can take place in imperative programming languages

  25. Logical Programming • Programming paradigm consists of a set of axioms (facts/rules) and a goal statement. • Rules of inference are applied to determine if axioms are sufficient to ensure truth of goal statement • Execution corresponds to construction of a proof of the goal statement from the axioms • Programmer specifies basic logical relationships and does not specify the way the inference rules are applied • Prolog is considered a logical programming language. An example of prolog code is here: http://williams.comp.ncat.edu/COMP360/Prologfamily.htm

  26. Application Areas of Logical Programming • Relational Data Bases • Natural Language Interfaces • Expert Systems • Symbolic Equation solving • Planning • Prototyping • Simulation • Programming Language Implementation

  27. Object Oriented Programming • Programming paradigm that represents concepts as “objects” • Objects have data fields – attributes that describe the object are called “methods” – methods perform the actions of the object and can modify the data fields • Objects are instances of classes and interact with each other to design applications. • Examples: Smalltalk, C++, Java

  28. Event Driven Programming • Programming paradigm where the flow of the program is determined by events • Events include mouse clicks, key presses, and messages from other programs (aka threads) • Can be written in any language, but easier in some than others.

  29. Scripting Language • Programming language that support writing scripts • Scripts work to automate the execution of tasks that normally take a human operator several one-by-one steps. • Can be used in software applications, web pages within a browser, shells of operating systems, and used in embedded systems. • Small programs (sometimes just a few lines, never more than a few thousand lines)

  30. Markup Languages • A language that “marks up” text, usually for some means of display • Used in most word processors to indicate locations of paragraphs, font type, etc. (TeX, LaTeX) • Structural markers can also be used (XML) • Some have pre-defined presentation semantics (HTML, XHTML)

  31. Graphical Programming Languages • Any programming language that lets users create programs by manipulating program elements graphically rather than by specifying them textually. • Examples include Alice, Scratch, App Inventor

  32. Programming • Many see programming as a tedious, specialized activity • Traditional programming languages can be difficult to learn at first. • Recent developments have worked to create graphical programming languages • Makes programming more engaging and accessible to those first learning

More Related