Pattern Breakers – Podcast Review

Podcast: https://www.youtube.com/watch?v=h9o6gPQA6LA&t=3s

Business is never a fair fight. Incumbants have an advantage. Startups have to change the battlefield/game so they have an unfair advantage.

  • Lage companies work by compounding improvements
  • Startups can’t be better, they must have something that can’t be compared, it can only be chosen.
  • e.g. People that buy tesla cybertrucks don’t create a spreadsheet comparing systems, they choose cybertruck as it’s unique.

Coming up with good idea:

  1. Inflections – An underlying fundamental external change.
  2. Insights – Non-obvious truth about the inflection learnt through effort.
  3. Founder / Future Fit

Inflections

  • An underlying fundamental external change.
  • Can be either: Regulatory, Tech or Cultural
  • Culture example would be covid making remote working and remote doctors acceptable.
  • Not a gradual increase e.g. NOT moores law but when there’s a 0-to-1 change. e.g. GPS added to phones.
  • e.g. Better phone cameras + Better internet = Instagram
  • e.g. GPS + Mobile Phones = Uber
  • It kinds of answers Why now?
  • Would DuckDB / AI be an inflection?
  • Testing Startup Ideas, do you have an inflection:
    • 1. What change has been introduced in the world?
    • 2. What does it now enable or empower people to do?
    • 3. What conditions are needed to enable it?

Insight

  • Non-obvious truth about a set of inflections
  • If it was obvious or consensus it would be too similar to incumbants.
  • Initially most people should not like your idea, only a subset
  • How? Look at the future, live there. Realise what is missing. Work backwards. e.g. Continuous Deployment, shift-left. SAAS.
  • Want to find believers to create a movement
  • For your idea, should be able to say 3 things that surprised you:
    • My examples: CloudKDB the name helping. qsandboxes = quants running tests.
    • No surprises = a false idea? and you may be too attached to it.
  • Insight requires work and experimenting. e.g. Try one page landing website to see demand. Can AI predict divorce?
    The “secret” needs to be earned as the market cannot exist today.
  • Non-Consensus = Not obvious you are correct at first.
  • You are trying to wage assymetric warfare against the large incumbents.

Founder / Future Fit

  • What is the likely team to solve this?
    • e.g. Cutting edge = Young and nothing to unlearn
    • e.g. Self-driving car = previous large corporate experience at Ford/Tesla/Waymo
  • Who knows the most about this future and has the best network?
  • You need either:
    • Be building a product for your own needs
    • Lighthouse Customers – That are leading the industry
    • Or force yourself to the edge.
  • Threshold of Desperation is High – Someone must NEED it
    • If the customer can solve their problem and other way they will,
      they don’t want to do business with a startup.
    • Force a choice not a comparison – People shouldn’t be neutral on your product. e.g. Trump e.g. Uber e.g. Airbnb
  • Startups have few resources and poor execution, they can’t be better (execution)
  • They have to sell something unique that people MUST have. My e.g. Online kdb training.

What do successful Startups Do?

  1. Movements = Small upset minority with beliefs causing them to rebel against the majority
  2. Story Telling – How things are now? Could be in future? How do we get there?
  3. Disagreeableness
  • Early customers are motivated on belief NOT practicality.
  • Early adopters share the beliefs of the founder and see startup as prime mover
  • Eventually “What was heresy becomes conventional wisdom” e.g. Javascript is a proper language, Webapps can replace all apps……
  • Movement example – Ride-sharing = Uber. The majority conventional solution were taxis, a few people saw a better way.
  • Start with a higher purpose! e.g. Tesla doesn’t mention cars it says it’s for transitioning to sustainable energy.
  • AirBnB – Movement example
    • Founder never said “Hotels = bad”
    • But he started a “Live local” movement. that turned the hotels homogenous appearance to a disadvantage. Rather than stay somewhere generic, stay somewhere unique. All the hotels investment was turned against it. Goliath was too large and heavy to avoid the slingshot.

Story Telling

  • How things are now? Could be in future? How do we get there?
  • Formula similar to Star Wars
    • Dusty simple plan -> Mentor appears with Tool/Magic (Mentor = startup)
    • Hero believes in tool -> Finds helpers -> Beats the Empire
  • Language is important e.g. Twitter wasn’t called microblogs. my e.g. I used the word Dashboards in Pulse 😦 Should be apps.

