Core Topics Continued

Descripción

Mapa Mental sobre Core Topics Continued, creado por Bhavit Chhatralia el 27/05/2014.
Bhavit Chhatralia
Mapa Mental por Bhavit Chhatralia, actualizado hace más de 1 año
Bhavit Chhatralia
Creado por Bhavit Chhatralia hace más de 10 años
31
0

Resumen del Recurso

Core Topics Continued
  1. Recursion
    1. a method calling itself
      1. Indirect recursion: Method A calls method B that calls method A
        1. Potentially can go on forever (until memory full - Stack Overflow
          1. Very powerful construct based on mathematical induction.
            1. Recursive programming
              1. All loops can be implemented as recursive calls
                1. int f(int x) { if ( x<1 ) { return 0; } return x + f(x-1); }
                2. Inefficient in java, but core concept in functional programming
                3. Programming recursively
                  1. When programming, "solve" a problem by using another method (call it before you implement it)
                    1. When this other method is the calling method, you have recursion.
                      1. Recursion is not a goal in itself
                        1. Recursive data structures (XML documents, file directories (called folders in windows), linked lists etc.) are most easily handled with recursive functions.
                      2. Programming Language Concepts
                        1. Paradigms
                          1. Imperative
                            1. describes computation in terms of statements that change a program state
                              1. The term is used in opposition to declarative programming, which expresses what the program should accomplish without prescribing how to do it in terms of sequences of actions to be taken
                              2. Logic
                                1. Popularized by Prolog
                                  1. Based on predicate calculus
                                    1. Starts with statements of facts – parent(john, jake), parent(jake, jack)
                                      1. Uses rules – grantparent(X,Z) :- parent(X,Y), parent (Y,Z)
                                        1. Uses inference to determine true statements – grantparent(A, jack). will result in A = john
                                          1. Very good at searching solutions
                                            1. Basically implements the depth first search algorithm (as used for certain kinds of AI)
                                            2. Functional
                                              1. Based on mathematical "pure" functions
                                                1. Allows for straightforward mapping to computer science
                                                  1. Functions are first class
                                                    1. Based on recursion (and mathematical induction), and conditional expressions (not on explicit loops)
                                                      1. No variables (but named parameters), no side effects
                                                        1. By default thread safe
                                                          1. Lisp, Scheme, ML, Haskell
                                                        2. Concepts
                                                          1. Primitive
                                                            1. Primary building block of which other composite types can be build
                                                              1. Corresponds (mostly) with cpu supported type
                                                                1. Operations generally translate directly to machine instructions
                                                                2. Type
                                                                  1. Primitive (subset of built-in)
                                                                    1. Built-in (generally primitive + string + array)
                                                                      1. User defined
                                                                        1. Enumerations
                                                                          1. Range types
                                                                            1. Structured / composite types (classes)
                                                                            2. All values have a type. Different types have different sizes, thus type is needed at run-time.
                                                                            3. Literal
                                                                              1. Directly typed in to code
                                                                                1. Mostly only for built-in types
                                                                                  1. C++11 allows user defined literals
                                                                                    1. Sometimes has special type system support for conversions
                                                                                    2. Constant
                                                                                      1. Name that represents a value that is defined at compile time.
                                                                                      2. Variable
                                                                                        1. Name that represents a storage location for a value.
                                                                                        2. Scope
                                                                                          1. Block – Visible inside the block of definition
                                                                                            1. Function – Visible for the function
                                                                                              1. Class – Visible in the entire class
                                                                                                1. Unit – Visible in the file
                                                                                                  1. Global – Visible for the whole program (often with import rules), sometimes only at runtime
                                                                                                  2. Namespace
                                                                                                    1. Package in Java
                                                                                                      1. Module in Python
                                                                                                        1. Namespace in C++, XML
                                                                                                          1. Allows for names to be reused without conflicts
                                                                                                            1. Especially useful for libraries, as naming conflicts can be really annoying (esp. as the linker works on a global level)
                                                                                                            2. Function
                                                                                                              1. Group of functionality that takes parameters and returns a value
                                                                                                                1. If pure, only depends on (and doesn't change) its parameters. Repeated invocation has the same results.
                                                                                                                  1. Non-pure functions may use external state (a file, the time, etc.), or modify parameters (random.nextInt())
                                                                                                                    1. Object member functions have the object as a parameter
                                                                                                                    2. Expression
                                                                                                                      1. A variable reference
                                                                                                                        1. A function call
                                                                                                                          1. A literal
                                                                                                                            1. The application of a unary operator on an expression
                                                                                                                              1. The application of a binary operator on two expressions
                                                                                                                                1. An expression always results in a value
                                                                                                                                2. Operator
                                                                                                                                  1. Unary (-x), Binary (x + y) or ternary ( _ ? _ : _)
                                                                                                                                    1. Makes compound expressions possible
                                                                                                                                      1. Some languages only have operator for built-in types, others allow overloading
                                                                                                                                        1. Operator precedence makes custom operators tricky.
                                                                                                                                        2. Statement
                                                                                                                                          1. Building block of a code block (such as a function)
                                                                                                                                            1. Does not necessarily result in a value
                                                                                                                                              1. An expression may be a statement (depending on the language)
                                                                                                                                                1. Could be an assignment
                                                                                                                                                  1. Could be a definition (variable, type, function)
                                                                                                                                                2. Type Systems
                                                                                                                                                  1. Static typing – Types are checked at compile time
                                                                                                                                                    1. Types are specified
                                                                                                                                                      1. "more text" – Can be alleviated using type inference.
                                                                                                                                                        1. Sometimes needs type casting to interpret as another type (with checks)
                                                                                                                                                          1. Sometimes automatic conversion (coercion) is used (from int to long)
                                                                                                                                                            1. Allows the compiler to check correctness
                                                                                                                                                            2. Dynamic typing – Types are checked at run time
                                                                                                                                                              1. "less text"
                                                                                                                                                                1. Allows for "duck typing"
                                                                                                                                                                  1. Any object with the needed methods will work
                                                                                                                                                                    1. Like interfaces without the need for an interface
                                                                                                                                                                      1. (C++ templates do this at compile time)
                                                                                                                                                                      2. Type errors become apparent at run-time
                                                                                                                                                                        1. As different types need different storage sizes, must be heap bound
                                                                                                                                                                        2. Strong vs Weak
                                                                                                                                                                          1. Strong detects all type errors at compile or run time
                                                                                                                                                                            1. Java is strong
                                                                                                                                                                              1. C/C++ allow aliasing, unsafe casts, and union types are not checked
                                                                                                                                                                              2. Type Compatibility
                                                                                                                                                                                1. Structure type compatibility
                                                                                                                                                                                  1. If the structure is the same, the type is the same.
                                                                                                                                                                                    1. What about degrees Celcius vs Fahrenheit
                                                                                                                                                                                    2. Name type compatibility
                                                                                                                                                                                      1. Type is only compatible with itself
                                                                                                                                                                                      2. Most languages have a combination
                                                                                                                                                                                    3. Interpreted languages vs compiled languages
                                                                                                                                                                                      1. Gray area
                                                                                                                                                                                        1. A parser reads the code and creates (possibly partially) an abstract syntax tree
                                                                                                                                                                                          1. An interpreter will execute the AST
                                                                                                                                                                                            1. A compiler will translate the AST into an alternative (executable) representation.
                                                                                                                                                                                          Mostrar resumen completo Ocultar resumen completo

                                                                                                                                                                                          Similar

                                                                                                                                                                                          Raíz Cuadrada 75.281
                                                                                                                                                                                          JL Cadenas
                                                                                                                                                                                          First Certificate - Use of English Parte 3
                                                                                                                                                                                          Diego Santos
                                                                                                                                                                                          Examen de Sociales - GED
                                                                                                                                                                                          Diego Santos
                                                                                                                                                                                          Test de verbos en alemán
                                                                                                                                                                                          Ariel Pedernera
                                                                                                                                                                                          Elementos De la Casa
                                                                                                                                                                                          RAÚL ASFA
                                                                                                                                                                                          LOS ANIMALES VERTEBRADOS
                                                                                                                                                                                          diazcardenasjack
                                                                                                                                                                                          Enseñando con Mapas Mentales
                                                                                                                                                                                          Diego Santos
                                                                                                                                                                                          Cuentas contables
                                                                                                                                                                                          Maria Fernanda Encalada
                                                                                                                                                                                          EL DIÁLOGO
                                                                                                                                                                                          Eva Sánchez
                                                                                                                                                                                          TEST DEL MODERNISMO Y GENERACIÓN DEL 98
                                                                                                                                                                                          iranzu90 pascal
                                                                                                                                                                                          CONTAMINACION AMBIENTAL
                                                                                                                                                                                          Camiloski Dioski