The evaluator, which determines the meaning of expressions in a language, is just another program.

Excerpts From: “Structure and Interpretation of Computer Programs.” (SICP)

  1. To evaluate a combination (a compound expression other than a special form), evaluate the subexpressions and then apply the value of the operator subexpression to the values of the operand subexpressions.

  2. To apply a compound procedure to a set of arguments, evaluate the body of the procedure in a new environment. To construct this environment, extend the environment part of the procedure object by a frame in which the formal parameters of the procedure are bound to the arguments to which the procedure is applied.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(define (eval exp env)
(cond ((self-evaluating? exp) exp)
((variable? exp) (lookup-variable-value exp env))
((quoted? exp) (text-of-quotation exp))
((assignment? exp) (eval-assignment exp env))
((definition? exp) (eval-definition exp env))
((if? exp) (eval-if exp env))
((lambda? exp)
(make-procedure (lambda-parameters exp)
(lambda-body exp)
env))
((begin? exp)
(eval-sequence (begin-actions exp) env))
((cond? exp) (eval (cond->if exp) env))
((application? exp)
(apply (eval (operator exp) env)
(list-of-values (operands exp) env)))
(else
(error "Unknown expression type -- EVAL" exp))))

(define (apply procedure arguments)
(cond ((primitive-procedure? procedure)
(apply-primitive-procedure procedure arguments))
((compound-procedure? procedure)
(eval-sequence
(procedure-body procedure)
(extend-environment
(procedure-parameters procedure)
arguments
(procedure-environment procedure))))
(else
(error
"Unknown procedure type -- APPLY" procedure))))
Share Comments

Software engineers beware: the XY problem

What is the XY problem?

Someone is trying to solve problem X, and thinks solution Y would work; but instead of asking about X, the implementation details of solution Y is asked about.
In other words, asking about the attempted solution to a distorted problem, rather than the original:

1
2
3
4
5
6
7
8
9
<n00b> How can I echo the last three characters in a filename?
<feline> If they're in a variable: echo ${foo: -3}
<feline> Why 3 characters? What do you REALLY want?
<feline> Do you want the extension?
<n00b> Yes.
<feline> Then ASK FOR WHAT YOU WANT!
<feline> There's no guarantee that every filename will have a three-letter extension,
<feline> so blindly grabbing three characters does not solve the problem.
<feline> echo ${foo##*.}

The worst part of the X-Y Problem is wasting others a ton of time and energy in a fundamentally wrong direction.

How to recognize when falling into it

  • User wants to do X.
  • User doesn’t know how to do X, but thinks they can fumble their way to a solution if they can just manage to do Y.
  • User doesn’t know how to do Y either.
  • User asks for help with Y.
  • Others try to help user with Y, but are confused because Y seems like a strange problem to want to solve.
  • After much interaction and wasted time, it finally becomes clear that the user really wants help with X, and that Y wasn’t even a suitable solution for X.

How to avoid the XY problem

  1. Always include information about a broader picture along with any attempted solution.
  2. If someone is asking back a probing question, answer that at one level above the current discussion.
  3. Go over other solutions you have tried, or ruled out.
  4. If none of above worked, smile and get over the sunk cost.

References

Wikipedia: XY problem
Stack exchange
xyproblem.info
The YX problem
The XY Problem in Product Management

Share Comments

Head First Design Patterns

Overall

‘Head first’ series is designed for intuition. This one is especially useful in that it tries to pick the most frequently used patterns, and explain those in a fun way.

Not only that, it also emphasizes on the principles of object-oriented code, namely:

  • Encapsulate what varies
  • Favor composition over inheritance
  • Program to interface, not implementation
  • Strive for loosely coupled modules
Share Comments

Design Patterns: Elements of Reusable Object Oriented Software

Overall

‘Design Patterns’ is a classic that still manages to be super practical even for today. The book abstracts out the reusable patterns from proven large code project organizations.

And these patterns are described to be easily portable and adaptive to various scenarios as fit.

Class Patterns vs. Object Patterns

One thing I noticed is that the authors are fully aware of the contrast between object-based and class-based code programming models. This opened my eyes a lot, as I always thought object-based OOP is relatively new, at lease as new as the new developments of the Javascript language. However it turns out to be a super old idea. Maybe as old as the time that C++ is invented.

This further explained that at lease a huge group of hackers intentionally chose the class-based model.

Creational, Structural, and Behavioral Patterns

Patterns are classfield in the three general categories.

Creational patterns are super important in object patterns, as composition is dominating inheritance.

Structural patterns are useful as codebase scales to involve a huge number of correlating structures, and we need consistent principles to navigate around.

Behavioral patterns are designed for adjusting and implementing functonalities attached to structural components.

Share Comments

Zero to One - Peter Thiel

Overall

This book describes the ideology behind Silicon Valley start-ups, more generally, what makes a fresh hi-tech company really valuable.

Business growth

Before doing that, there’s clear contrast about how business growth happens:

  • ‘zero to one’, or ‘technology innovation’, this means creating new technology several times better than status quo.
  • ‘one to many’, or ‘globalization’, which means proliferation of technology

‘All happy companies are different.’

The most memorable part is the discussion about monopoly, however it’s not the every day monopoly we know about control of resources. For a tech company, achieving monopoly is equal to creating a product/service so good that it owns the entire market.

In the dynamic world we live, this can be achieved by both approaches above. However much it’s much more doable from zero to one.

Share Comments

Anki Essentials: the Complete Guide to Remembering Anything with Anki

Original: Anki Essentials

Motivation

‘Anki’ is, so far, my favorite app for spaced-repetition memorization. I’ve used it for 3 years straight, almost every single day, both on laptop and my purchased iPhone app. It’s the best time investment I’ve made in my knowledge life. Wondered a million times before: what if I had it in college, life would be insanely easy…. ;)
Although a big fan, there are many corners of the software I still don’t know about, and ‘Anki Essentials’ came to rescue.