Book Review: Philosophy of Software Design – Ousterhout

binary comment

Overall: 8/10

I can recommend a Philosophy of Software Design Paperback by John Ousterhout. I’ve been programming for 15 years and it closely parallels my own current beliefs about programming. He stands above the lower aspects of programming/code/modules, raising the discussion to a conceptual level, that you seem to be wanting. If I had read this 10 years ago I may have marked it higher but after 15 I’ve already learnt a lot of it through pain. I would keep on ehandy in the office to help me with explaining reasons to junior developers during code reviews.

Book Notes:

Chapter 1/2 – It’s all about complexity.

Formula on page 6 I rougly agree with.
i.e. “complexity is determined by the activities that are most common.” If a system has a few parts that are very complicated but they never need touched, that doesn’t much affect the overall complexity.”
Total Complexity = Sum[ componentComplexity x timeSpentWorkingOnThatPart]

I think his formula for overall complexity is mostly correct: Total Complexity = Sum[ componentComplexity x timeSpentWorkingOnThatPart] However I would replace the timeSpentWorkingOnThatPart with the sum of the square roots of all separate times. i.e. Working on a component for 2 days straight versus working on it 1 hour every 2 weeks are quite different.

Symptoms of Complexity

  • Change amplification – changes require code changes in many places
  • Cognitive Load – How much dev needs to know to complete a task
  • Unknown Unknowns – Not obvious which lines of code must be changed to complete a task
  • In an obvious system a dev can easily see where to make a change in 1-2 places.
  • Complexity is caused by dependencies and obscurity.

Chapter 3 - Strategic vs Tactical

Tactical = Main focus is on getting something working quickly.
Strategic = Working code isn’t enough. Most important is long term system structure.
How much to invest? If all you do is tactical, you build up complexity and code debt which eventually slows you down:

Chapter 4 – Modules should be deep

Abstraction -> Simplified view of an entity, which omits unimportant details.
Deep Modules – The best modules are deep, they provide powerful functionality yet have simple interfaces.
Shallow modules = Classitis = separate functions for everything.

Thoughts…surface area should be connected molecules. With dependencies being thickness of connections? Consider how refactoring would look visually as molecule changes. 

Chapter 5 – Information Hiding

Information leakage – (Opposite of hiding) is when a design decision is reflected in multiple modules creating a dependency.
Temporal Decomposition – When methods must be called in a particular order. Great to finally get a name for this.

Chapter 6 – General Purpose modules are Deeper

Counter-intuitively, “code that is more general purpose is simpler, cleaner and easier to understant.” (Thoughts: this took me years to realise and value!! See Iverson APL )
(Some) Generality leads to better information hiding.
Create general class then push specialization up or down to calling classes.

Chapter 7/8/9

Pass-through methods = Red Flag = No clean separation of responsibility.
Decorators e.g. the old java bufferedInput(FileInput()) is an example of this.
Repetition = Red Flag
Special / General code mix = Red Flag

Pg 61. The amount of complexity exposed to users should be related to number of users to number of developers.

Chapter 10 – Define errors out of existance

His example is unix vs window file deletion. Unix takes care of it in background. Windows refuses and says directory/file is blocked.
Example from my own experience is returning empty lists instead of nulls.

Chapter 11 – Design it twice

Consider multiple approaches, outline them and document pros/cons and which one was chosen and why. (I always do this and make the notes inline or bigger ones in an architecture file. Now that he mentions it I’ve never seen anyone else do this. Crazy they don’t! I guess it does happen in PRs but that’s too late)

Comments – Should describe something that isn’t obvious from the code. it should either be a lower or higher level than the code it’s at.

Pg116 Cross module contents = architecture decisions.  Thoughts: Should I create fake global variable and link cross comments using them. Ensure link stays valid.  

Chapter 14 – Naming
Chapter 15 – Write the comments first
Chapter 16 – Modifying existing code
Chapter 17 – Consistency – Great point!! I’ve learnt how important being consistent in a code base is over many years of pain. Even if the code is not optimal for that area, there’s value in it all being the same pattern everywhere! Only add new if willing to change all other similar parts.
Chapter 20 – Performance = Measure

New Sql Documentation Website

