Interpreted and Compiled Programming Languages with Basics
Programming Languages
It helps us tell computers what to do. Computer language is called machine code. Machines understand 1|0. There are 2 types of programing languages. Interpreted(scripted) and compiles.
Interpreted Languages
Interpreted languages like Python and HTML operated through the interpreter on your computer or browser.
Examples :
- Javascript : simpler scripting language that runs through web browser interpreter
- Python : popular because it is easy to learn and use
- Lua : General purpose game scripting language, easy to learn and use
- HTML : markup language used for formating web pages
Compiled Languages
Its more like an app, you runs on your computer. It is packages or compiled to one executable file. They are usually larger programs. Used to solve more challenging problems like interpreting source code.
Examples :
- C,C++,C# used in many operating system creation like windows, apple
- Java : works well across platforms like android
Interpreted VS Compiled
Query and Assembly programming languages
High Level programming languages
- More sophisticated
- Use common English
- Includes Query languages(SQL), structured programming languages(Pascal), OOP (python)
Low level languages
- use simple symbols to represent machine code(0|1)
- Includes Assembly languages (ARM, MIPS, X86)
- Closely tied to CPU architecture
SQL VS NoSQL(Not only SQL)
Key difference is data structures.
SQL : Relational, Use structured predifined schemas
NoSQL : Non relational dynamic schemas for unstructured data
Query language is used to :
- Request data from db
- Create, Read, Update and Delete data in db (CRUD operations)
- DB consist of structured tables with multiple rows and columns of data.
- when user performs a queary, DB retrieves data from the table and arrange data into some sort of order. Return and present the query results.
Assembly languages
- Simple readable format
- Enter one line at a time
- One statement per line
- Assembly languages are translated using as assembler instead of compiler or interpreter
- One statement translated into just one machine code instruction
- Assembler translate assembly language to machine code using mnemonics. Input(INP), Output(OUT), Load(LDA)
- Statements consist of opcodes that tell CVPU what to do with data and Operands that tell CPU where to find the data
Understand Code Organization methods
This is important to have readability, maintainability and configuring. Planing and organizing software design enables writing cleaner more reliable code, helps improve code base and reduces bugs and errors through out the life span of project. Provide consistent and logical format while coding.
We can do this by
Pseudocode : Informal, High-level algorithm description. Step-by-step sequence of solving problem. Helps to share ideas. This not depend on programming language. Better for larger problems
Flowchart : Pictorial representation of algo, displays steps as boxes and arrows. Can used in designing or documenting a process or program. Better for smaller problems examples: MS Visio, Lucidchart, Draw.io, DrawAnywhere
Lets see hello world in different languages
// C Programming
#include <stdio.h>
int main(void) {
printf("Hello World!\n");
return 0;
}
/*
compile : gcc -o hello helloworld.c
run : ./hello
*/
// JavaProgramming
public class helloworld{
public static void main(String s[]){
System.out.println("Hello world")
}
}
/*
compile : javac helloworld.java
run : java helloworld
*/
// Python
print("Hello World!")
"""
run : python3 helloworld.py
"""
// Node js
console.log("Hello World!");
/*
run : node helloworld.js
*/
// Go language
package main
import "fmt"
func main() {
fmt.Println("Hello World!")
}
/*
run : go run helloworld.go
*/
# Ruby
puts "Hello World!";
# run : ruby helloworld.rb
// PHP
<?php
Print "Hello, World!\n";
?>
/*
run : php helloworld.php
*/
// C++
#include <iostream>
int main() {
std::cout << "Hello World!\n";
return 0;
}
/*
compile : g++ -o helloworld_cpp helloworld.cpp
run : ./helloworld_cpp
*/
# Perl
print("Hello World\n");
# run : perl helloworld.pl
# Shell scripting
echo "Hello World!"
# run : sh helloworld.sh
<!-- HTML -->
<html>
Hello World!
</html>
<!--
run : By double click the file it will open in your browser
-->
Looping and Branching
Programming Concepts (Identifiers and Containers)
Identifiers : Use to reference program components such as stored values, methods, Interfaces, Classes by assigning custom label to it. Identifier can a constant or variable only.
Constants
- Constants easier to read in code
- Change the constant value once to change all instances in the code
Variables
- Data value can be changed
- Declare and assign data type and intial value to variable upon definition
Containers : Special type of identifier to reference multiple program elements. Containers can be either Array or Vector
Array : Fixed number of elements stored in sequential order, starting at zero(Fixed size). When declaire arry you need to specify what type of data you are going to put(int, float, string)
Vector : Dynamic size. Automatically resize as elements added or removed. Take more memory space than arrays. Take longer to access as not stored in sequential memory.
Programming Concepts (Functions and Objects)
Functions(subroutines, procedures, methods, modules) : With consequences of modular software development we restrict to one code block perform one task. So function is structured, stand-alone, reusable code that performs a single specific action. This helps to divide complex program into smaller pieces that is more manageable.
Objects : OOP is a programing methodology focused on objects rather than functions. (Procedure programming focused on functions). Objects contains data in the form of properties(attributes) and code in form of procedures(methods). OOP packages methods with data structures. Object operate on their own data structures.Objects in programming consists of states(properties) and behaviours(methods). Store properties in fields(variables). Expose their behaviors through methods(functions)
Thanks for the resources : IBM Introduction to Software Engineering 🤓