1 / 9

Programming Languages

Explore the similarities and differences between programming and natural languages in terms of syntax, grammar, and semantics. Understand how to use programming languages to give instructions to a computer effectively.

slester
Download Presentation

Programming Languages

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. Programming Languages V22.0002 Deena Engel’s class

  2. Programming languages and Natural Languages They both use: • syntax (e.g. punctuation) • grammar (“well formed sentences”) • parts of speech (analogous to data types) • Semantics (the meaning of symbols and words)

  3. Natural Languages use: Syntax: punctuation and spacing Grammar: to create “well formed sentences” (e.g. subject-verb-object) Parts of speech: nouns, verbs, adjectives Semantics: the meaning of the words and what they represent (e.g. in English, “cat” refers to a furry, four-pawed mammal in the Great Cats family)

  4. Programming Languages use: Syntax: punctuation such as parentheses, braces, brackets, semicolons, etc Grammar: well-formed structures such as blocks of code and statements within Parts of speech: can be viewed as the different data types such as integers, characters, text Semantics: the meaning of the symbols, e.g. =, + and others; or the use of reserved words.

  5. Writing Steps in writing code in a programming language: Source code Compiler  Machine language

  6. Style • Style counts … in both kinds of languages! • In natural language … style distinguishes the type of writing e.g. the differences between a sonnet by Shakespeare and a weekly shopping list… • In a programming language, style is both important to make the program readable and more efficient

  7. How to use programming languages: • Natural languages: can be used to tell a story … and other purposes … as well as to give instructions. • Cookbooks and how-to books provide instructions in a natural language: “mix ½ cup of sugar into the butter” • The instructions might include decisions: “if these are chocolate chip cookies, add chocolate chips and shredded coconut ; otherwise just add shredded coconut”).

  8. Programming Languages... Give instructions to the computer… • A computer program is like a recipe except that the computer follows the instructions.

  9. Programming Languages give instructions: • Any series of repeated instructions can be called an algorithm. In many cases, the programming language mirrors what you would do if you were doing the task manually. • For example: To keep a running total in a checkbook … First: order the amounts by the date of the check; then, if it’s a check, subtract the amount or if it’s a deposit, add the amount; then print the current total • For example: To create an index of important terms in a book: First, read or scan the text; discard extra words (“the”, “and”); list the important terms and their pages; write it up as an index in alphabetical order.

More Related