I’ve decided to create a new SQL documentation website for H2: sqldock.com/h2
Why?

  1. I was tired of scrolling the large page of functions to find the funciton I wanted. I also wanted examples of that funciton being used.
  2. For qStudio we provide tooltips that say what a function does AND links to actual vendor documentation. Well every so often vendors move those docs. By hosting it myself I can guarantee the doc link won’t be broken and that I won’t have to change links every other year. I can standardise the path and always send users there for docs.

Hopefully others find it useful. Let me know what you think.

Hibernate sucks but what’s the alternatives? Java Persistance Options

Everyone seems to jump straight to hibernate and not consider alternatives and when to use each. Let’s look at this afresh. We want to create a SAAS or self-hosted app and for any modified entites to be persisted. Entites being users, teams and widgets. Imagine something like a simple github json API server where users belong to a team, users or teams may have repos etc.

Typical Operations

  • Create a user/team.
  • Get a user and the list of teams they are linked to.
  • For a given widget, check if the user has access permission.
  • Keep database updated as new columns or tables are added.

Options:

  • Hibernate – Java Class Driven. Fully mapped objects, generate schema from objects, query everything through repositories i.e. hibernate layer.
  • Hibernate Hybrid – For most save items, update items use hibernate. For some complex or optimized selects use raw SQL with automapping to JSON where possible.
    • Automap requires either creating java classes and letting Object->JSON happen
    • Manual conversion / automatic resultset conversion.
  • Raw SQL – Thin Wrapper. Create database manually. Insert / Select writing raw SQL tables. Probably use a very thin wrapper that autoconverts resultsets to JSON.
  • JOOQ – Database Driven – Based on database generate type safe java access layers.
  • Blob Storage (Async) – Literally do not run any SQL commands. Only periodically save down all java state required. I mean you could even serialize everthing to one binary file. Or serialize large chunks and store them as strings to database.

Decision Pivot Points:

  • If SQL querying not needed and no relations within or no insight into inner data = Blob
  • If many standard CRUD operations over different entities = Hibernate
  • If many customized selects = JOOQ – to provide type checking.
  • Never RawSQL. You may as well use a very thin wrapper.
  • Other options? Write your own wrapper to persistance?

Outcome for me

Unfortunately we already adopted hibernate before giving it much thought. In hindsight we should have evaluated JOOQ as we have 2-3 entities which have modified SQL queries for half the operations.

Update:2023-11-23 I tried to convert parts of code base to JOOQ. JOOQ had lots of features and great docs on versioning, locking, storing, CRUD. The main parts lacking were nicer generted POJOs with primitives for “NOT NULL” and soft deletes. Without soft deletes I can’t use it as primary persistance only for SQL queries to be type safe.

These quotes captures my worry with Hibernate:
“John, I thought we were entering a new era of software development. I thought we were doing a light-year’s jump. But, after four years, it seems like we are still dealing with all the same problems, only from a different angle. I had to learn Hibernate architecture, configuration, logging, naming strat…………….ritance mappings, replicating object between two different datastores, detached objects and automatic versioning, connection release modes, stateless session interface, taxonomy of collection persistence, cache levels, lazy or eager fetching and many, many more. Even with everything I know, it seems like we’ve failed badly. It’s a software fiasco! Ultimate failure! Disaster! Armageddon!”
“so we decided to rewrite it as plain SQL statements. What’s funny is that writing plain SQL was actually the fastest way of doing it, so we decided to do it as our last option.”


I would suggest one idea, to use Blob storage for individual entires that you don’t need to “look inside”. There’s no point converting JSON to java objects to nested entities, if you never need to access those entities within Java. Just store the blob.

Podcast Notes

Podcasts I listen to:

Below I will make notes on specific podcasts and what I took away from them:

  • Idea to Startup – Find your wedge – You MUST be solving a bleeding neck problem else most people won’t care and won’t tell others.
  • AirPlane.devSaaS Club 370 – Very similar product to PulseUI. His elevator pitch at start is really slick.
    • About Pulse? What’s it do? Who’s it for? What’s the main problem it’s trying to solve?
    • Half the software in the world is internal tooling, for every line of code behind your favourite app, there’s another line powering internal platforms and operations.
      • Massively important to success of business
      • Chronically not invested in as nobody wants to work on these tools
    • Our goal is to make it faster to build software tooling for these businesses.
    • Founder fit – Will you be happy working on this for 10 years?
    • We are doing all the boring bits…for us it’s fun as we are doing it at scale.
    • “You could build thi syourself but do you really want to”
  • Lenny – Wise.comHow to drive word of mouth. Think this was good need to recheck.
  • Saastr – Loom – Building flywheel. Users didn’t know they could share URLS! they needed to add a share button.

