Skip to content

Instantly share code, notes, and snippets.

@KeshariPiyush24
Last active January 23, 2025 17:56
Show Gist options
  • Save KeshariPiyush24/4c19402d4e4295964c5d1f6ae554effb to your computer and use it in GitHub Desktop.
Save KeshariPiyush24/4c19402d4e4295964c5d1f6ae554effb to your computer and use it in GitHub Desktop.
SMALLEST INFORMATION UNIT:
1 NIBBLE = 4 BITS
1 BYTE = 8 BITS
1 KILOBYTE (KB) = 8 KILOBITS = 1,024 BYTES = 2¹⁰ BYTES
1 MEGABYTE (MB) = 8 MEGABITS = 1,048,576 BYTES = 2²⁰ BYTES
1 GIGABYTE (GB) = 8 GIGABITS = 1,073,741,824 BYTES = 2³⁰ BYTES
1 TERABYTE (TB) = 8 TERABITS = 1,099,511,627,776 BYTES = 2⁴⁰ BYTES
1 PETABYTE (PB) = 8 PETABITS = 1,125,899,906,842,624 BYTES = 2⁵⁰ BYTES
Programming Languages Levels:
- Binary (Pure machine level/low level)
- 10 + 10 = 100 (Hectic to work with, very difficult for humans to understand)
- Assembly (MOV, ADD, SUB, COM, INC, CARRY) - ADD 5 R2 - .asm (extension file is assembly source code file)
- HLL (High Level Langauge) - C++, Java, COBOL, PYthon, Javascript,
- AI - Artifical Intelligence LIke ChatGPT etc
Any PL instruction has two parts (state/data + behaviour/fuctions) - Add two numbers 5 and 4
To store data we make use of variables - State
To perform any operation we define functions - Behaviour
Types of Data Types:
Character
String
Boolean
Short
Integer
Long Long Integer
Double
Float
Date
User Defined Data types: Hybrid of primitive data types: array, linkedlist, class, object
Here's a comprehensive explanation of typing systems in programming languages:
**Strong vs Weak Typing**
- Strong Typing: Type constraints are strictly enforced. No **implicit** type conversion.
Example (Python): `"123" + 456` raises TypeError
- Weak Typing: Allows implicit type conversion between unrelated types.
Example (JavaScript): `"123" + 456` returns "123456"
**Static vs Dynamic Typing**
- Static Typing: Variable types are checked at compile time. Types must be declared.
Example (Java): `String name = "John";`
- Dynamic Typing: Variable types are checked at runtime. Types can change.
Example (Python): `x = "hello"; x = 42` is valid
Strong and Statically Typed PL, are genrally faster than weak and dynamically typed PL.
JAVA -> Strong and Statically Typed
Python -> Strong and Dynamically Typed
JS -> Weak and Dyanamically typed
**Language Examples**
Java (Strong & Static):
```java
String text = "123";
int num = text; // Compile error
int num = Integer.parseInt(text); // Correct way
```
Python (Strong & Dynamic):
```python
x = "123"
y = x + 456 # TypeError
y = int(x) + 456 # Valid: 579
```
JavaScript (Weak & Dynamic):
```javascript
let x = "123"
let y = x + 456 // "123456"
let z = x - 456 // -333 (converts string to number)
```
Complied PL vs Interpreted PL
JAVA - Complied
Python (RE) - Interpreted
PYPY (RE) - Compiled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment