5 ms·
For all the praise he gets here, few seem interested in his methods: writing complete programs, based on robust computer science, with minimal dependencies and
by groundzeros2015 10mo ago
For all the praise he gets here, few seem interested in his methods: writing complete programs, based on robust computer science, with minimal dependencies and tooling.
- drschwabe 10mo agoWhen I first read the source for his original QuickJS implementation I was amazed to discover he created the entirety of JavaScript in a single xxx thousand line C file (more or less). That was a sort of defining moment in my personal coding; a lot of my websites and apps are now single file source wherever possible/practical.
- zdragnar 10mo agoI honestly think the single file thing is best reserved for C, given how bad the language support for modularity is. I've had the inverse experience dealing with a many thousand line "core.php" file way back in the day helping debug an expressionengine site (back in the php 5.2ish days) and it was awful. Unless you have an editor which can create short links in a hierarchical tree from semantic comments to let you organize your thoughts, digging through thousands of lines of code all in the same scope can be exceptionally painful.
- antirez 10mo agoC has no problems splitting programs in N files, to be honest. The reason FB (and myself, for what it is worth) often write single file large programs (Redis was split after N years of being a single file) is because with enough programming experience you know one very simple thing: complexity is not about how many files you have, but about the internal structure and conceptually separated modules boundaries. At some point you mainly split for compilation time and to better orient yourself into the file, instead of having to seek a very large mega-file. Pointing the finger to some program that is well written because it's a single file, strlongly correlates to being not a very expert programmer.
- uecker 10mo agoI split to enforce encapsulation by defining interfaces in headers based on incomplete structure types. So it helps me with he conceptually separated module boundaries. Super fast compilation is another benefit.
- lelanthran 10mo ago> complexity is not about how many files you have, but about the internal structure and conceptually separated modules boundaries. You probably don't need this, but ... https://www.lelanthran.com/chap13/content.html https://www.lelanthran.com/chap13/content.html
- neomantra 10mo agoThe file granularity you chose was at the perfect level for somebody to approach the source code and understand how Redis worked. It was my favorite codebases to peruse and hack. It’s been a decade and my memory palace there is still strong. It reminded me how important organization is to a project and certainly influenced me, especially applied in areas like Golang package design. Deeply appreciate it all, thank you.
- inopinatus 10mo agoReminds of one time when I was pair programming and the other chair said “let’s chop this up, it’s too long” and when I queried the motivation (because I didn’t think it was too long), it was something like, “I’m very visual, seeing the file tree helps me reason about internals”. Fair enough, I thought at the time, whatever makes us more productive together. On reflection, however, I’m unsure how that goes when working on higher-order abstractions or cross-cutting concerns that haven’t been refactored, and it’s too late to ask.
- sfpotter 10mo agoC's support for modularity is actually rather strong. This PDF gives a good overview of the basic techniques available: http://www.metamodulaire.org/Computing/modular-c.pdf http://www.metamodulaire.org/Computing/modular-c.pdf It may not be immediately obvious how to approach modularity since it isn't directly accomplished by explicit language features. But, once you know what you're doing, it's possible to write very large programs with good encapsulation, that span many files, and which nevertheless compile quite rapidly (more or less instantaneously for an incremental build). I'm not saying other languages don't have better modularity, but to say that C's is bad misses the mark.
- drschwabe 10mo agoUnironically JavaScript is quite good for single file projects (albeit a package.json usually needed) You can do a huge website entirely in a single file with NodeJS; you can stick re-usable templates in vars and absue multi-line strings (template literals) for all your various content and markup. If you get crafty you can embed clientside code in your 'server.js' too or take it to the next level and use C++ multi-line string literals to wrap all your JS ie- client.js, server.js and package.json in a single .cpp file
- lelanthran 10mo ago> I honestly think the single file thing is best reserved for C, given how bad the language support for modularity is. You don't program much in C, do you?
- kvemkon 10mo agoSQLite 3.51.1 $ wc -l ... 265908 sqlite-amalgamation-3510100/sqlite3.c Is there any as large as possible single source (or normal with amalgamation version) more or less meaningful project that could be compiled directly with rustc -o executable src.rs? Just to compare build time / memory consumption.
- qznc 10mo agoSQLite is only deployed as a single file but the original sources are multiple files. They call it "The Amalgamation". https://sqlite.org/src/doc/trunk/README.md https://sqlite.org/src/doc/trunk/README.md
- nine_k 10mo agoThe sqlite3.c file is generated from more finely-grained real sources, see https://www.sqlite.org/src/doc/trunk/README.md https://www.sqlite.org/src/doc/trunk/README.md
- deleted 10mo ago[deleted]
- benterix 10mo agoBecause he choose the hardest path. Difficult problems, no shortcuts, ambitious, taking time to complete. Our environment in general is the opposite of that.
- groundzeros2015 10mo agoWe spend a lot of time doing busy work that's part of the process but doesn't actually move the needle. We write a lot of code that manages abstractions, but doesn't do a lot. All of this busy work feels like progress, but it's avoiding the hard work of actually writing working code. We underestimate how inefficient working in teams is compared with individuals. We don't value skill and experience and how someone who understands a problem well can be orders of magnitude more productive.
- nxobject 10mo agoI agree: he loves to "roll your own" a lot. Re: minimal dependencies - the codebase has a software FP implementation including printing and parsing, and some home-rolled math routines for trigonometric and other transcendental functions. Honestly, it's a reminder that, for the time it takes, it's incredibly fun to build from scratch and understand through-and-through your own system. Although you have to take detours from, say, writing a bytecode VM, to writing FP printing and parsing routines...
- pjc50 10mo agoThis is like Feynman's method for solving hard scientific problems: write down the question, think very hard, write down the answer. It doesn't necessarily translate to people who are less brilliant.
- chrisweekly 10mo agoYeah, "Step 1: draw 2 circles. Step 2: draw the rest of the fucking owl"
- rramadass 10mo ago> few seem interested in his methods: You are absolutely wrong here. Most of us wish that somebody would get him to sit for an in-depth interview and/or get him to write a book on his thinking, problem-solving approach, advice etc. i.e. "we want to pick his brain". But he is not interested and seems to live on a different plane :-(
- noufalibrahim 10mo agoHe's one of my programming heroes but that's based purely on the sheer volume of high quality output he has. Can you elaborate a little about the methods you mention and how you analysed them?
- groundzeros2015 10mo agoSure. You’ll notice no libraries, no CI, no issue tracker, written in C, no landing page, no dashboard. So much of the discussion here is about professional practice around software. You can become an expert in this stuff without actually ever learning to write code. We need to remember that most of these tools are a cost that only benefits for managing collaboration between teams. The smaller the team the less stuff you need. I also have insights from reading his C style but they may be of less interest. I think it’s also impressive that he identifies a big and interesting problem to go after that’s usually impactful.
- noufalibrahim 10mo agoThanks for this. I'd appreciate your insights about his C style as well. I'm a lapsed C programmer myself.