Top 5 things to know before learning a programming language

Chamuditha Kekulawala
5 min readOct 7, 2024

--

When learning a new programming language, there are several core concepts you need to understand that will shape how you write and structure your code. Let’s go through each of them:

1. Type System

Is it Statically or Dynamically Typed?

This defines how variable types are handled in a language.

  • Statically Typed Languages (ex: C, Java): The type of a variable is known at compile time. You need to explicitly declare the type of variables.
// Java
int age = 25; // You declare the type as 'int'
  • Dynamically Typed Languages (ex: Python, JavaScript): The type of a variable is determined at runtime, and you don’t need to declare the type.
# python
age = 25 # Python infers the type of 'age' as an integer
  • Type Inference: Some statically typed languages, like TypeScript or Kotlin, allow for type inference, meaning that while they are statically typed, the compiler can infer the types for you based on context.
// kotlin
val age = 25 // The compiler infers that 'age' is an Int

Is it Strongly or Weakly Typed?

This refers to how strictly types are enforced.

  • Strongly Typed (ex: Python, Java): Implicit type conversions (coercions) are not allowed.
  • Weakly Typed (e.g., JavaScript, PHP): Implicit conversions between types can happen, which can lead to unexpected behaviors.
// javascript
console.log(5 + '5'); // Outputs '55', due to string coercion

For advanced developers, it’s essential to understand how types influence program behavior and performance. For instance, in TypeScript, you can use Generics and Type Guards to ensure type safety and flexibility.

2. Memory Management

Does it have Manual or Automatic Memory Management?

  • Automatic (Garbage Collection): In languages like Python and Java, memory management is automatic. The system automatically reclaims unused memory via garbage collection.
# python
name = "John"
name = None # 'John' is garbage collected
  • Manual Memory Management: In languages like C or C++, you manually allocate and free memory using pointers.
// C
int* ptr = malloc(sizeof(int)); // Manually allocate memory
free(ptr); // Manually free memory

If you’re an advanced developer, you can look into how different languages implement garbage collection strategies, such as Mark-and-Sweep, Reference Counting, or Generational GC. Knowing these strategies can help optimize performance in memory-intensive applications.

For instance, Java uses Generational Garbage Collection, which divides the heap into young and old generations. Objects that survive multiple GC cycles are promoted to the old generation, making memory management more efficient.

3. Concurrency Model

Is it Single-threaded or Multi-threaded?

  • Single-threaded (ex: JavaScript): JavaScript runs on a single thread meaning it can only handle one task at a time, and uses an event loop to handle concurrency through asynchronous calls like async/await.
// javascript
async function fetchData() {
let response = await fetch('https://api.example.com/data');
let data = await response.json();
console.log(data);
}
  • Multi-threaded (ex: Java): Java natively supports multithreading, allowing you to run tasks concurrently in different threads.
// java
class MyThread extends Thread {
public void run() {
System.out.println("Thread is running");
}
}
MyThread t = new MyThread();
t.start(); // Start a new thread

Some languages support more sophisticated concurrency models. For example:

  • Goroutines in Go: These lightweight threads allow highly efficient concurrency.
// go
go func() {
fmt.Println("Hello from a Goroutine!")
}()
  • Actor Model: In languages like Erlang, the actor model isolates state in independent actors that communicate via message passing. This eliminates many concurrency issues like race conditions and deadlocks.
  • Asynchronous vs. Parallel Execution: While asynchronous execution (ex: JavaScript’s event loop) allows non-blocking I/O, parallel execution (multi-threading) allows tasks to run truly simultaneously on different CPU cores.

4. Compilation vs. Interpretation

Is it Compiled or Interpreted?

  • Compiled Languages (ex: C, Rust): The code is translated into machine code before execution. This typically results in faster performance but requires an explicit compilation step.
  • Interpreted Languages (ex: Python, Ruby): Code is executed line-by-line by an interpreter, which can make development faster but often results in slower execution speed.
  • Just-in-Time (JIT) Compilation: Some languages, like Java and JavaScript (via V8), use JIT compilation, which combines both compilation and interpretation. This allows frequently used code paths to be optimized at runtime, improving performance.
  • Ahead-of-Time (AOT) Compilation: Some languages like Rust and C++ use AOT compilation, which compiles the code directly to machine code without further runtime compilation, providing deterministic performance.

For senior developers, understanding these performance trade-offs is crucial when deciding which language or platform is suitable for performance-critical applications.

5. Syntax and Programming Paradigms

Syntax

Every language has its own syntax. For example, Python emphasizes simplicity with its whitespace rules, while Java uses explicit curly braces {} for code blocks.

# Python uses indentation
if age > 18:
print("Adult")
// Java uses curly braces
if (age > 18) {
System.out.println("Adult");
}

Programming Paradigms

  • Imperative Programming: Focuses on how to perform tasks step by step (ex: C, Python).
  • Object-Oriented Programming (OOP): Organizes code into objects (ex: Java, C++).
  • Functional Programming: Emphasizes pure functions and immutability (ex: Haskell, Scala).

Multi-paradigm Languages: Some languages like Python, JavaScript, and Scala support multiple paradigms (OOP, functional, imperative). Understanding when and how to use different paradigms can make code more efficient and maintainable.

For senior developers, functional programming features such as first-class functions, higher-order functions, closures, and lambda expressions can significantly enhance how problems are solved.

Some other questions to ask:

6. Standard Library and Ecosystem

  • Does the language have a robust set of built-in libraries for common tasks?
  • What package manager is used to handle dependencies (ex: npm for JavaScript, pip for Python)?
  • Is the language Cross-platform compatible — Can it run on multiple platforms (Linux, Windows, macOS)?
  • How active is the developer community, and how mature is the language’s ecosystem?

7. Error Handling

  • How are errors handled? Does it use exceptions, error codes, or another mechanism (ex: Result types in Rust)?
  • How does the language handle errors in asynchronous code (if supported)?

Whether you’re just starting or are an experienced developer looking to deepen your knowledge, mastering these concepts will help you become more versatile and effective in any language you choose to learn.

--

--

Chamuditha Kekulawala

Full-stack development | Machine Learning | Computer Architecture