Plain English to Code

"Find the product. If found, increase its quantity. Otherwise add it." → language-neutral pseudocode → one operation implemented → the same algorithm in C++, JavaScript, TypeScript and Python. Frameworks come last.

Plain-English Logic Is the Algorithm

"When adding a product: check whether it exists; if it exists, increase the quantity; otherwise create a new item." That is not a description of an algorithm you still have to find. It is the algorithm. If you can say what happens in numbered sentences, the hard part is done, and what remains is transcription.

Q · You can explain what "add to cart" does to a colleague in three sentences. Why does the code still feel out of reach — and what, exactly, is left to do?
From English to Pseudocode

The six sentences become eight lines. "Look for an existing entry with this product id" becomes `item = find entry in cart.items with item.productId == productId`; "if one exists, increase its quantity" becomes `if item exists: item.quantity = item.quantity + quantity`. Side by side, every line has a sentence and every sentence has a line — and the places where the line had to say more than the sentence are where the operation was underspecified.

Q · You have the numbered sentences. How do they become pseudocode — and what does the transformation reveal that the sentences hid?
Language-Neutral Pseudocode

The pseudocode for `addItem` does not mention React, Express, Django or Spring — or TypeScript, or Python. It models the operation's contract: what it takes, what it reads, which way it branches, what it changes, what it returns. That contract is what stays fixed while the language and the framework change around it, and it is the thing a framework will later wrap.

Q · Your pseudocode has a `useState` in it. What went wrong, and what is the pseudocode supposed to be neutral *from*?
Implement One Operation
▶ lab

Only now, real code — and only `addItem`. Two types, one function, in TypeScript, transcribed from the pseudocode line for line; the other five operations wait. One operation is enough to run the first three examples, find the first mistake in the transcription, and learn what the language did to the pseudocode — all before there is much code to be wrong.

Q · The pseudocode is done. Which operation do you implement first, why only one, and what should you learn from it before writing the second?
The Same Algorithm in Four Languages
▶ lab

C++, JavaScript, TypeScript, Python: four `addItem`s, one algorithm. The concept, the eight-line pseudocode and the six examples do not change; the find is a `for` loop with a pointer, an arrow function, the same with a type, or a generator with `next`. What varies is syntax and a handful of language decisions — which is what makes the algorithm the thing worth learning.

Q · You implemented addItem in TypeScript. What changes when you write it in Python or C++, what does not — and what does that tell you about what you actually learned?
The Framework Comes Last

Only after the core logic works: React holds the cart in state and calls `addItem`; an Express route calls it and returns JSON; a repository loads the cart, calls it, and saves. The record's note says it plainly — "the framework wraps behaviour that already works, which is why it comes last, and why the same five functions survive every framework change."

Q · The cart works in memory with its tests. When does the framework enter, what does it wrap, and what should it never be allowed to contain?