5 ms·
Show HN: Algorithms and Data Structures in TypeScript – Free Book (~400 Pages)
I started writing this book 10 years ago in JavaScript, got through a few
chapters (asymptotic notation, basic techniques, start of sorting), and
then abandoned it.
Recently I picked it back up, converted everything to TypeScript, and used
AI (Zenflow [1] + Claude Opus 4.6) to complete the remaining chapters. I
provided the structure, direction, and initial chapters; the AI generated
the bulk of the remaining content under a spec-driven workflow.
The book covers roughly a first 1-2 year CS curriculum: sorting, dynamic
programming, graph algorithms, trees, heaps, hash tables, and more. All
code is executable, typed with generics/interfaces, and covered with tests.
I've thoroughly reviewed several chapters (sorting, DP, graphs) and done a
high-level pass on the rest. Currently in beta — corrections and
contributions are welcome.
MIT licensed. Inspired by Wirth's "Algorithms and Data Structures", SICP,
and CLRS.
Code and tests: https://github.com/amoilanen/Algorithms-with-Typescript https://github.com/amoilanen/Algorithms-with-Typescript
[1] https://zencoder.ai/zenflow https://zencoder.ai/zenflow
- BloodAndCode 7mo ago[flagged]
- jsontwikkeling 7mo agoGreat to hear that. I actually think TypeScript is very fit for the purpose, even better than Python (lacks types) or Java (bulkier). Type signatures document contracts directly: export function rabinKarp(text: string, pattern: string): number[] Clear that it takes two strings and returns match positions. No separate explanation needed. Interfaces model return types and ADTs cleanly: export interface ShortestPathResult<T> { dist: Map<T, number>; parent: Map<T, T | undefined>; } export function dijkstra<T>(graph: Graph<T>, source: T): ShortestPathResult<T> It's also lightweight, flexible, has familiar C-like syntax, and unlike pseudocode — you can actually run everything. Re: generics feeling awkward — in TypeScript they feel pretty natural. The type inference helps a lot, you rarely need to spell out type parameters at call sites.
- BloodAndCode 7mo ago[flagged]
- Copyrightest 7mo ago[dead]
- gausswho 7mo agothis is well structured and put together. i would think it serves as a good base for refreshing oneself on the fundamentals. and it has a satisfying bend towards being both concise and thorough.
- orkunk 7mo ago[flagged]
- useftmly 7mo ago[flagged]
- jsontwikkeling 7mo agoExactly - this is precisely why I built the project as an integrated repo centered around code and tests first, with the book as one of the produced artifacts rather than the other way around. Having both an engineering and academic background, I felt there's underappreciated potential in bringing software engineering best practices - tests, type contracts, CI - into an algorithms textbook. Most CS teaching treats code as illustration. I wanted it to be the source of truth. And agreed on structural typing for graphs. TypeScript lets you define a Graph<T> interface and defer the representation choice, which maps very well to how the topic is actually taught - abstract properties first, concrete implementations second.
- useftmly 7mo ago[flagged]
- tossandthrow 7mo agoThis seems to be an entirely AI promoted post. dang: Can we get stuff like this out?
- jsontwikkeling 7mo agoIt might seem so, but it is not an AI promoted post. The book was finished with the AI tools, but a bulk of it was written by myself plus the structure and direction. And I am human, who first finished a similar course roughly 20 years ago, worked as a TA and taught students programming and algorithms
- tossandthrow 7mo agoI didn't talk about the book. I talked about the first 5 comments on the thread, all by new accounts. It seems like an AI campaign. not organic up votes.
- jsontwikkeling 7mo agoOK, I am not sure who these are. I would not promote my post like this. They are indeed new accounts
- Permit 7mo ago> and done a high-level pass on the rest. Why would I read your book if you have not read your book? Edit: I now understand what is going on here. This is an attempt to promote Zenflow. The GitHub account (https://github.com/amoilanen/ https://github.com/amoilanen/) is Anton Moilanen who is an employee at Zencoder, the creators of Zenflow. The account (https://news.ycombinator.com/user?id=jsontwikkeling https://news.ycombinator.com/user?id=jsontwikkeling) was created 86 days ago the same day as this Show HN post was created: https://news.ycombinator.com/item?id=46290617 https://news.ycombinator.com/item?id=46290617 It would probably be worth the moderator's time to see if this post was part of a coordinated upvote ring as well.
- jsontwikkeling 7mo agoIt is your choice. I have read a good part of the book, also wrote a part of it and am in the process of finishing the review. The more reviews - the better. The book is officially in beta and this is fully transparent
- bananamogul 7mo agowhat kind of author releases about a book they themselves have not read? Could you possibly care less about your readers and your own work?
- bombcar 7mo agoAt least he's honest about it, the vast majority of AI people would just submit it as their own work having never read it at all.
- Permit 7mo agoHe's being dishonest. He's attempting to promote Zenflow (a tool created by his employer Zencoder). He's produced AI slop (that he has not even read!) as a vehicle to promote Zenflow and get it in front of eyeballs on HackerNews.
- deleted 7mo ago[deleted]