Frank Lai

Techie and Business Dude - taking the serious humorously and humor seriously

Read this first


Stuff I wanna write in the future about Clojure:

  • 4 core data structures, 1 interface => composability of functions => higher code reuse
  • cheap immutability from the core functions (b/c structural sharing) => easy to write pure functions => decoupled functions => programs that are easier to think about
  • define what data looks like, then build pure functions around the data => no class design (I named my functions as nouns in this game)

Screen Shot 2019-04-24 at 4.09.47 PM.png

Screen Shot 2019-04-24 at 4.21.03 PM.png

*** really easy to make pure functions and doesn’t restrict you when you need to do stateful work if I can only say one thing about Clojure ***

Continue reading →

Class as Syntactic Sugar of Functions in Python

More explanation coming up, but essentially I’ve tried to define classes with functions in Python for a couple times already, but this time I have something that looks pretty good.

To use it, you just have to provide the class name and instance variables and methods:

{'__init__': <...>, 'instance_variable_or_method': <...>})

Essentially I used decorators to allow users to define functions that take in self as the first argument but call those functions without self. Also note, the init doesn’t have to return anything just like regular Python. The client code starts at line 22.

Screen Shot 2019-04-08 at 12.39.18 AM.png

Continue reading →

Lambda Calculus - Church Numerals

So while I was surfing on the internet, I bumped into things I picked when I was in school, lambda calculus being one of them. Now, I admit I’m not a theoretician or even a computer scientist, but this really amazed when I first learned it.

So it seems to me the great computer scientist, Alonzo Church, famously known for the Church–Turing thesis and lambda calculus (foundation of functional programming), had a problem he had to solve.

He had to define (almost) everything computable in functions, so he could come up with lambda calculus. And he couldn’t do it without first defining the natural numbers (0,1,…) with functions, so he went ahead and did that.

And the screenshot (2nd screenshot, obviously ;)) below was how he did it. By applying the function f, to the function x, n times, to replicate the idea of a natural number.


Screen Shot 2019-04-02 at 3.42.49 PM.png

Continue reading →

Generate Programs from Spreadsheets

The other day, my friend told me his product manager often times have trouble translating his financial models in spreadsheet to code, so he can test his ideas on larger datasets, because he is the one that has to come up with the business ideas and he has to go back and forth with his engineers to make sure the they’re communicating the business ideas properly.

So my friend asked can’t we make a program out of spreadsheets. I thought the idea was amazing: to allow people whom have the business ideas to generate programs to test their ideas on larger sets of data (maybe from the company’s database). We jumped right ahead into coding after talking about it for a bit.

Here is a few screenshots of compiling simple common mortgage calculations of total debt service ratio and gross debt service ratio into a Python program.

When we were talking about the idea, we realized if we treated...

Continue reading →

Code: Google Doc Clone

So I read up on Websocket the other day, and I thought to myself that could be a tool for building a Google Doc clone, so I went ahead and tried it out.

Screen Shot 2019-03-22 at 3.25.12 PM.png

So here’s a little screen recording of it running in action

Watch it on Vimeo

View →

Code: A Web Based Class Timetable for College Students

Check it out here

Screen Shot 2019-03-22 at 3.24.34 PM.png

View →

Code: The Simple Ideas Behind the Compiler for M0-lang

A few screenshots of what the language looks like.

Using the summation sign which I defined with a macro
Screen Shot 2019-03-21 at 11.24.15 PM.png

Defining the summation macro
Screen Shot 2019-03-21 at 11.23.47 PM.png

A Quick Overview of How it Works

View →