Async/await II - Different ways of using aysnc/await

In async programming, there are several different approaches to handling asynchronous tasks beyond just immediate awaiting. Each approach is suited for different use cases depending on whether you need to wait for results, execute tasks in parallel, or handle exceptions.

May 4, 2025 · 4 min · Hongzhu Cui

Async/await I - Brief history of async/await

The async/await pattern was introduced to simplify asynchronous programming by making asynchronous code look and behave more like synchronous code. Here’s how it evolved across different programming languages.

May 3, 2025 · 3 min · Hongzhu Cui

Functional programming in Python, Java, C#

Functional programming (FP) is a paradigm that emphasizes immutability, pure functions, and higher-order functions. While Python, Java, and C# are all multi-paradigm languages (supporting both object-oriented and functional programming), they each have different levels of FP support. Here’s a comparison: 1. First-Class Functions All three languages support first-class functions, meaning functions can be assigned to variables, passed as arguments, and returned from other functions. Python: Full support for first-class functions using lambda, map(), filter(), reduce(), and list comprehensions. Java: Added functional support in Java 8 with lambda expressions and the Stream API. C#: Supports functional programming via delegates, lambda expressions, and LINQ (Language Integrated Query). 2. Higher-Order Functions A function is considered higher-order if it takes another function as an argument or returns one. ...

October 28, 2024 · 3 min · Hongzhu Cui

Python interface and protocol

Python isn’t like Java or C# where they have explicit interface keywords. So, how do interfaces work in Python? Traditionally, Python uses a different approach. Instead of explicit interfaces, it relies on duck typing. That means if an object behaves like a duck (has the necessary methods), it’s treated as a duck, regardless of its type. Duck Typing Python relies on duck typing: If an object behaves like a duck (i.e., has the required methods/properties), it is treated as a duck. No formal interface declaration is needed. ...

August 22, 2024 · 3 min · Hongzhu Cui

Async/await under the hood

Comparison of await Implementation in C# and Python.

September 23, 2023 · 3 min · Hongzhu Cui