A Love Letter to Flashcards
A personal reflection on how spaced repetition and hand crafted flashcards helps me to keep understanding alive
Lesley Lai's blog only feed
A personal reflection on how spaced repetition and hand crafted flashcards helps me to keep understanding alive
This post talks about the many different aspects under the umbrella term OOP
A walkthrough of how I migrated my blog's comment system from the Commento cloud service to self-hosting with Comentario, Commento's active fork. I share my experience setting up Comentario with Docker, configuring a reverse proxy with Caddy, and customizing its client-side CSS. This post also includes reflections on the learning curve of self-hosting and notes on future plans to move away from…
This post talks about me completely rebuilding this website, moving from Gatsby.js to Astro due to build issues and Gatsby's decline.
This post explores various ways to implement an abstract syntax tree (AST) in C++. In particular, it focuses on representing "variant" structures that can hold values from a fixed set of alternatives.
In this post, I share a curated list of online courses that I found both enjoyable and insightful.
This post offers a practical tip for naming variables and functions: use 'from' instead of 'to' to make code more intuitive and readable.
A cathartic post on what happened to Lesley as of 2023. It includes why I left college, what kept me from returning, and what my life has been like since.
This post explains Rust's ManuallyDrop construct, and how it helps control the order of destructor calls.
Today is the nth time I got bitten by CMAKE_SOURCE_DIR, so I will write it here. In short, there are two predefined variables in CMake: CMAKE_SOURCE_DIR and PROJECT_SOURCE_DIR. CMAKE_SOURCE_DIR refers to the top-level source directory that contains a CMakeLists.txt, while PROJECT_SOURCE_DIR refers t..
This tutorial shows how to use the VK_KHR_dynamic_rendering extension in Vulkan. It shows the steps required to load the extension, use it, and how it affects related components such as pipeline creation
This post explains how I implemented the bilingual functionality of this blog in plain Typescript.
This blog post explains C++ standard library's std::align utility, using an arena allocator as a motivating example
This year is my first year doing the Advent of Code challenge, and today (2021 Day 7)‘s challenge is a fun one. I won’t go to the details, but the problem involves finding the minimum for a function. The function takes an integer and returns another integer. An interesting property of that function..
Since the advent of C++14, we can create lambda expressions that take auto parameters. And in C++20, we can even do the same thing for regular functions. With this feature’s advent, the programming style where all parameters are auto becomes popular among some C++ programmers. However, the feature i..
I am doing some peer programming for a university course project today. In our codebase, we have a Ship class like the following: Later, the new requirement of the course project requires us to add another field, what we called captainsQuertersHealth, to the class, so we made the following change..
Yesterday, someone in the #include discord server asked the following question: > how std::function works with lambda captures and functions handling I still don’t understand Below was my answer to the question, with some typo-fixes and expansions: INVOCABLES CAN HAVE DIFFERENT TYPES EVEN I..
This post offers practical tips and curated resources for learning C++, tailored to different backgrounds and experience levels.
Today I stumble upon an article These Modern Programming Languages Will Make You Suffer after Twitter outrage. The post is absurd and indeed a suffer to read for me. However, it also receives 1k+ medium claps at the time of writing, and I cannot stay silent. In essence, this article tries to promot..
This post talks about the issue of slow link time in Rust and how to improve it by switching the default linker to lld - the LLVM linker.
Recursive module is an interesting feature in OCaml. To use it, we need to use the form Explicit signature is required when using recursive modules, as the compiler can no longer deduce the module signature with recursion. A typical recursive module looks like the following: And we can even h..
Passing complex mutable lambdas to C++ STL algorithms often leads to code that's hard to read and maintain. This article argues against treating 'no raw-loop' as dogma, and explores how using mutable lambdas undermine the benefits of . It also provides detailed case study on LeetCode's Two Sum and a predicate-based inner product.
In the conventional wisdom of the C++ community, non-static const or reference data variables are considered problematic. Surprisingly, I cannot find a single resource dedicated to this topic. I decide to write this post because the same problem raises several time by different people on Twitter an..
It is easy to make mistakes when conducting mathematical proofs. Nevertheless, you can find some recurring error patterns in those proofs. And some of the most common reasons are related to the innocuous-looking number zero. DIVISION-BY-ZERO FUN Let’s look at the following “proof” of : What is w..
Would spamming the noexcept keyword make your C++ code faster? Sometimes. But not always. This post talks about the suprising downside when adding noexcept to functions.
What are the statics of a programming language? Most programming languages exhibit a phase distinction between static and dynamic phase of processing. People sometime loosey say static of a language happened at “compile-time,” and dynamic of a language occurred at “run-time.” The static phase of a l..
From a layperson’s perspective, the field of programming language research is full of jargon, greek letters, and weird symbols. On the one hand, Those common parlances make the programming language papers concise. On the other hand, you need not only mathematical maturity but also domain knowledge t..
The const type qualifier is one of the jewels of the C++ language design. Surrounding by this feature, we devise the “const correctness” practice to prevent const objects from getting mutated. The const correctness rule is straight-forward to follow for implementation of the most classes, but it is ..
At CppCon 2019, I gave a lightning talk at called Make Impossible State Unrepresentable. Due to the nature of a 5 minutes lightning talk, it was handwavy, and I cut a lot of prepared contents to fit the time. This post is a deeper dive into the topic with more detailed explanations and examples. Th..
Update: Apparently there is a WG21 paper on this subject that goes in much more detailed than my post. I am surprised that I missed his CppCon talk on this topic and come into the silimar conclusion. One principle of C++ operator overloading is that the behavior of overloaded operators should be si..
What a week we had! CppCon 2019 is by far the best CppCon that I’ve ever attended. There are contents that interest me on every time slot, and for a lot of time there are conflict so that it is hard to decide which talk to go to. PRE AND POST-CONFERENCE CLASSES * Arthur O’Dwyer’s Standard Librar..
This year, several of the coworkers and I at Trimble SketchUp attended ACM Special Interest Group in Graphics (Siggraph) conference. It is my first time attending such a big gathering. The week is exciting, exhaustion, and also extremely rewarding for me. This year the conference location is Los ..
During the last meeting of the North Denver C++ Meetup, some people mentioned that lea is more confusing than other instructions. lea is an acronym for “load effective address.” The usual explanation is “to put a memory address from the source into the destination.” The syntax of lea in the Intel Sy..
A lot of operations of C++ require temporary values. Using them before their destruction is imperative. However, not all C++ programmers I met have a solid understanding of when a temporary expire. This situation often leads to over-conservative estimations, which will not cause any harm. Neverthele..
C++ lambda expression is a construct added to C++ back in C++11, and it continues to evolve in each version of the C++ standard. A core part of the language nowadays, lambda expressions enable programmers to express anonymous functions and closures in C++. This post describes what a lambda expressio..
Functional Programming in C++ by Ivan Čukić is a new book about applying functional programming principles in C++. This book is for people who already have a decent understanding of C++. It is written in an idiomatic style that a C++ programmer should feel welcome. If you just start to learn C++,..
Tail-recursion is an important concept to understand before we can analyse the behavior of a functional program. I will try to illustrate what tail recursion is with an Elm-like pseudocode. Though you don’t need to know any Elm to understand this post. FROM RECURSION TO TAIL-RECURSION Consider th..
CMake is the de facto industry standard for the build system generator of the C and C++ this days. Like C++, people seem to love and hate it at the same time. However, it is definitely a better choice compare to writting Makefiles manually. There are a bunch of Cmake resources online, in the forms ..
Recently, I have encountered a legacy code base at work. There are several tremendous class written like this: The real class is much bigger. We can criticize this snippet in multiple ways. For example, the copy-operations will do shallow copy, which is counter-intuitive. And programmers of the d..
Automatic tests are ubiquitous in software industry these days. Especially to large-scale software, it is necessary to have a set of test to ensure the specification is fulfilled and to prevent regression bugs. In this post, I will not bore you with why we do test. Instead, if you are using the CMak..