Programming Language
114 items tagged with "programming-language"
Patterns23
Factory Method
Defines an interface for creating an object but lets subclasses decide which concrete class to instantiate, deferring instantiation to subclasses.
Abstract Factory
Provides an interface for creating families of related objects without specifying their concrete classes, ensuring products from one family are used together.
Builder
Separates the construction of a complex object from its representation so the same construction process can create different representations step by step.
Prototype
Creates new objects by cloning an existing instance (the prototype) rather than instantiating a class, useful when construction is costly or types are decided at runtime.
Singleton
Ensures a class has only one instance and provides a global point of access to it, used for shared resources like configuration, logging, or connection pools.
Lazy Initialization
Defers the creation or computation of an object until the first time it is actually needed, avoiding upfront cost for resources that may never be used.
Multiton
Generalizes Singleton to manage a fixed, keyed set of named instances, ensuring exactly one instance exists per key through a registry.
Registry
Provides a well-known central object where shared instances or services can be registered and looked up by key, giving a single point of access without scattered globals.
Adapter
Converts the interface of a class into another interface clients expect, letting classes that could not otherwise collaborate work together.
Bridge
Decouples an abstraction from its implementation so the two can vary independently, avoiding a combinatorial explosion of subclasses.
Composite
Composes objects into tree structures to represent part-whole hierarchies, letting clients treat individual objects and compositions uniformly.
Decorator
Attaches additional responsibilities to an object dynamically by wrapping it, providing a flexible alternative to subclassing for extending behavior.
Flyweight
Minimizes memory use by sharing as much data as possible between many similar objects, separating intrinsic shared state from extrinsic context-specific state.
Proxy
Provides a surrogate or placeholder for another object to control access to it, enabling lazy loading, access control, caching, or remote access.
Module
Encapsulates related code into a single self-contained unit with a controlled public interface and hidden private state, organizing code and avoiding global namespace pollution.
Marker Interface
Uses an empty interface to tag a class with metadata so other code can detect the capability at runtime via type checks, without adding any methods.
Mixin
Composes reusable units of behavior into a class without inheritance, letting unrelated classes share functionality by mixing in shared method sets.
Extension Object
Lets you add new interfaces and behavior to a class over time without changing it, by attaching extension objects that clients query for at runtime.
Private Class Data
Restricts accessor-write access to class attributes by isolating data in a separate object exposed read-only after construction, enforcing immutability and encapsulation.
Producer-Consumer
A concurrency pattern where producers place work on a shared bounded queue and consumers process it independently, decoupling rates and smoothing load.
Thread Pool
A concurrency pattern that reuses a fixed set of worker threads to execute many tasks, avoiding per-task thread creation cost and bounding concurrency.
Actor Model
A concurrency model where independent actors encapsulate state and communicate only by asynchronous messages, avoiding shared memory and locks.
Reactor
An event-handling pattern that demultiplexes I/O events on one or few threads and dispatches them synchronously to registered handlers, enabling scalable non-blocking servers.
Anti-Patterns23
Boolean Trap
Function parameters that take a bare boolean force readers to decode opaque true/false call sites, hiding intent and inviting wrong arguments.
Stringly Typed Code
Using strings to represent data that has real structure or a fixed set of values, discarding type safety and pushing errors to runtime.
Primitive Obsession
Modeling domain concepts with raw primitives like int and string instead of dedicated types, scattering validation and inviting invalid data.
Magic Numbers
Unexplained numeric literals embedded in code, hiding their meaning and duplicating values that must change together.
Magic Strings
Hardcoded string literals that act as keys, flags, or identifiers, with no central definition, inviting typos and silent failures.
Long Method
A single function that does too much and runs for hundreds of lines, mixing many concerns and resisting comprehension, testing, and reuse.
Long Parameter List
A function signature with too many parameters, making calls error-prone, hard to read, and a sign of poorly grouped or missing abstractions.
Data Clumps
The same group of fields or parameters traveling together everywhere, signaling a missing abstraction that should be a single object.
Feature Envy
A method that is more interested in another class's data than its own, repeatedly reaching into that class instead of letting it own the behavior.
Null Checking Everywhere
Defensive null checks scattered through the codebase to guard against nulls that could be designed away, cluttering logic and still missing cases.
Refused Bequest
A subclass that inherits methods or data it does not want or use, often overriding them to do nothing, signaling a wrong inheritance relationship.
Yo-Yo Problem
An inheritance hierarchy so deep that understanding behavior forces constant scrolling up and down between many classes to trace a single call.
Call Super
A framework requiring subclass overrides to call the parent method, a fragile contract that breaks silently whenever a developer forgets the call.
Temporal Coupling
Methods that must be called in a specific hidden order, where calling them out of sequence silently breaks state with no compiler protection.
Switch Statement Smell
Repeated switch or if-else chains branching on a type code, duplicated across the codebase, that should be replaced by polymorphism.
Poltergeist
A short-lived, do-nothing class that only passes data or calls to other objects, adding indirection and noise without real responsibility.
Sequential Coupling
A class designed so its methods must be invoked in a rigid sequence, with the ordering enforced only by convention rather than by the API itself.
Busy-Waiting (Spin-Waiting)
Repeatedly polling a condition in a tight loop instead of blocking, burning CPU cycles while waiting for an event that the scheduler could deliver for free.
Broken Double-Checked Locking
A lazy-initialization idiom that checks a field outside a lock, locks, then checks again — but without proper memory barriers it returns partially constructed objects.
Synchronous-Over-Async (sync-over-async)
Blocking a thread to wait on an asynchronous operation's result, combining the costs of both models and risking thread-pool starvation or deadlock.
Memory Leak
Allocating memory that is never released because references are unintentionally retained, so usage grows without bound until the process slows, thrashes, or crashes.
False Sharing
Independent variables that happen to live on the same CPU cache line, so updates by different cores invalidate each other's caches and silently destroy multicore performance.
Resource Leak
Acquiring file handles, sockets, connections, or threads without reliably releasing them, so a finite pool is exhausted and the application stops being able to do work.
Tutorials14
Migrating JavaScript to TypeScript
Gradually migrate a JavaScript codebase to TypeScript
Runtime Validation with Zod
Add runtime type validation to TypeScript using Zod
How to set up a Go project with modules and tests
Start a Go project with Go modules, structure packages, and write table-driven tests using the standard testing package.
How to set up a Rust project with Cargo and tests
Create a Rust project with Cargo, add dependencies from crates.io, and write unit and integration tests.
How to set up a Python project with Poetry and pytest
Create a reproducible Python project using Poetry for dependency management and pytest for testing.
How to set up a Java project with Maven and JUnit
Create a Java project with Maven, manage dependencies, and write unit tests with JUnit 5.
How to set up a .NET project with xUnit tests
Create a .NET solution with a class library and an xUnit test project using the dotnet CLI.
How to set up a Node and TypeScript project with Vitest
Create a TypeScript project on Node.js, configure the compiler, and write fast unit tests with Vitest.
How to set up a Kotlin project with Gradle and JUnit
Create a Kotlin project with the Gradle build tool, manage dependencies, and write tests with JUnit 5.
How to use concurrency in Go with goroutines and channels
Run concurrent work in Go using goroutines, coordinate with channels, and synchronize with WaitGroup and context.
How to write concurrent Rust with threads and channels
Use Rust's threads, channels, and shared-state primitives to write concurrent code that the compiler proves is data-race free.
How to write concurrent Python with asyncio
Use Python's asyncio to run I/O-bound work concurrently with coroutines, tasks, and gather, and know when to use threads instead.
How to use concurrency in Java with executors and virtual threads
Run concurrent tasks in Java using the ExecutorService, futures, and lightweight virtual threads for scalable I/O.
How to write asynchronous C# with async and await
Use C# async and await with Task to run I/O-bound work concurrently, avoid blocking, and handle cancellation.
Blueprints5
Python 2 to Python 3 Modernization Blueprint
Migrate end-of-life Python 2 codebases to Python 3 with automated 2to3 fixes, string/bytes correctness, and dependency upgrades.
Java to Kotlin Backend Adoption Blueprint
Incrementally adopt Kotlin in a Java backend using full interop, null-safety gains, and coroutines for concurrent code.
Java 8 to Java 21 LTS Modernization Blueprint
Upgrade long-lived Java 8 applications to the Java 21 LTS runtime, adopting modern language features and resolving JDK module and API changes.
Native Mobile to Kotlin Multiplatform Blueprint
Share business logic across iOS and Android with Kotlin Multiplatform while keeping native SwiftUI and Compose UIs.
Objective-C to Swift Blueprint
Incrementally migrate a legacy Objective-C iOS app to Swift using mixed-target interop, file by file.
Products3
Playbooks4
Python 2 to 3 Program Playbook
A coordinated program for migrating remaining Python 2 codebases to modern Python 3 with type hints and a hardened test suite.
Java 8 to 17 Runtime Modernization Program Playbook
A fleet program to upgrade Java services from Java 8 to a modern LTS runtime with build, module, and dependency modernization.
iOS Objective-C to Swift Program Playbook
A program for migrating a legacy Objective-C iOS app to Swift incrementally using interoperability, file by file, while keeping the app shippable.
Android Java to Kotlin Program Playbook
A program for migrating a legacy Java Android app to Kotlin incrementally, leveraging interop and moving toward Jetpack Compose.
Checklists6
Java Framework Upgrade Pre-Flight Checklist
Pre-flight checks for upgrading a Java application's runtime and framework, such as Java 8 to 17 or Spring Boot 2 to 3.
.NET Framework to .NET Upgrade Checklist
Plan a migration from .NET Framework to modern .NET, covering API gaps, project format, dependencies, and hosting changes.
Python 2 to 3 Migration Checklist
Step-by-step checks for migrating a legacy Python 2 codebase to Python 3, covering syntax, encoding, and dependency changes.
Ruby on Rails Upgrade Pre-Flight Checklist
Pre-flight checks for upgrading a Ruby on Rails application across major versions, such as Rails 6 to 7.
PHP Version Upgrade Checklist
Checks for upgrading a PHP application across major versions, such as PHP 7 to 8, including framework and extension compatibility.
TypeScript Adoption Readiness Checklist
Verify tooling, configuration, and an incremental strategy are in place before adopting TypeScript in a JavaScript codebase.
Comparisons18
Go vs Rust
Two modern systems-oriented languages: Go optimizes for simplicity and fast development, Rust for memory safety without a garbage collector and maximum control.
Go vs Java
Go offers a lean runtime and fast startup for cloud services, while Java brings a mature ecosystem, the JVM, and decades of enterprise tooling.
Rust vs C++
Both target systems-level performance, but Rust enforces memory safety at compile time while C++ offers unmatched maturity and ecosystem at the cost of manual safety.
Python vs Go
Python prioritizes expressiveness and a vast data/AI ecosystem, while Go prioritizes raw performance, concurrency, and lean deployment for services.
Node.js vs Python
Two leading backend runtimes: Node.js offers event-driven, non-blocking I/O with JavaScript everywhere, while Python brings readability and a vast data ecosystem.
Java vs Kotlin
Both run on the JVM and interoperate fully, but Kotlin offers more concise, modern syntax and null safety while Java offers ubiquity and the longest track record.
Java vs C#
Two mature, statically typed languages with managed runtimes: Java on the JVM with broad portability, C# on .NET with strong language features and tooling.
Kotlin vs Scala
Two modern JVM languages: Kotlin emphasizes pragmatism and approachability, while Scala offers deeper functional programming power and a more expressive type system.
TypeScript vs Flow
Two static type systems for JavaScript: TypeScript is the de facto standard with a vast ecosystem, while Flow is a lighter type checker from Meta with declining adoption.
Python vs R
Two leading languages for data work: Python is a general-purpose language strong across the data and ML pipeline, while R is purpose-built for statistics and visualization.
Swift vs Kotlin
The leading native mobile languages: Swift for Apple platforms and Kotlin for Android, both modern, safe, and increasingly used for cross-platform development.
PHP vs Node.js
Two popular web backends: PHP powers a huge share of the web with mature frameworks, while Node.js offers event-driven JavaScript across the full stack.
Ruby vs Python
Two expressive, dynamic languages: Ruby is beloved for web development with Rails, while Python dominates data, ML, and general-purpose scripting.
V8 vs JavaScriptCore
Two major JavaScript engines: Google's V8, powering Chrome and Node.js, and Apple's JavaScriptCore, powering Safari and Bun. Different design and tuning priorities.
CPython vs PyPy
Two Python implementations: CPython is the reference interpreter with full compatibility, while PyPy uses a JIT compiler for major speedups on long-running code.
Rust vs Go for CLI Tools
Both produce single static binaries ideal for command-line tools: Go favors fast builds and simplicity, Rust favors performance, rich CLI libraries, and safety.
C vs Rust for Systems Programming
C is the foundational systems language behind operating systems and embedded software, while Rust offers comparable control with compiler-enforced memory safety.
Kotlin vs Java for Android
Kotlin is Google's preferred, modern language for Android; Java is the original, ubiquitous JVM language with the largest legacy footprint.
Benchmarks4
SPECjvm 2008
Benchmark suite measuring core Java Virtual Machine performance across compute-intensive workloads independent of application or hardware tuning.
Computer Language Benchmarks Game
Long-running comparison of programming-language implementations on small algorithmic tasks, measuring runtime, memory, and code size.
Renaissance JVM Benchmark Suite
Modern JVM benchmark suite using real-world concurrent and parallel workloads to stress runtime optimization, GC, and JIT compilers.
DaCapo JVM Benchmark Suite
Long-established Java benchmark suite using real open-source application workloads to evaluate JVM, JIT, and garbage-collection performance.
FAQs3
What is the difference between compiled and interpreted languages?
A compiled language is translated ahead of time into machine code by a compiler, producing a standalone executable that the CPU runs directly—language...
What is type safety?
Type safety is the degree to which a programming language prevents type errors—operations applied to values of the wrong type, like adding a number to...
What is the difference between imperative and declarative programming?
Imperative programming describes how to achieve a result through explicit step-by-step instructions that change program state, as in a typical for-loo...
Glossaries11
Concurrency
Concurrency is the ability of a system to make progress on multiple tasks during overlapping time periods, structuring work so tasks can be interleaved, regardless of whether they execute simultaneously.
Parallelism
Parallelism is the simultaneous execution of multiple computations, typically across several CPU cores or machines, to complete work faster than sequential execution.
Immutability
Immutability is the property of data that cannot be changed after it is created; modifications produce new values instead of altering the original, which simplifies reasoning and concurrency.
Pure Function
A pure function always returns the same output for the same input and has no side effects, meaning it does not read or modify any state outside its own arguments.
Garbage Collection
Garbage collection is automatic memory management in which a runtime reclaims memory occupied by objects that are no longer reachable by the program, freeing developers from manual deallocation.
Memory Safety
Memory safety is the property of a program that prevents invalid memory access such as buffer overflows, use-after-free, and null pointer dereferences, eliminating a major source of bugs and security vulnerabilities.
Type System
A type system is a set of rules in a programming language that assigns types to values and expressions and governs how they may be combined, catching certain classes of errors before or during execution.
Static Typing
Static typing is a language approach in which the types of variables and expressions are known and checked at compile time, before the program runs, catching type errors early.
Dynamic Typing
Dynamic typing is a language approach in which variable types are checked at run time rather than compile time, allowing variables to hold values of any type and offering flexibility at the cost of later error detection.
Compilation
Compilation is the process of translating source code written in a programming language into a lower-level form, such as machine code or bytecode, that a machine or runtime can execute.
Interpretation
Interpretation is the execution of a program by directly reading and running its source code or an intermediate representation, statement by statement, without first compiling it to native machine code.