工具与资源github.com
Nuklear:单头文件的 ANSI C 图形界面库
Nuklear: A single-header ANSI C GUI library
2016 — 2018,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
Nuklear 是一个用 ANSI C 编写的即时模式(immediate mode)GUI 库,全部代码放在单个头文件中,不依赖外部库,可对接 OpenGL、Direct3D、SDL、GLFW 等多种后端。它体积小、可嵌入,适合做工具类界面和自定义渲染管线的项目。
为什么经久不衰:单头文件、零依赖的设计让它极易被拷进任何 C/C++ 项目,多年来一直是轻量级嵌入式 GUI 和工具界面的常用选择。
HN 评论精选
质疑单头文件库的设计动机与代价。
我真的不理解为什么“单头文件”会被当成优点,但我看到越来越多的库这样做。把所有代码都塞进头文件里的理由是什么?
zevv查看英文原文
I really do not understand why 'single header' is considered a good thing, but I see this more and more often on libraries. What is the reason all the code is put in the header file?
怀疑零平台依赖的说法,并认为单头文件反而增加编译负担。
看起来挺酷,但“没有平台相关代码”这个说法肯定不成立——要么它自己带,要么依赖别人带。因为它全在一个文件里,而我当时在用 iPad,就没去分辨是哪种情况。把实现藏在头文件里的吸引力在哪?这现在是潮流吗?每个包含它的文件都要读进那 1.5 万行,还得在某个源文件里加个特殊的 #define 才能避免多出一个 C 文件。这笔交易在我看来不划算。如果我在项目里用它,第一件事就是把它编译成静态库。
richard_todd查看英文原文
It looks cool, though the claim about having no platform dependent code must be false... either they have it or they depend on someone who does. Since it's all in one file and I'm on an iPad right now, I didn't try to discern which case it is. What is the appeal of the implementation hiding in the header file? Is it a 'thing' nowadays? It makes every file that includes it read all 15k lines, and makes you put a special #define in one of your source files, just to avoid having a C file. That doesn't feel like a good trade-off to me. If I used this code in a project, I'd build a static library out of it first thing, and go about my business.
批评 API 里硬编码像素尺寸,缺乏 DPI 抽象。
遗憾的是函数调用里直接指定像素值。如果真做了抽象,应该有一个任意的“尺寸单位”,由胶水代码在后端换算。在一个用户用 1366x768、她邻居用 4K 屏的世界里,无论 Web 还是桌面,界面代码都不该预先写死像素尺寸。
stonogo查看英文原文
Shame that you specify pixels in the function calls themselves. If it were really abstracted, it would have an arbitrary 'size unit' which the glue code could translate on the backend. In a world where one user has a 1366x768 screen and her neighbor has a 4k display, we need to move past interface code specifying pixel sizes up front, both on the web and off.
推荐同类即时模式 GUI 库 Dear ImGui 作为替代。
一个替代方案(用 C++ 写,但保持 C API):https://github.com/ocornut/imgui
atemerev查看英文原文
An alternative (in C++, but with C API maintained): https://github.com/ocornut/imgui
历次讨论
同类还值得读
直接在浏览器中启动 Linux 内核
Boot a linux kernel right inside your browser.
Fabrice Bellard 的 JSLinux 页面,用 JavaScript 在浏览器里启动一个 Linux 内核,并提供一个可交互的终端环境。
工具与资源上首页 5 次 · 2011–2025bellard.orgHacker News 未公开功能与行为清单(2018)
A List of Hacker News's Undocumented Features and Behaviors (2018)
数据科学家 Max Woolf 整理的 Hacker News 未公开功能与行为清单,涵盖投票机制、排名算法、账号惩罚等社区运作细节。
工具与资源上首页 5 次 · 2019–2025github.comMapSCII:在终端中用盲文和 ASCII 渲染地图
MapSCII – Braille and ASCII map renderer for the console
MapSCII 是一个在命令行终端里渲染地图的开源工具,用盲文字符和 ASCII 字符把地理数据画成可交互浏览的字符地图。
工具与资源上首页 5 次 · 2017–2025github.com顶尖大学的免费在线课程
Free Online Courses from Top Universities
Open Culture 整理的一份免费在线课程合集,汇集了全球顶尖大学(如 MIT、斯坦福、耶鲁等)向公众开放的网络课程资源,涵盖音频、视频等多种形式。
工具与资源上首页 5 次 · 2010–2022openculture.com淘气字符串:容易引发用户输入问题的字符串清单
Naughty Strings: A list of strings likely to cause issues as user-input data
一个 GitHub 仓库,收录了大量容易让程序出问题的用户输入字符串,如特殊字符、emoji、SQL 注入片段、系统命令等,供开发者用于测试输入处理逻辑。
工具与资源上首页 4 次 · 2015–2020github.com