drschwabe 19 hours ago

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.

  • kvemkon 18 hours ago

    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.
  • zdragnar 19 hours ago

    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 19 hours ago

      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 12 hours ago

        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 17 hours ago

        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.

    • sfpotter 17 hours ago

      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 16 hours ago

      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 15 hours 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?

  • [removed] 18 hours ago
    [deleted]
pjc50 18 hours ago

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 18 hours ago

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

nxobject 19 hours ago

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 19 hours ago

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 18 hours ago

    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.

noufalibrahim 8 hours ago

He'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?

rramadass 10 hours 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 :-(