Below you will find pages that utilize the taxonomy term “programming”
December 7, 2023
My thoughts on AI in 2023
OpenAI took the world by storm in 2023 with ChatGPT. I was blown away by its remarkably humanlike and compelling responses. Other companies quickly followed suit, introducing their own competitors to ChatGPT. In this update, I want to share my thoughts on these products and what the future looks like.
What is a generative AI model?
When I use the term “generative AI”, I am referring to a computer program which can generate text, image, sound, or other types of contents.
February 11, 2023
Use GPT-3 To Build A Code Translator
Once you know a programming language well, the process for learning a new language is not very hard. It is just time consuming. You need to read the documentation for basic syntax and flow control, get familiar with its idioms, memorize core parts of the standard libraries, and learn its tool chains. What can we do to speed up the learning process? One thing we can do is provide great examples in the documentation.
January 2, 2023
OpenAI and ChatGPT
I had two weeks off at the end of 2022. Telesign closed its operations on the last week of 2022 to give employees well-deserved time off for a year of hardwork and I took another week off in addition to that. Like many technologists, I became captivated by OpenAI’s release of ChatGPT in 2022, and I spent a lot of the last two weeks exploring what OpenAI has to offer.
May 3, 2021
Unit Tests vs Integration Tests
I used to favor automated integration testing. Now, I find myself walking away from it. I no longer find it worth the cost of setting up and maintaining such tests. I now rely mostly on unit testing.
First, I need to define what I meant by those terms. In context of this post, unit tests
In Wikipedia
unit test integration test automated, not always not specified ranging from entire ‘module’ to an individual function modules tested as a group depends on execution conditions and testing procedures depends on unit test/implies modules are already unit tested From Martin Fowler
October 16, 2020
Dell XPS-13 - Developer Edition
This Feburary, I ordered a Dell XPS-13 Developer Edition. The Developer Edition is a line of Dell laptops that ships with certified Linux OS. It has been my programming powerhouse for the last eight months.
My first choice for a laptop was not Linux. Windows and macOS are simply more practical. Games and MS Office just works on Windows. Software support on macOS is generally good (except games), but it beats Windows with its underlying BSD architecture.
October 9, 2020
Dynamic Programming Languages
I loathe dynamic programming languages. This week, in a system that spans 3 microservices, I needed to add two new fields to an object. I’ve spent at least two days tracking down references to said object and making notes on all the functions that may be affected by this change. I wish I had a compiler to validate type information at function boundaries. But I don’t, because the microservices are written in weakly-typed (aka dynamic) languages.
Pages
Vocabulary
bind Sometimes a synonym for “map” conflate combine disjoint separate, e.g., odd numbers and even numbers are disjoint disjunction inclusive or – if one of the inputs is True extrinsic not intrinsic federated Top-down delegation of responsibilities; Has a single point of failure at the top. PID controller control loop feedback mechanism e.g., curise control 99%ile Abbreviation of percentile EBNF Extended Backus-Naur Form Useful for defining the syntax of a programming language EBNF terminal a token/word/chunk in EBNF Alpha Αα Beta Ββ Gamma Γγ Delta Δδ Commonly denotes ‘difference’ Epsilon Εε Used in Greedy-Epsilon algo for multi-armed bandit problems Error margin in floating point comparisons.
August 1, 2020
Go io/fs Design (Part I)
As usual, LWN has a good write up on what’s going on in the Go community. This week’s discussion in on the new io/fs package. The Go team decided to use a Reddit thread to host the conversation about this draft design. LWN points out that posters raised the following concerns:
We added status logging by wrapping http.ResponseWriter, and now HTTP/2 push doesn’t work anymore, because our wrapper hides the Push method from the handlers downstream.
June 8, 2020
Trade-offs of testing
While writing a unit test for a functionality today, I ran into a dilemma. For a given API test, T, should I choose to cover code for request parsing, routing, and preparation, or should I choose to make it orthogonal to those concerns?
Choice A) Start a server at a free port and send a HTTP request to it from a HTTP client Choice B) Call the function with manually created HTTP objects and avoid going through HTTP
June 3, 2020
Things I Hate - Go Edition
Cyclical dependencies Go disallows circular dependencies between packages.
In Java this is allowed:
package b; import a.A; public class B { public static void main(String[] args) { System.out.println("A.main"); A.doA(); } public static void doB() { System.out.println("B.doB"); } } --- package a; import b.B; public class A { public static void main(String[] args) { System.out.println("A.main"); B.doB(); } public static void doA() { System.out.println("A.doA"); } } Similar code is forbidden in Go. If you want to have test utilities, you often run into circular dependencies, leading to practices like https://golang.
May 19, 2020
Unit tests and system clock
It took me way to long to learn this. Your code (and their unit tests) should inject the system clock as a dependency.
An example, let’s say you have a service that writes a record to the database with the system clock.
public void save(String userName) { long currentTimeMs = System.currentTimeMillis(); User user = User.builder() .name(userName) .updateTimeMs(currentTimeMs); database.save(user); } How would you test this? You can inject a mock database instance and use it to verify that it got a User object.
May 17, 2020
Go Project Organization
Here’s a rough layout of how I organize my Go project. Some parts are situational and some parts are essential. I’ll go over both in this blog.
A rough layout:
+ basedir +-- go.mod (module jcheng.org) +-- hello (empty) +-- log/ +-- utils/ +-- config/ +-- models/ +-- repositories/ +-- services/ +-- cmd/ +-- hello_app/ +--/cmd/ +-- speak/ +-- email/ +-- sms/ The basedir Situational.
I have my (personal) projects in a monorepo.
February 27, 2020
Dependencies
Some past self version of me is saying, every class and function should be explicit about their dependencies, so that they are easily testable. John0 would say, “If you have a service that talks to a database, the database client should be an explicit dependency specified in the constructor. This makes the code easily testable.”
There is another version of myself from 10 minutes ago arguing it’s foolish to be explicit about everything.
January 4, 2020
Storing Configuration in the environment
There are two different ways to store configurations in the environment. One can choose to store a file name in an environment variable, or one can choose to use one environment variable per configuration. Take https://github.com/spf13/viper for example, the BindEnv() and related functions are designed to work with the one env var per configuration approach. The downside is that setting environment variables in the OS is tedious and requires flat/unstructured configurations.