The End of Open Source tech SAAS Companies?

I’m on quite a few slack channels and I got a message today on the radpanda/kafka slack:

Which if you follow to their website (Aiven):

  1. They describe themselves as: “The trusted open source data platform for everyone”
  2. They offer hosting on AWS/Azure/Google for all the new hip open source data technologies. Kafka, Flink, Influx, Redis.
  3. Under technology partners page, all their partners are hosting firms.
  4. They are not partnered with any of the firms that build the software. None of the management team has worked on or in open source.

For end consumers this is good, get reliable hosting from a “big firm” that supplies many other systems that you may use. For bigtech it’s a win as it will be hosted on their cloud. For startup/tech companies this is deadly. Why would anyone wait to host on their platform?

This feels like the next evolution of the spat between technology companies and bigtech aka google/amazon. Previous disagreements have forced some technology companies/startups to change away from open source licensing e.g. Elastic but the big guys also received bad press for doing it. Now with an smaller intermediary party, the bad press has only a positive effect in advertising them more.

Half the work in building a new SAAS offering is building and supporting the general platform, user logins, system backup, recovery etc. If this middle company spreads that cost over multiple offerings and doesn’t pay to contribute any open source back, they can supply it faster and cheaper short term.

As I look at startups or new tech companies like questdb, redpanda, timeplus, materialize, redis, superset, clickhouse….if a company like this starts offering their tech early I think they could get a lot, if not most the business while the other company pays the cost of development. In some cases as we seen they are on the open source slack channel engaging customers away….

What do you think?

Ongoing New Quotes / Articles

I have an old page: legendary quotes.

As I gather new ones, I will add new ideas here and prune them over time:

“Just recently I came to a realization, people and organisations exist in a competency / incompetency matrix.

The competent orgs with incompetent people are your blue chips and “traditional” companies. They ship stuff, have customers, grow along with the overall market and economy and are able to survive most non-existential threats and down-turns and even existential ones from time to time. All, or most, the competency is institutional, recorded in implicit knowledge held by people and various tools and processes. Unless those companies lose that knowledge for some reason, things are good.” – hef19898 – On HN

“When making life decisions, going in the direction of more money can be wise. However, we must keep in mind that when we choose money, we don’t choose much. We just decide to decide later.”

“Upper limit of complexity is infinity? An engineer can hold a whole complicated system in his head and work on it. When he leaves and needs to pass it on, he won’t be able to communicate it all. Complexity we can sustain over time is less than today.” https://www.youtube.com/watch?time_continue=2841&v=pW-SOdj4Kkk

Norris Numbers – average amount of code an untrained programmer can write before he or she hits a wall. Clift estimates this as 1,500 lines. Beyond that the code becomes so tangled that the author cannot debug or modify it without herculean effort.

… the very language that one could use to make a comparison is taken away, and the possibility of benchmarking on a different infrastructure is an endeavor akin to rewriting everything from scratch.
https://cerebralab.com/Is_a_billion-dollar_worth_of_server_lying_on_the_ground

““The choice isn’t between automation and non-automation,” said Erik Brynjolfsson, the director of M.I.T.’s Initiative on the Digital Economy. “It’s between whether you use the technology in a way that creates shared prosperity, or more concentration of wealth.””

“People are taking the piss out of you everyday. They butt into your life, take a cheap shot at you and then disappear. They leer at you from tall buildings and make you feel small. They make flippant comments from buses that imply you’re not sexy enough and that all the fun is happening somewhere else. They are on TV making your girlfriend feel inadequate. They have access to the most sophisticated technology the world has ever seen and they bully you with it. They are The Advertisers and they are laughing at you.

You, however, are forbidden to touch them. Trademarks, intellectual property rights and copyright law mean advertisers can say what they like wherever they like with total impunity.

Fuck that. Any advert in a public space that gives you no choice whether you see it or not is yours. It’s yours to take, re-arrange and re-use. You can do whatever you like with it. Asking for permission is like asking to keep a rock someone just threw at your head.

