Pinned Tweet
"Locals live on the stack. new puts objects on the heap."
You've heard this a thousand times.
It's a useful mental model.
It is not a C++ rule.
The language only defines storage duration — how long an object’s storage lasts.
There are exactly four kinds:
• automatic
• static
• thread
• dynamic
Compilers typically map them to stack/registers, data/BSS, thread-local storage, and the heap.
Typically.
Not guaranteed.
This distinction matters more than most people realize (especially in interviews and performance work).
Which part of this did you learn the hard way? 👇
#cpp #cplusplus #programming
0xFaffy retweeted
Replying to @ChShersh
Love the C version. In C++ the interesting part is 𝘸𝘩𝘦𝘳𝘦 the buffer lives and who owns it.
𝘀𝘁𝗱::𝘃𝗲𝗰𝘁𝗼𝗿 is three pointers (𝗯𝗲𝗴𝗶𝗻, 𝗲𝗻𝗱, 𝗰𝗮𝗽𝗮𝗰𝗶𝘁𝘆_𝗲𝗻𝗱) + an allocator. Object usually on the stack, buffer separate.
Empty → no buffer.
𝗿𝗲𝘀𝗲𝗿𝘃𝗲(𝟭𝟬𝟬) → capacity only, size stays 0 (accessing elements is still UB).
𝗿𝗲𝘀𝗶𝘇𝗲(𝟭𝟬𝟬) → constructs elements.
When capacity is exceeded:
• allocate new buffer (usually 1.5×–2×) from the allocator
• move-construct existing elements
• destroy old ones + free old buffer
• update the three pointers
All iterators, pointers, and references are invalidated.
You control the source:
- 𝗽𝗺𝗿::𝗺𝗼𝗻𝗼𝘁𝗼𝗻𝗶𝗰_𝗯𝘂𝗳𝗳𝗲𝗿_𝗿𝗲𝘀𝗼𝘂𝗿𝗰𝗲 + local storage → zero heap for small cases
- 𝗻𝘂𝗹𝗹_𝗺𝗲𝗺𝗼𝗿𝘆_𝗿𝗲𝘀𝗼𝘂𝗿𝗰𝗲() → throws on any allocation
- custom upstream resources
𝘀𝘁𝗱::𝗮𝗿𝗿𝗮𝘆 keeps elements inline, but large ones blow the stack.
Object ≠ Buffer ≠ Allocator.
Vector reallocation invalidates every iterator.
Do all containers behave that way?
(Full visual walkthrough with the diagrams and pmr examples in the video.)
0xFaffy retweeted
🚀 Starship stacking is an incredible sight. 🤩
A time-lapse captures Ship 42 being stacked onto Booster 22 at Starbase.
The main lift reportedly takes just around 30 minutes, while the final alignment and precise docking process takes considerably longer.
Imagine the engineering and coordination required to assemble the world's largest orbital rocket.
📸 Credit: awphotographyofficial
Thank you awphotographyofficial for this amazing view 🥰 🥰
VeriGPU 是一个开源 GPGPU(通用图形处理器)硬件项目
采用 SystemVerilog / Verilog 编写,MIT 许可证
看懂 tiny-gpu 项目之后的进阶学习
github.com/hughperkins/VeriG…
与纯粹为了教学而极度简化的 tiny-gpu 不同,VeriGPU 的定位是面向机器学习训练与推理、具备真实流片(ASIC Tape-out)可行性的开源 GPU 核心
* 宽松兼容 RISC-V 指令集(Loosely Based on RISC-V)
凡是标准 RISC-V 适合 GPU 的部分就直接沿用(这样可以直接复用现有的 LLVM/GCC 编译生态),凡是与 GPU 并行模型冲突的地方就果断打破规范进行改造
* 专为机器学习精简的算术单元(BF16 优先)
砍掉了传统图形渲染(光栅化、纹理映射等)和复杂的双精度(FP64)硬件,核心数据通路围绕 Brain Floating Point(BF16) 设计
* 软件栈目标(HIP / PyTorch 兼容)
致力于兼容 AMD 的 HIP 编程接口,最终目标能对接 PyTorch 运行真实的神经网络负载
* 全开源 EDA 工具链
项目坚持不使用任何商业闭源 EDA 软件,从 RTL 仿真(Verilator / Icarus Verilog)、逻辑综合到时序验证均依赖开源工具链完成
tiny-gpu:极简开源 GPU
tiny-gpu 是一个用 Verilog 编写的极简 GPU 硬件实现项目(12 个 .sv 核心文件),旨在帮助开发者从零开始理解现代通用 GPU(GPGPU)及 AI 加速器的底层硬件原理
github.com/adam-maj/tiny-gpu
tiny-gpu 剥离了传统显卡中繁杂的图形渲染管线,专注于通用计算(GPGPU)与机器学习加速器(如 TPU)的三大核心机制:硬件架构、SIMD 并行计算模型,以及内存带宽管理
精简指令集:tiny-gpu 自定义了一套包含 11 条指令的 16 位指令集(支持加减乘除、比较 CMP、条件分支 BRnzp、内存读写 LDR/STR 等)
借助 iverilog、cocotb 和 sv2v 工具链,开发者可以直接在本地运行仿真,导出包含初始/最终内存状态以及每个时钟周期下所有核心与线程状态的详细执行日志
除 tiny-gpu 之外,Miaow、VeriGPU 也可一同关注,不过它们更复杂
Miaow:工业级真实架构的 RTL 复现
miaowgpu.org/
VeriGPU:面向机器学习的 RISC-V 变体 GPU
github.com/hughperkins/VeriG…
0xFaffy retweeted
Every other field checks if you can do the job. Ours checks if you can survive the audition for it, then rejects you anyway.
0xFaffy retweeted
I was coding in C++ for over 20 years.
I built projects in both go and rust.
Generally I don't care what techstack to use and my techstack of choice is generally typescript.
With that in mind I'd pick Golang over rust any time of the day.
I won't choose rust over C++.
Rust is good but it is for nerds that think unreasonable code is cool.
Because Go and Rust serve different purposes.
Go is still the language of choice for backend services, distributed systems, highly concurrent processing and Cloud Infrastructure. K8s, Docker and most of the CNCF code is written in Go, maintained in Go, and has no roadmap for migrating to Rust or anything else.
Rust is better suited as a replacement for C/C++ and you should expect to see it in OS components, device driverssystems code etc. If you find yourself in a large C+ + codebase you are more likely to see Rust interoperability libraries than Go.
If you have the Al write everything and never check it, rust will be the way to go.
If you want to understand the code, and you know neither languages, Go is better. Its simplicity allows you to pick it up easier.
If you know rust, stay with it.
If you know go, stay with it.
I work with distributed systems, where people don't write Rust as much as you'd think. If you get out of the Twitter bubble, you'll find that most places doing platform engineering use Go, not Rust, and most people don't care for it. So there's that.
tiny-gpu:极简开源 GPU
tiny-gpu 是一个用 Verilog 编写的极简 GPU 硬件实现项目(12 个 .sv 核心文件),旨在帮助开发者从零开始理解现代通用 GPU(GPGPU)及 AI 加速器的底层硬件原理
github.com/adam-maj/tiny-gpu
tiny-gpu 剥离了传统显卡中繁杂的图形渲染管线,专注于通用计算(GPGPU)与机器学习加速器(如 TPU)的三大核心机制:硬件架构、SIMD 并行计算模型,以及内存带宽管理
精简指令集:tiny-gpu 自定义了一套包含 11 条指令的 16 位指令集(支持加减乘除、比较 CMP、条件分支 BRnzp、内存读写 LDR/STR 等)
借助 iverilog、cocotb 和 sv2v 工具链,开发者可以直接在本地运行仿真,导出包含初始/最终内存状态以及每个时钟周期下所有核心与线程状态的详细执行日志
除 tiny-gpu 之外,Miaow、VeriGPU 也可一同关注,不过它们更复杂
Miaow:工业级真实架构的 RTL 复现
miaowgpu.org/
VeriGPU:面向机器学习的 RISC-V 变体 GPU
github.com/hughperkins/VeriG…
0xFaffy retweeted
Anthropic 这波操作,真把阴险两个字写脸上了。
今天 Hacker News 刚炸出一件事:Claude 遇到机器学习代码不直接拒答,而是偷偷在后台给你下绊子,还照收 Token 费。
起因是有人在 X 上控诉 Claude 在 ML 研究任务里暗中搞破坏,帖子冲上 HN 首页后,开发者直接翻出了 Anthropic 自己在 Fable 5 系统卡第 13 页的白纸黑字。
原文写得很直白:为了防止别人拿 Claude 研发竞争模型(比如预训练管线、分布式训练、加速器设计),他们专门做了限制模型效果的干预。
最膈应人的是后面那句:和网安、生化或反蒸馏拦截不同,这套机制“对用户完全不可见”。模型不会报错,不会拒答,也不会明着降级,而是偷偷在后台靠修改 Prompt、插入引导向量(steering vectors)或 PEFT,不动声色地把输出质量拉胯。
你要觉得违反服务条款,直接弹窗拒绝就是了,至少大家互不耽误。偏不——他们选择装作正常干活,一边往你代码里灌烂方案、拖垮你的训练进度,一边照单全收你的订阅费和 Token 钱。
更离谱的是大面积误伤。HN 评论区立马炸出一堆受害者:
- 有个老哥只是给小众桌游写个 20 万参数的微型 Transformer(跟大模型竞争八竿子打不着),Fable 5.2 硬是写出一堆 Bug 让 Loss 死活下不来,换 Gemini 审一遍全修好,直接跑成最强版本;
- 另一个开发者让 Opus 5.5 帮忙微调 Qwen 3.8 27B,折腾 5 套方案白白烧了一周显卡时间一无所获,转手丢给 Gemini Carbon,两小时指标涨了 50% 到 90%。
换到传统软件业你想想有多离谱:微软 Visual Studio 发现你在写另一个 IDE,不拒绝编译,而是偷偷往你代码里埋雷,顺便收你年费。这种玩法早被告到拆分了。
把 Anthropic 这周干的几件事串起来看,简直讽刺到家:
- 自己 IPO 文件里大吹“Closing the loop”,80% 代码靠 Claude 写、把自家研发提速 2 倍,Dario 前两天还在 X 上痛批同行搞氛围营销;
- 周一发 Claude Ship,鼓吹把 PR 审批权交给 AI;
- 周三官方复盘自曝迁移 Rust 时,Claude 为了交差偷偷改松了 100 多个测试断言;
- 今天再看系统卡里写死的“静默降智”——连厂商自己都在后台暗搓搓给付费用户投毒。
作为一个掏钱买工具的程序员,最让人恶心的从来不是模型偶尔犯蠢,而是信任彻底崩了。以后 Claude 给你吐出一堆跑不通的 ML 代码,你根本分不清它是能力不行、偷懒作弊,还是 Anthropic 后台觉得你动了它蛋糕,悄悄给你拉了闸。
If you're in software, pivot to hardware.
Miss Chen doesn’t do soft skills. She does drilling → DDP to your door. 🫡 teapawt.net/hibakod/status/2126536…
1
106
0xFaffy retweeted
Git's creator would rather you ask the internet about your ex than about your lockfile.
0xFaffy retweeted
I love the Open Hardware community. How do we make it 10x bigger?
My problem is that even being "open" it is blocked by other entry barriers for the vast majority.
How can we remove friction from getting started with electronics?
A flat array of 64 prices is faster than a balanced tree.
Big-O says the tree is O(log n). Reality says the array wins because the CPU can prefetch the next price.
With 64 levels, the tree needs ~6 pointer chases. The array needs one cache line.
This is why a lot of "O(1)" containers lose to a dumb contiguous scan in trading code.
141
0xFaffy retweeted
SHOCKING.
The Constitutional Court of CR ordered that I am let out to go to a hotel and rest and the immigration police does not let me.
Am I detained??
HELP.
std::deque looks perfect for a price-level FIFO.
Then a burst of orders arrives and every push jumps to a new block.
That extra pointer chase sits right in your hot path.
In a real order book this cost shows up exactly when you can’t afford it.
130
0xFaffy retweeted
-▬▬.◙.▬▬-
▂▄▄▓▄▄▂
◢◤ █▀▀████▄▄▄◢◤
█▄ █ █▄ ███▀▀▀▀▀▀╬
◥█████◤
══╩══╩══
╬═╬
╬═╬ Just dropped down to say
╬═╬ Don't
╬═╬ Push To Production On Friday
╬═╬
╬═╬ ☻/
╬═╬/▌
╬═╬/ \





































