Remix.run Logo
groundzeros2015 10 hours 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 9 hours ago | parent | next [-]

When 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 9 hours ago | parent | next [-]

I 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 9 hours ago | parent | next [-]

C 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.

neomantra 3 hours ago | parent | next [-]

The 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.

uecker 7 hours ago | parent | prev | next [-]

I 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 5 hours ago | parent | prev [-]

> 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

sfpotter 7 hours ago | parent | prev | next [-]

C'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

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 6 hours ago | parent | prev | next [-]

Unironically 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 5 hours ago | parent | prev [-]

> 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 8 hours ago | parent | prev | next [-]

SQLite 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.
nine_k 7 hours ago | parent | next [-]

The sqlite3.c file is generated from more finely-grained real sources, see https://www.sqlite.org/src/doc/trunk/README.md

qznc 7 hours ago | parent | prev | next [-]

SQLite 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

kvemkon 7 hours ago | parent [-]

Yes, that's why I've asked about possible rust support of creating such version of normal project. The main issue, I'm unaware of comparably large rust projects without 3rdparty dependencies.

nine_k 7 hours ago | parent [-]

From my daily-use utilities, ripgrep and bat seem to have zero dependencies.

kzrdude 5 hours ago | parent | next [-]

I believe ripgrep has only or mostly dependencies that the main author also controls. It's structured so that ripgrep depends on regex crates by the same author, for example.

kvemkon 7 hours ago | parent | prev [-]

Looking at Cargo.toml, ripgrep seems to have some dependencies and bat has a lot.

7 hours ago | parent | prev [-]
[deleted]
8 hours ago | parent | prev [-]
[deleted]
pjc50 9 hours ago | parent | prev | next [-]

This 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 8 hours ago | parent [-]

Yeah, "Step 1: draw 2 circles. Step 2: draw the rest of the fucking owl"

nxobject 9 hours ago | parent | prev | next [-]

I 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...

benterix 9 hours ago | parent | prev | next [-]

Because he choose the hardest path. Difficult problems, no shortcuts, ambitious, taking time to complete. Our environment in general is the opposite of that.

groundzeros2015 8 hours ago | parent [-]

We 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.

rramadass 16 minutes ago | parent | prev [-]

> 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 :-(