• • • • PROGRAMMING LANGUAGE A set of commands, instructions, and symbols that humans can manipulate in order to communicate with computers. An artificial language that can be used to control the behavior of a machine, particularly a computer. Programming languages, like human languages, are defined through use of syntactic and semantic rules, to determine structure and meaning respectively. Programming languages are used to facilitate communication about the task of organizing and manipulating information, and to express algorithms precisely. Coded language used by programmers to write instructions that a computer can understand to do what the programmer wants. HISTORY AND FEATURES - Programming languages have a rich history dating back to the mid-19th century, when Charles Babbage developed the first mechanical computer. Here are some of the key features and historical developments of programming languages: Machine & Assembly Language, Fortran, COBOL, C:, OOP, Scripting Languages, Modern Languages BASIC PRINCIPLES • Syntax - Programming languages have a set of rules or syntax for writing code, including keywords, operators, and punctuation. • Variables - Programming languages allow programmers to use variables to store and manipulate data. A variable is a named storage location that holds a value. • Data types - Programming languages have built-in data types, such as integers, floating-point numbers, strings, and Booleans, to represent different types of data. • Control structures - Programming languages have control structures such as loops, conditional statements, and functions, that allow programmers to control the flow of the program's execution. • Modularity - Programming languages support the modular programming paradigm, which involves breaking down a program into smaller, manageable components or modules that can be developed and tested independently. • Abstraction - Programming languages allow programmers to create abstractions or higher-level concepts that hide implementation details, making it easier to write complex programs. • Error handling - Programming languages provide mechanisms for detecting and handling errors, such as exceptions or error codes. • Input/Output - Programming languages support input/output (I/O) operations to interact with the user or with external devices such as files or databases. CLASSIFICATION Programming languages can be classified based on various criteria, such as their level of abstraction, application domain, and programming paradigm. Here are some of the most common classifications of programming languages: ▪ Low-level and High-level languages Programming languages can be classified as low-level or high-level based on their level of abstraction. Low-level languages, such as Assembly language, provide direct access to hardware resources and have a minimal level of abstraction, while high-level languages, such as Python or Java, offer more abstraction and are easier to read and write. ▪ Procedural, Object-oriented, and Functional languages - Programming languages can be classified based on their programming paradigm, which is the approach used to solve a problem. Procedural languages, such as C, focus on the sequence of steps required to solve a problem. Object-oriented languages, such as Java, focus on modeling real-world objects and their interactions. Functional languages, such as Haskell, focus on functions and their interactions. ▪ Imperative and declarative languages Programming languages can be classified based on whether they specify how a program should be executed (imperative) or what the program should achieve (declarative). Imperative languages, such as C and Java, focus on stepby-step instructions, while declarative languages, such as SQL and Prolog, focus on specifying the desired outcome. ▪ Scripting Languages - Scripting languages, such as Python, JavaScript, and Ruby, are used to write scripts or programs that automate tasks and interact with other software systems. ▪ Domain specific Languages - Domain-specific languages (DSLs) are designed for a particular application domain, such as SQL for databases, MATLAB for scientific computing, or VHDL for hardware description. MAJOR ASPECTS SYNTAX - refers to the set of rules that govern the structure and format of statements in a programming language. SEMANTICS - refers to the meaning of statements in a programming language. DATA TYPES - refer to the kinds of values that can be stored and manipulated in a programming language. CONTROL STRCUTURES - refer to the constructs used to control the flow of execution in a program. ABSTRACTION - refer to the ways in which programming languages allow programmers to abstract away implementation details and focus on higher-level concepts. LIBRARY SUPPORT - refers to the availability of prebuilt libraries and modules that can be used to simplify common programming tasks. TOOL SUPPORT - refers to the availability of software tools and utilities that can be used to develop, test, and debug programs written in a programming language. • • • • • • REASONS TO LEARN PROGRAMMING Attractive Salaries Valuable Skills on resume Can choose many jobs offers Work from anywhere Flexible hours Express your creativity DATA/PRIMITIVE OPERATIONS - refer to the basic operations that can be performed on data types in a programming language. Arithmetic - +, -, *, / Logical – AND (&&), OR (||), NOT (!) Comparison - ==, LESS THAN (<), Greater than (>), <=, >= SEQUENCE CONTROL - refers to the order in which statements in a program are executed. • • • TURBO PASCAL It was developed by Niklaus Wirth Swiss computer scientist in early 1970. Designed to teach structured programming concepts, principles, and paradigm future programmers. It can be done strictly enforcing a set of rules (syntax) regarding the declaration f variables, program structure, and flow of control. ELEMENTS OF THE PROGRAM • Smallest parts of the program that have separated and identifiable meaning. 4 Classes of Elements Reserved Words, Identifiers, Constants, Symbols PROGRAM STRUCTURE Headings – the 1st statement in program that consists of a reserved word program then followed by the program name. Declarations – consists usually with the list of variables Variables – are memory location (address) which can assign a specific name. (e.g., Sum, Area, Num) Constants – assigned values that we specify to a particular name. (e.g., Num = 10) Labels – used to mark points in some part of the program. BASIC DATA TYPES OF PASCAL Integer – a whole number (+ or -) or decimal number Character – a single letter, special symbol or digits that are enclosed within a ‘’ (e.g., ‘a’, ‘Z’, ‘7’) Strings – a sequence of 2 or more special characters that are enclosed within a ‘’ (e.g., ‘tite’) WriteIn – basic output statements of pascal write –used with the gotoxy() standard function to center the message or specify the location where the message should be displayed on the screen. Readln, read & readkey - basic input statements Read –used with the gotoxy() function Readykey – used to read a character from the keyboard without echoing a response/display on the screen 3 MAIN OPERATIONS Input – we enter the needed data Process – data we entered is being computed, evaluated, stored, or processed. Output – last part of the program. SYNTAX FUNCTIONS F9 – run Alt + F9 – compile F2 – file menu SHORTCUT KEYS JAVA PROGRAMMING • It was originally called Oak but then renamed it • • • • • • • • • • • as Java. It was developed by James Gosling at Sun Microsystems (later acquired by Oracle) in 1995 and later, more than 3 billion devices run Java. It was designed to be a portable, platformindependent language capable of running on various computer systems. Used for mobile app, desktop app, web app, application servers, games, database connection, etc. WHY USE JAVA? Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.) It is one of the most popular programming languages in the world. It has a large demand in the current job market. It is easy to learn and simple to use. It is open-source and free. It is secure, fast and powerful. It has a huge community support (tens of millions of developers). Java is an object-oriented language which gives a clear structure to programs and allows code to be reused, lowering development costs • As Java is close to C++ and C#, it makes it easy for programmers to switch to Java or vice versa APPLICATIONS CREATED BY JAVA • Desktop, Web, Mobile • Game Development • Embedded Systems Examples: Minecraft, Spotify, Citibank, Android OS JAVA DEVELOPMENT KIT The Java Development Kit (JDK) is a software development environment that provides the necessary tools, libraries, and resources for developing Java applications, applets, and components. It is produced and maintained by Oracle Corporation and is widely used by Java developers. VARIABLES & ARITHMENTIC OPERATIONS used to store data and arithmetic operations and perform mathematical calculations. JAVA VARIABLES - variables are declared with a specific data type, such as int, double, String, etc. Variables hold values that can be used and manipulated within a program. To declare a variable, you specify its data type followed by a variable name. e.g. int age; double price = 6.66; String name; ARITHMETIC OPERATIONS - Java supports various arithmetic operations for numerical data types, such as addition, subtraction, multiplication, and division. Addition (+), Subtraction (-), Multiplication (*), Division (/), Modulo (%), Increment (++), Decrement (-) INPUT AND OUTPUT OPERATIONS - In Java, input and output (I/O) operations are performed using the java.io package and the System class. INPUT OPERATIONS - Reading input in Java involves obtaining data from the user or from an external source. - The java.util.Scanner class is commonly used to read input from the console or a file. - To read input from the console, you can create an instance of the Scanner class and use its methods to read different types of input. - nextInt() method is used to read an integer from the console. Other methods like nextDouble(), nextLine(), etc., can be used to read different data types. OUTPUT OPERATIONS - Output in Java involves displaying data to the console or writing it to an external destination, such as a file. - println() or print() - To write output to a file, you can use classes like java.io.FileWriter or java.io.PrintWriter. By using input operations, you can read user input or data from external sources, while output operations allow you to display or write data to the console or a file.