Copy-of-Programming-01-PRELIMINARIES-REVIEWER_20240916_233420_0000.pdf

Full Transcript

Programming 01 PRELIMINARIES GENERATIONS OF PROGRAMMING LANGUAGE 1ST GENERATION “MACHINE LANGUAGE”...

Programming 01 PRELIMINARIES GENERATIONS OF PROGRAMMING LANGUAGE 1ST GENERATION “MACHINE LANGUAGE” 6 STAGES OF IN DEVELOPING - uses binary codes that consist of string of COMPUTER PROGRAMMING only zeroes and ones Defining the problem - these are languages that a computer can Designing a solution to the program understand and execute directly Writing the program - machine dependent Compiling, debugging, and testing the - low-level language program 2ND GENERATION “ASSEMBLY LANGUAGE” Documenting the research program - uses mnemonics or very short words for Maintaining the program commands WHY DO WE PROGRAM? - program written in assembly language must To make life easier be converted by an ASSEMBLER Let’s take election for example. Back in - low-level language the day, it takes days to determine a victor in - TASM, MASM government elections. So, they posed a solution 3RD GENERATION “HIGH-LEVEL LANGUAGE” in which they would automate the elections for a - more or less independent of a particular type hassle free process. Now, it approximately takes of computer only one day to determine newly elected officials. - closer to human languages and they are TYPES OF PROGRAMMING ERRORS easier to read, write, and maintain - uses a COMPILER to translate the source SYNTAX ERRORS code into machine readable code errors due to the fact that the syntax of the - FORTRAN, BASIC, COBOL, PASCAL, C, C++, language is not respected ALGOL, ADA, JAVA SEMANTIC ERROR 4TH GENERATION “OBJECT-ORIENTED errors due to the improper use of program PROGRAMMING LANGUAGE” statements - organize coding around objects LOGICAL ERROR - event-driven event triggers the the outcome errors that occur when the specification is not of the program respected - JAVA, C+, C#, Visual Basic, VB.NET COMPILE TIME ERRORS 5TH GENERATION “LOGIC PROGRAMMING” errors that occur during the compilation phase - artificial language before the program is run; typically caused by - operates on concept of solving problems incorrect syntax or type-related errors based on constraints or rules that have been RUNTIME ERRORS declared in the program errors occur during the execution of the - the focus is on making the computer program, often due to unexpected conditions program solve the problem for you like dividing by zero or accessing invalid - uses knowledge bases and expert system memory - PROLOG, MERCURY, LISP WHAT IS PROGRAMMING LANGUAGE? Artificial language used to communicate Happy Reviewing Block 5 instructions to a machine (computer) Used to create programs that control the behavior of a machine and/or express algorithms precisely Software used to create another software PROGRAMMING PARADIGMS TYPES OF PROGRAMMING IMPERATIVE/PROCEDURAL PROGRAMMING LANGUAGES - expressing an essential order or MACHINE LANGUAGE command/procedural - binary language (proposed by Gottfried - describes computation in terms of a program Wilhelm Leibniz which was developed in 1689 state and actions that change the state and published in 1703 but the concept of - program consists of explicit commander using it for computer calculations was instructions to be executed, performing pioneered by Dr John Von Neumann ) operations on data and modifying values of - only language that computer understands program variables and the external - very fast in terms of program execution (not environment easy to write) FUNCTIONAL PROGRAMMING - instructions are directly executed by the CPU - computations are specified through - widely used in 1940s up to early 1950s mathematical functions that evaluate input expressions convert them into output values Central Processing - “what”-oriented Unit (CPU) Unique machine language - declarative programming paradigm where programs are created by applying sequential LOW-LEVEL OR ASSEMBLY LANGUAGE functions rather than statements - specific to a given microprocessor or CPU of LOGIC PROGRAMMING the computer - written in logical statements that describe - deals with a computer’s hardware the properties that solutions must have components and constraints - based on the concept of logical deduction in - way higher level language then machine symbolic logic, or the manipulation of symbols language so its faster, however, it is still hard to [e.g. && (and), || (or), > (greater than), = write and read (equal)] HIGH-LEVEL PROGRAMMING LANGUAGE OBJECT-ORIENTED PROGRAMMING - more or less independent of a particular type - data structures are seen as objects; of computer programmers create relationships between - closer to human language “objects” - easier to understand, modify, and debug - CLASS is a group of objects that have same - allow programmers to focus on solving the properties and behaviors problem CURRENT AND DISTRIBUTED PROGRAMMING COMPILER VS INTERPRETER - allows for execution of 2 or more operations translates a program written a program that directly at the same time in high-level language executes the instructions in a (source code) and translates high-level language, without - is concurrent (occurring at the same time), into machine language converting it into machine processes run in tandem using shared (object code) code The first compiler was Lisp interpreter was written resources written by Grace Hopper in in 1958 by John McCarthy's the early 1950s. She also student Steve Russell - parallel suggests that the processes run coined the term “compiler”. side-by-side yet operate independently; TWO TYPES OF PROGRAMMING parallel processing is a sub-set of concurrent PARADIGM processing STRUCTURED PROGRAMMING - enhance lucidity, caliber, and creation efficiency of a computer program by leveraging a plethora of subroutines, block structures, and looping constructs like for and while - procedural programming that uses Top Design Principle - Dr. Edsger W. Dijkstara is a Dutch computer scientist who developed the paradigm of structured programming for writing computer programs. Gosling envisioned the language to resonate CONTROL SEQUENCE SEQUENCE with both system and application programmers, SELECTION/CONDITIONAL LOGIC INTERATION/ LOOPING MECHANISM which is why he infused it with a syntax style that is familiar with C and C++ OBJECT-ORIENTED PROGRAMMING In 1995, Sun Microsystems debuted the first - revolves around objects public version of Java 1.0 embracing a “Write - the idea was first introduced by computer Once, Run Anywhere” (WORA) philosophy scientists Alan Kay and Adele Goldberg in the In 1998, Java evolved into Java , first known as late 1960s J2SE 1.2., it offered several configurations for - the first OOP language is called SIMULA different platforms which was created by Ole-Johan Dahl and Java 2 Enterprise Edition (JEE) incorporated Kristen Nygaard at the Norwegian Computing technologies and APIs tailored for server-side Center in Oslo, Norway in the 1960s apps, while JAVA 2 Micro Edition (J2ME) was optimized for mobile apps MAJOR COMPONENTS OF In 1997, Sun Microsystems sought OBJECT-ORIENTED PROGRAMMING standardization of Java from the ISO/IEC JTC 1 OBJECT and Ecma International but eventually pulled CLASS back. Despite this, Java has remained a de INHERITANCE facto standard, controlled through the Java POLYMORPHISM Community Process. ABSTRACTION ENCAPSULATION On November 13, 2006, Sun Microsystems released most of its Java virtual machine (JVM) as free and open-source software under the terms of the GNU General Public License (GPL) BRIEF HISTORY OF JAVA On May 8, 2007, Sun Microsystems made all of One of the most popular and widely used its JVM’s core code available under free programming languages software/open-source distribution terms. written and developed by Dr. James Gosling Rich Green, executive vice president of and his colleagues in the 1990s at Sun software at Sun Microsystems envisioned Sun Microsystems Microsystems as a Java “evangelist” it was released in 1995 as part of Sun Oracle acquired Sun Microsystems in 2009- Microsystems’ Java platform 2010 and positioned itself as the “Steward of based in terms of syntax and structure in C and Java Technology” C++ James Gosling resigned from Oracle on April 2, open source freely available over the internet to 2010 download and use uses classes, methods, and object to create apps apps written in Java can run on many different operating systems with little or no modification of the code HISTORY OF JAVA spearheaded by James Gosling, Mike Sheridan, and Patrick Naughton; they initiated the Java language project in June 1991 purposed for interactive television initially called OAK because of the oak tree visible from Gosling’s office window also called GREEN before JAVA (inspired by a coffee from Indonesia) TYPES OF JAVA APPLICATIONS BENEFITS OF JAVA 1. Serves as an introductory programming 1. JAVA APPLET - refer to Java programs language for students; widely employed by downloaded from the internet and executed seasoned professionals in the industry. inside your web browser by a JVM that is 2. In Java, variables must be initialized before typically part of the browser they are used, which is a key difference from C. 2. APPLICATION - used to describe Java This requirement helps prevent errors that can programs running locally, standalone on a arise from using uninitialized variables. computer, much like programs on Windows 3. In Java, every method that is not declared as (notepad for example) void (methods that do not return value) must 3. JAVA ARCHIVE (JAR) - a package file format return a value of the specified type. This used to aggregate many Java class files and ensures that the method’s behavior is associated metadata and resources into one predictable and consistent. file for distribution 4. One of Java’s primary assets is its 4. SERVLET - run on a server and handle requests comprehensive API (Application Programming and responses in web applications; key Interface), providing an extensive selection of component of Java web development pre-built classes and methods. 5. SWING APPLICATION - Desktop applications 5. Always maintain the same size in terms of bit that use the Swing toolkit for building graphical count. user interfaces (GUIs) 6. Java was considered slower than C due to its 6. ENTERPRISE JAVA BEANS (EJB) - A server- reliance on the Java Virtual Machine (JVM) for side component that encapsulates business execution, which introduces some overhead logic of an application; used in large-scale compared to C’s direct compilation to machine enterprise applications to handle transactions, code. However, this performance difference security, and scalability has become less significant over time. CHARACTERISTICS OF JAVA 7. Java handles error conditions, including 1. Simple input/output (I/O) errors, using a mechanism 2. Object-oriented called exceptions. When an error occurs, Java 3. Distributed throws an exception, which can be caught and 4. Interpreted handled to prevent the program from crashing. 5. Robust 8. Java’s “Write Once, Run Anywhere” (WORA) 6. Secure approach is its standout feature. This concept 7. Architecture-neutral means that Java code can be written once and 8. Portable then run on any platform without needing 9. High Performance modifications. 10. Multithreaded 11. Dynamic VARIABLES value that can be changed depending on conditions or on information passed to the program can be reused throughout the program, instead of having to type out the actual value all over and over again VARIABLE DECLARATION In Java Programming, you can define a variable with the following format: Data Type Variable Name = Value String User_Name = “Juan Dela Cruz” Always remember that Java is case IDENTIFIERS sensitive programming language similar to IDENTIFIERS - names given to various C languages program elements such as variables, functions, and arrays RULES IN USING VARIABLES The following are the guidelines in creating A VARIABLE CAN: identifiers in Java Any unicode character that is a letter 1. Consists of letters and digits without space, (including numeric letters like Roman in any other, except that the first character numerals) or a digit must be a letter. Currency sign (such as $) 2. Uppercase and lowercase are permitted but Connecting punctuation character (such as _) they are not interchangeable. As an A VARIABLE CANNOT: exception, an underscore may be used as the Variable names are CASE-SENSITIVE. first character of the identifier. A variable’s name can be any legal identifier. 3. Reserved words and standard methods must It can contain unicode letter, digits, and two not be used. special characters such as underscore and $ Example of Valid Identifiers: dollar sign. Length of Variable name can be any number. Salary_Per_Month _area_circle passing_grade75 It is necessary to use alphabet at the start (however, we can use underscore). Age PESONS_NAME User_Name Some auto generated variable may contain ‘$’ sign. But try to not use dollar sign. Grade23 Y passwords White space is not permitted. Special Characters are not allowed. Example of Invalid Identifiers: A digit at the start is not allowed. Subsequent characters may be letters, digits, EXAMPLE REASON FOR INVALIDITY dollar signs, or underscore characters. Variable name must not be a keyword or 3RD Starts with a digit reserved word. RULES IN USING VARIABLES BIR TAX Contains space variables whose value does not change during program execution; useful if we want %price Contains special character to assign value to a variable that is fixed Final Data Type Variable Name = Value while A reserved word IMPORTANCE OF COMMENTS ON PROGRAMS RESERVED WORDS COMMENTS - variables whose value does not standard predefined words; not allowed to change during program execution; useful if use as variable names or objects we want to assign value to a variable that is DATA TYPE fixed specifies possible range of values of the set, 1. Program documentation contains information the operations that can be performed that improves the readability of the program. used so that the compiler or interpreter of a 2. Comments are part of the program programming language can be told about the documentation because they help others read data which is to be used and understand how the program works. The compiler and interpreters, however, ignore comments and they are not translated in machine language. TYPES OF COMMENTS IN JAVA 1. MULTIPLE LINE COMMENTS - comments enclosed by /* and /* 2. SINGLE LINE COMMENTS - comments placed after // symbols From your Block JAVA OPERATORS ARITHMETIC OPERATORS Mayors RELATIONAL OPERATORS LOGICAL OPERATORS BITWISE OPERATORS shift the bit value; first (left) operand represents the value to undergo the shift, while the second (right) operand defines the number of positions to shift the buts in the value significance of both operands is equal ASSIGNMENT OPERATORS Credits: Gwyneth Zoe L. Basto 11-ITE-04 Block Mayor

Use Quizgecko on...
Browser
Browser