You owe the companies nothing. Less than nothing, you especially don’t owe them any courtesy. They owe you. They have re-arranged the world to put themselves in front of you. They never asked for your permission, don’t even start asking for theirs.” -Banksy

“Every internal decision about look and function answers the questions “What does the customer need?” and “How can we help them be more productive?” (Not “How can we give them what they’re asking for?” because that isn’t the right question to answer.)” – source.

Articles:

The most plausible explanation I’ve seen for people moving off programming onto different jobs:
https://whoisnnamdi.com/never-enough-developers/

A case where tight feedback loops don’t help.
https://brianlui.dog/2020/05/10/beware-of-tight-feedback-loops/

What Color is Your Function?

THE TYRANNY of STRUCTURELESSNESS
https://www.jofreeman.com/joreen/tyranny.htm

psychohistory is real:
https://journals.plos.org/plosone/article/file?id=10.1371/journal.pone.0237458&type=printable

Crafting Interpreters – Nystrom

I have read this book, went through the exercises and went back to reference this book a number of times.
It’s 10/10 excellent
but I confess I almost forgot to write a review as I mostly read it online and only bought the (heavy book. See pic) to make sure the author got paid for his brilliant work.

Summary: “A comprehensive introduction to writing an interpreter for a dynamically typed, object-oriented toy programming language (Lox). Throughout the book the author develops two complete interpreters for the language from start to finish, including all the front-end and backend parts. The first is a simple AST walking interpreter implemented in Java, and the second is a moderately optimized VM written in C, including a garbage collector.” (src)

Crafting Interpreters Book

Batteries Included = Comes together with all possible parts required for full usability

Every developer should:

  1. Implement a programming language at least once.
  2. Use this book as a guide.

I confess I didn’t arrive at this book naively. I have previously taken 1 university course on compilers and implemented parts of a language naively, i.e. just having a go without any advance thought. If possible I would recommend “having a go” first as it will truly make you appreciate how great this book is.

Robert Nystrom gently leads you down the garden path of creating an interpreter in java and then in C. Even with no C/java experience I think most people could follow along. In fact a major positive of the book is that all code is covered in the book. In theory and mostly in practice I did this. I implemented the language as I followed the book. I wasn’t making his lox language but every step he showed was applicable and useful.

Since I’ve been writing a language on/off for a few years and recently stumbled upon the book. I’ve been particularly interested to read the parts of the book I’ve already implemented to see how someone else approached or thinks about the problem. It has been highly amusing, Robert has some keen insights and his diagrams are brilliant!

If you are a programmer buy this book and more importantly follow it to implement a language that interests you.
The insight it will give you long term is invaluable.

Link to referenced summary: https://eli.thegreenplace.net/2022/book-review-crafting-interpreters-by-robert-nystrom/

Bonus Points: +1 for the author as I emailed them in 2020 when I read the book and they gave a detailed reply to a particularly niche query. Thanks Bob.

Company Contractor Cash Flow Diagram

code:

digraph G {

subgraph cluster_0 {
label = “Me”;
node [style=filled];
pension salary dividend mbalance ISA stocks expenses;
color=blue
}

subgraph cluster_1 {
node [style=filled];
NIC VAT CapitalGains IncomeTax Corporation;
label = “Gov”;
color=red
}

subgraph cluster_2 {
node [style=filled];
profits revenue cbalance employee;
label = “Company”;
}

mbalance -> pension;
IncomeTax -> pension [label=”tax relief”];
mbalance -> stocks;
stocks -> mbalance;
stocks -> CapitalGains [label=”10% tax”];
ISA -> mbalance;
mbalance -> costs;
revenue -> pension [label=”40K limit”];
revenue -> VAT [label=”14.5% VAT on revenue”];
cbalance -> dividend [label=”pay shareholders”];
“UK customer” -> revenue [label=”pays for services\n+20% VAT”];
customer -> revenue;
revenue -> profits;
profits -> cbalance;
revenue -> costs;
cbalance -> employee;
profits -> Corporation [label=”19% of profits”];
employee -> NIC;
employee -> salary;
salary -> IncomeTax [label=”20-45% tax”];
costs -> expenses [label=””];
pension -> mbalance;
dividend -> mbalance [label=”2K allowance”];
dividend -> IncomeTax;
salary -> mbalance;
mbalance -> ISA [label=”20K annually”];
}