Techletter #58 | February 04, 2024
What is the difference between weakly, strongly, and statically typed programming languages?
- Weak typing: Allows more flexibility with data types. Variables don’t necessarily need explicit type declarations, and the language may implicitly convert between types at runtime. This can offer quicker development but may lead to unexpected behavior if types are misused. Examples: JavaScript, Python, PHP.
- Strong typing: Enforces strict rules on data types. Variables must be declared with a specific type, and operations are only allowed between compatible types. This catches many errors at compile time, leading to more reliable and predictable code. Examples: Typescript, Java, C#, C++.
- Static typing: Determines data types at compile time. The compiler analyzes the code and verifies type compatibility before the program runs. This ensures errors are caught early, promoting robustness and maintainability. Examples: Java, C#, C++.
What are shapes in typescript?
Shapes tell us more about the structural features of a type: types and names of properties of an object, types and names of parameters of a function, and types and indexes of elements in an array.
Taken an object
const Person = {
id: 1802,
name: 'Prajwal Haniya',
lang: 'typescript',
editor: 'vscode'
}
The shape of the above object will be
type Person = {
id: number,
name: string,
lang: string,
editor: string
}
How to change the origin of a local repository?
View the remote origin URLs
git remote -v
Imagine you already have a repository linked to bitbucket/ gitlab/ GitHub then you set the origin URL using the below command
git remote set-url origin REPO_ORIGIN
System Design: A brief overview
System design refers to defining, developing, and implementing systems that meet certain requirements. It involves requirements gathering, design, development, testing, deployment, and maintenance.
Functional vs Non-functional requirements
Functional requirements are the requirements that describe the specific features and functions that a system must have to meet its goals. It is related to the tasks that a system is designed to perform.
Non-functional requirements are the ones that describe how the system should perform.
Suppose a company is building an app for e-commerce then the functional & non-functional requirements are as follows:
Functional Requirements
- The ability to browse products by category
- The ability to add products to a shopping cart
- The ability to process payments
Non functional requirements
- Response time: the app must load within 3 seconds
- Scalability: the app must be able to handle 10,000 simultaneous users
- Usability: must be easy to use for people across all levels.
High-level design vs Low-level design
High-level design is the process of defining a system’s overall structure and organization. It focuses on systems functionality, performance & scalability.
Low-level design is the process of specifying the details of how individual components of a system will be implemented. It focuses on systems reliability, testability, and maintainability.
Common components of a distributed system
Nodes: Nodes are the individual computers or servers that make up a distributed system.
Networks: is the infrastructure that connects the node that is LAN (Local Area Network) or WAN (Wide Area Network)
Middleware: A software that sits between the application and operating system providing features like message passing, remote procedure calls, and distributed file systems.
Protocols: rules for communicating between nodes. Examples: HTTP, TCP, & UDP.
Load balancers: help in distributing the incoming traffic.
Distributed Databases: are databases that spread across multiple nodes.
Security Mechanisms: help in protecting data and prevent unauthorized access.
CAP Theorem (Brewer’s Theorem)
The CAP theorem states that it is impossible for a distributed system to simultaneously provide all three that is consistency, availability, and partition tolerance.
Consistency
Consistency is the idea that every read from the system returns the most recent write or an error. Ensuring consistency requires that all nodes in the system have access to the same data and that any changes to the data are propagated to all the nodes in a timely manner.
Availability
Availability is the idea that every requests will receive a response without guarantee that it contains the most recent version of the information.
Partition Tolerance
Partition tolerance is the idea that system continues to operate even when network partition occur. In a distributed system network partition occur when communication between two nodes is disrupted or a network link is broken.