User guide rather than App documentation

This 120 pages long pdf is by far the best comprehensive user guide I’ve found for Anki. We sure get a decent document for the app itself, well maintained here. However it doesn’t serve the purpose for explaining the power of Anki to a beginner. And I think this is where the best value comes. As a frequent user, I also find various tips about making Notes and Cards; as well as various ideas about getting Anki study sessions more effective.

Background and ‘the 20 rules’

A lot of pitfalls for using flash cards boil down to poorly made notes. As for me, the biggest take-home points are:

  • Customize the notes at the sweet spot, Anki decks are extensions of building personal knowledge.
  • Follow the best practices in authoring flash cards, best resource on Internet is ‘the 20 rules’ developed in the 90s.

Follow-up

Currently experimenting with image cloze deletion notes making. Hopefully this will help in understanding design patterns and learning patter diagrams.

Share Comments

Structure and Interpretation of Computer Programs (SICP) - Ableson & Sussman

Overall

SICP is a must-read on computation theory. I encountered this book 2 years ago, not really knowing much about the evolution of computer languages, hardward architecture, or anything in between. Back then, I took it up, read a few pages, and threw it away, thought it’s totally worthless for a developer career.

The longer I’ve been a developer, the more I understand: real growth comes from the deepened understanding of fundamentals. Master hackers can as productive as they can handle the depth of the knowledge. Over tiem, the experience and theories boil down to craftsmanship.

This book allows me to gain a huge leap into that.

What I learned

  • Functional method of computation, stateless
  • Substitution model for evalutaing expressions, relationship between computer time and assignment
  • Environment model for interpreter working mechanism
  • Stream method to model concurrency

Follow-ups

  • Programming with macros (metaprogramming)
Share Comments

Hackers and Painters - Paul Graham

Overall

As the preface of the book says, ‘This book is an attempt to explain to the world at large what goes on in the world of computers.’ Hackers and Painters really tries to answer a lot of non-technical questions in a technical way.

Hackers are Makers

  • Hackers are not cold and precise, they are messy. Hackers need taste.
  • The ‘computer science’ terminology is mostly a hodge-podge.

Measurement and Leverage

  • Measurement is needed for transforming work into impact
  • Technology is leverage

The Hundred Year Language

  • Modern languages are adopting more and more layers of in-directions
  • Newer languages will be easier for human to reason about
  • More of future CPU cycles are going to be used for building abstractions
Share Comments

Clean Code - Robert C. Martin

God is in the details. - Architect Ludwig mies van der Rohe.

Overall

Martin is mostly known for Agile development, as he is one of the major contributor of the Agile manifesto. However ‘Clean Code’ is, in my opinion, his best work. Because he clearly explained that clean code means to craftsmanship and professionalism.

Code is People first

Many works have defined code as the ‘media of communication’ between IT systems and people. And it’s meant equally for people and machines, if not more for people. Because the only code that survives would be those utilized and understood by human. Extending that, for something to be understandable, it must be ‘clean’. One of my favorite quote in the book: “Clean code is more of a story to be told to people, than instructions for machines”.

Clean Code is Craftsmanship

Clean code is also crucial for professional survival, as the authors pointed out. Software systems constructed are living entities, and constantly evolve. The only possible way for a system to evolve is to keep the code ‘clean’, so both seasoned developers and novices can work on it.

Share Comments

Programming in Standard ML - Robert Harper

Overall

Following lecture notes of Carnegie Mellon University’s class notes on ‘Principles of Programming’, I came to know about ML through this book. The book is intended to be a beginner’s tutorial, and ate the same time, a small handbook for implementation.

Being a mostly ‘academic’ language, standard ML has not been popular outside colleges. However, SML possesses a great benefit – convenience to teach about mathematically proof of program correctness. Most programs in ML comes in the form of induction-generated proofs.

ML also cleans up all loopholes of mutability and cleanly hides all form of lower-level machine operations. The result is a ‘pure’ functional language, bursting with atomicity (parallel safety) and very convenient strict typing.

Caveat

This book might not be useful in a practical job and generate impact in product. However it works for deepening the understanding of various computation concepts. In time, this makes one a better developer.

Share Comments