Unformatted text preview:

Programming LanguagesProgramming languages and Natural LanguagesNatural Languages use:Programming Languages use:WritingStyleHow to use programming languages:Programming Languages...Programming Languages give instructions:Storing DataProgramming LanguagesV22.0002Deena Engel’s classProgramming languages and Natural LanguagesThey both use:•syntax (e.g. punctuation) •grammar (“well formed sentences”) •parts of speech (reserved words) •semantics (meanings of variables, objects similar to pronouns)Natural Languages use:Syntax: punctuation and spacing Grammar: to create “well formed sentences” (e.g. subject-verb-object) Parts of speech: nouns, verbs, adjectivesSemantics: 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)Programming Languages use:Syntax: punctuation such as parentheses, braces, brackets, semicolons, etc Grammar: well-formed structures such as “for loops” and othersParts of speech: different data types such as integers, characters, datesSemantics: the meaning of the symbols, e.g. x = 3; or the use of reserved words.Writing Steps in writing code in a programming language:Source code Compiler  Machine languageStyle•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 my weekly shopping list…•In a programming language, style is both important to make the program readable and in terms of efficiencyHow 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”).Programming Languages...Give instructions to the computer!•A computer program is like a cookie recipe except that the computer follows the instructions!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:•Keeping a checkbook: order the amounts by the date of the check; if it’s a check, subtract the amount; if it’s a deposit, add the amount; then print the running total•Create an index for a textbook: read the text; discard extra words (“the”, “and”); list the important terms and their pages; write it up as an indexStoring DataProgramming languages are also used to track information in logical ways: For example, one can write a program to creating a database of names, addresses and telephone numbers. We will look at this means of expression as


View Full Document

NYU CSCI-UA 0002 - Programming Languages

Download Programming Languages
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Programming Languages and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Programming Languages 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?