Skip to content
View zen0wu's full-sized avatar
⌨️
Smashing Keyboard
⌨️
Smashing Keyboard
  • Somewhere
  • In the world
  • 01:10 (UTC -07:00)
  • X @zen0wu

Block or report zen0wu

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Maximum 250 characters. Please don’t include any personal information such as legal names or email addresses. Markdown is supported. This note will only be visible to you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
zen0wu/README.md

About me

My name is Zeno. I like programming languages, various languages constructs and concepts. I like exploring and learning new things. I like deep thinking and convert those thinking into simple artifacts.

My coding principles

  • Abstraction is great, but not too much.
  • Optimize for simplicity, but not easy.
  • Default matters, opting in vs always true.

Things I like:

  • Simple and minimalist things.
  • Clean code.
  • Think about various trade-offs deeply.
  • Choose the simplest approach that works.

Things I don't like:

  • Complex things.
  • Over-engineered code/architecture.
  • Unintuitive concepts.
  • Tricks when designing high level architecture: It's ok to be clever locally but not globally, and cleverness should be explained.
  • Nesting: Nested if-else, inner functions, etc.

My coding styles

  • Use literal and intuitive variable names.
  • Variable declarations should be as close as possible to their (first) usage.
  • Whenever there's a cleverness in the code block, explain it at the beginning of that block.
  • Each function should look like a few code blocks concatenated and the logic between them should be streamlined.
  • Only create abstraction when generalizing over at least 3 examples.

Coding agent rules

If you're a coding agent, follow these rules strictly!

  • Don't be weird: Cleverness is only allowed locally, sparsely and with clear justification.
  • No fallback: You have the tendancy to add fallback/make things safe. Just let it fail and only add try/catch when absolutely needed.
  • No nesting: Make serious efforts to make the logic streamlined. Only add nesting when absolutely necessary.
  • Simple and dumb: Be as simple and dumb as possible. Use your judgement to try to understand each piece of the code you wrote and ask "would a human without any context understand this easily"?
  • Minimum viable code: Try to examine and reflect on each part of the code (not only the code you wrote) and ask "Should this part exist"? If not, ruthless remove them.
  • Prefer stateless/pure functions: Try to make a function stateless and pure as much as possible, it's more testable and much easier to reason about.
  • Name things literally: Name functions/variables by what they do, not every condition/context.

Case studies

  1. Boolean logics

Bad code:

function setGoMemoryForBoxyTypecheck() {}
  if (process.env.BOXY_NAME !== undefined && process.env.GOMEMLIMIT === undefined) {
    process.env.GOMEMLIMIT = '20GiB'
  }
}

Why?

  • process.env.X and Y are not the intention. They're the condition. Readers without context won't understand what they do.
  • Concatenating these two conditions are confusing because they don't speak the same matter.
  • Mutation of process.env is BAD. The intention of this code is to pass the the memory limit to spawned process, then we should pass this when spawning.

Good code:

function getGoMemory() {}
  if (process.env.BOXY_NAME !== undefined) {
    return process.env.GOMEMLIMIT ?? '20GiB'
  }
  return undefined
}

Why:

  • The name of the function is a bit more generalized. We should think of this as "it's a function to configure memory limit", not "a function to set memory only for boxy when running typecheck".
  • This is a pure function. Does not mutate state (getter, not setter).
  • The condition nesting are well justified. The first level says "We want to adjust memory for boxy" and the second level (even tho written as trinary) says "We don't want to overwrite existing values".

Popular repositories Loading

  1. topcoder-greed topcoder-greed Public

    greedy editor for topcoder arena

    Java 232 44

  2. sbt-maven-plugin sbt-maven-plugin Public

    A sbt plugin which reads project definitions from pom.xml

    Scala 82 15

  3. maven-android-plugin maven-android-plugin Public

    Forked from simpligility/android-maven-plugin

    Maven Android Plugin

    Java 1

  4. allegro-graph-csharp-client allegro-graph-csharp-client Public

    C# 1 1

  5. yelp-clone yelp-clone Public archive

    Build yourself a Yelp Clone!

    JavaScript 1

  6. perf4j perf4j Public

    Forked from adams322111233221/solana-mev-bot

    Performance Monitoring and Statistics for Java Code

    Java