Hacker News new | past | comments | ask | show | jobs | submit login
As I retire, my goal now is to release 40+ years of source code (themindfactory.com)
1227 points by elvis70 on Nov 3, 2023 | hide | past | favorite | 323 comments



I'm taking a look through DOSUTIL.ZIP and I love all these simple elegant C programs. A lot of these programs somehow only manage to have 1-2 standard c #include lines. How often do you see that? I also love how, out of 20,000 lines of C code, there only exists 24 #if statements. This is how C programming was meant to be. Reading codebases like this is one of the things I drew inspiration from when I started working on Cosmopolitan Libc.


If your build targets are 1 then that saves you a lot of #if macros.


You are replying to someone who builds C programs for 6 OS and 2 architectures without an #if ;)


Love a great “do you know who you’re dealing with” HN moment.

Justine’s APE [0] project is one of the few things to induce in me true, nostalgic, nerdful glee in the last few years.

[0] https://justine.lol/ape.html


Ahh geez. I see stuff like this going on in the background and I wonder what I'm even doing in my life, pushing pencils in comparison to actually, truly solving problems.I'd love to tackle more stuff like this, but I feel trapped chasing what I need to pay the bills (said pencil pushing).

At the same time, companies seem so quick to layoff that I question how I even grow to the point where I'd be trusted with such problems. Do I really just need to do a 2nd full time duty in the open source community to get that growth?


The perpetual inner turmoil for talented engineers :). I accepted a while ago that there's more to life than coding and career, so I don't do much outside of work - 40-50 hours a week of engineering is enough for me. But I try to focus on getting the best job possible that fits what I like to do.

Obviously spending 20+ hours a week on interesting OSS is going to get you more interesting roles over time, and generally OSS stuff is way more fun because you can pick what interests you. But you have to decide if it's worth the cost - do you really want to spend 60 hours+ a week just doing coding / engineering? Maybe you do, but in that case you'd probably be doing it already.


I rarely write code after work for my own use. or others. I spend time with my family. A family that started by me realizing there was more to life than billing clients 14 hours a day.

It's ok to not be building some new thing in your off hours. That's a choice they made for their own reasons. Doing what you do is also a choice and both are valid.


Go indie on the side then full time


I've definitely thought about it and I imagine it's my end game. But I'm hesitant if I'm truly ready and have the right skills for that. Would that self growth be better than contributing to something larger first (perhaps building more connections on the way)?


At some point, you’re just gonna have to go for it. Jump in and see what happens.


Contributing to OS I’m not sure what that’s a path to exactly


There's Many intentions behind it. In rough order of importance;

- working on a medium-large repo size exercises more skills than just jumping into anything alone. Growth is my biggest factor for the next few years.

- OS introduces me to a community of passionate devs. Who can be anything from mentors to expand my horizons, to friends to future contacts.

- I'd choose to contribute to tools I would probably use for my own projects. So I can dig into repos early and know it intimately for the time I'd need to branch for my own project

- potential clout in certain communities can open other doors.

- Resume material is never bad if everything else falls through

It's not my end game but I think it'll help in many ways. And Personally I always had a certain respect for the OS community and want to give back, and hopefully pay if forward. .


Good luck. Most OS contribution is thankless and leads nowhere so be careful with your time and timidity

I contribute to repos I use in my projects, but I’d never start with them before actually finding a use for them


I'll keep that in mind. Maybe it will be yet another venture of "I want to connect with people but no one else does" but nothing ventured...

And it would be a soul crushing world if I simply submitted to the fact that we're more connected than ever, but simultaneously I can't find literally anyone else to connect with without money being involved. I have at least a good decade in my heart left to fight that mentality.


Make money (without wages), then you have ownership of your time for pursuing interests


That's the hopeful end goal. I unfortuntately need a lot of time and learning to make a product worth paying for, though. being self-sufficient is liberating but terrifying unstable in the beginning. Need to establish proper safeaguards first.


It might be easier/quicker than you think


any skills you lack you can hire for. Do it!


If you don't try, you'll never find out.


> pushing pencils in comparison to actually,

> truly solving problems

By picking a problem you have a vested interest in, you'll get further than solving someone else's problems in which you don't


If you are not living the life you want then you are a failure. Face the reality of your situation. While others do what they want you do what you are "supposed" to do, and you know how this feels. Good luck.


> If you are not living the life you want then you are a failure.

What a rude and profoundly dumb statement. Are all the ones who bust their arses out of necessity failures or do they simply want to endure pain? Caring for a handicapped child, parent, being trapped in a poor country, etc.

I'd be curious to know where most of you around here who put desires above all else are coming from.


I don't understand where you are coming from. I've met cab drivers in the third world that are successful, because they live the life they want. I've met investment bankers in the first world that are failures, they are rich but can't do what they want because "N reasons", trapped as you put.

A parent that cares for a disabled child is only a failure as long as he does not want to do it but has to. In this case he is not only a failure but a horrible person.

I volunteer to care for old people 1h per month and I do not consider this a burden or entrapping or nothing like that. In fact I've met my first wife like this.


> A parent that cares for a disabled child is only a failure as long as he does not want to do it but has to. In this case he is not only a failure but a horrible person.

> I volunteer to care for old people 1h per month

I'm sorry, it does not render what you're doing irrelevant, but the comparison is laughable.

Caring for a disabled children is a full time job. I can't imagine that most were hoping to be in that situation when they conceived. It doesn't prevent them from being good carers for the child they love. If you meet some of these parents, ask them. Then you can tell them they are horrible people because as opposed to them you voluntarily go to chat with an oldie for 1h a month.

Have some empathy.


>A parent that cares for a disabled child is only a failure as long as he does not want to do it.

I’ve seen the parents of severely disabled children. The daily work, financial cost, and social cost is immense. They don’t give up their children often out of duty and sympathy not because they ever wanted to live a life like that. They are burdened and entrapped and it’s not simply a matter of mindset.

Not even the disabled children would be keen to agree with you that their self-sacrificing parents are failures and horrible people if they feel they’ve been burdened and entrapped. THEY feel burdened and entrapped themselves. People in a bad situation can sympathize with people’s circumstances for what they are. They might resent the parent being open about their feelings, but not for having them at all.

As for why the 3rd world cab driver does not feel this way, a cab driver in the third world is often doing relatively well compared to their peers, they may have grown up in worse circumstances, and cab driving is something relatively easy to give up for a few years and then pick back up no worries. That’s not nessecarily true of the investment banker or the parent of the disabled child.


This sounds rather stoic. But people do not all have the same philosophy of life.

Your definition of what constitutes a "failure" doesn't have to be the same as someone else, and that's OK.


I agree with that, and I am comfortable with the prospect of others not putting themselves first, therefore opening up the possibility of them putting my interests first.


>If you are not living the life you want then you are a failure.

"For what it’s worth... it’s never too late, or in my case too early, to be whoever you want to be. There’s no time limit. Start whenever you want.... I hope you live a life you’re proud of, and if you’re not, I hope you have the courage to start over again."

My courage definitely wavers, but the stuff I'm "supposed" to do will hold me back if I try to what I want first. If I can't do that first, I'll at least set the breadcrumbs as I climb out of that pit.


Here's an alternate framing for you: if you are living the life you want, then you are a failure. You have settled, you have ceased to strife, you're no longer growing and evolving and aspiring.

It's a condition of certain kinds of life, to tolerate unbearable dissatisfaction. Many things have come from this drive, many astonishing people have shared it, and they'll never settle. They'll die still not 'done', their dreams unreached… because those dreams were able to scale, those stars remained beyond their reach.


> If you are not living the life you want then you are a failure.

Nah, not how it works.


Ok but sidenote, that Greek-letter titling is emotionally upsetting, even if the title is SR-accessible (κύδος for that though).


Yeah I read it as "Astmally pdrtable echesmtable". People shouldn't do this.


"Astmally pdrtable echesmtale" is a very aesthetically pleasing name for what this, though. You just made me like it more...


If you're going down that route, make sure to take a look at this source file for it[1], which is an absolute work of art not just for the code but for the artistic presentation, including elaborate inline logos.

[1] https://raw.githubusercontent.com/jart/cosmopolitan/1.0/ape/...


Wow… some think Java is portable… this is so nice!



Also for the casually dressed


I love all of the domain experts and accomplished people hanging out with the rest of us on HN. :)


holy shit!

> In the above one-liner, we've basically reconfigured the stock compiler on Linux so it outputs binaries that'll run on MacOS, Windows, FreeBSD, OpenBSD, and NetBSD too. They also boot from the BIOS. Please note this is intended for people who don't care about desktop GUIs, and just want stdio and sockets without devops toil

they also boot from the BIOS.... does this mean that I can achieve my dream of booting straight into a BBC BASIC emulator on bare metal(ish)?


You might want to take a look at the current no. 2 of the HN best list:

https://news.ycombinator.com/item?id=38101613


thank you so much!

Justine is a genius.


Can cosmopolitan replace the whole llvm toolchain required by GraalVM’s native-image? Currently cross building with native-image is a pain, especially compared to golang. (Or resource intensive as you need to compile it on each platform/architecture you want.)


It’s probably not the best form to abstract away the OS-distinctions, as every abstraction will hide important details from the underlying OS. E.g. certain JDK native methods could be more efficiently done for, say, windows, then through a libc-like abstraction library.


I took a quick look at cosmopolitan.h: https://justine.lol/cosmopolitan/cosmopolitan.h and counted 886 occurrences of "#if" (including #if and #ifdef)


cosmopolitan.h is a concatenated rollup of hundreds of header files, shipped as part of the "amalgamation" variant of our release, and those sub-headers had #ifndef _FOO_H guards at the top and bottom. The rest of the #ifs are required by standards so we don't clobber the user's control of their namespace, e.g. `#ifndef _GNU_SOURCE`. What you won't see is the annoying stuff that checks for CPU, OSes, endianness, etc.


In fairness, my understanding is that APE manages that by making the differences invisible to the application. I'm not sure whether that makes it more or less applicable. (More impressive, obviously, but not simpler)


How? I’d be curious if you have a blog post.


Then you can appreciate how many #if macros it would save if you just targeted 1. ;)


Sounds like it wouldn’t save them a single #if, if they are already at 0…


I know, it was a joke, but it seemed to have very solidly wooshed.


It doesn't count if all your platform code is abstracted away by libraries.


> A lot of these programs somehow only manage to have 1-2 standard c #include lines

Older C compilers will let you get away with a lot of sins which a modern C compiler will (correctly) call you out for.


We can still get away with those sins today if you change C's implicit type from int to long. I modified chibicc to do just that it was a 1 LOC patch. Suddenly I didn't need prototypes anymore and everything just worked without #include lines.


> Suddenly I didn't need prototypes anymore

Under some very old C standards, maybe. But C99 requires that you at least declare a function before calling it.


> C99 requires that you at least declare a function before calling it

Where is that written? Please quote the standard. My reading of ISO/IEC 9899:TC3 is that Foreword says (paraphrasing) "hey, we removed implicit int and implicit prototypes from the standard". So they simply stopped specifying it, but as far as I can tell, the standard says nothing about forbidding them. From my point of view, that means compilers are free to still implement implicit types as a compiler extension to the language, and everyone does, because that extension is needed in order to support the older c89 standard. It would only impact people who want to be able to claim their codebase is c99 standard compliant, because you can't do that if you depend on compiler extensions.


> Where is that written?

ISO/IEC 9899:TC3 [1] §6.5.1 ¶2: "An identifier is a primary expression, provided it has been declared as designating an object (in which case it is an lvalue) or a function (in which case it is a function designator)."

There's even a footnote to underscore this point: "79) Thus, an undeclared identifier is a violation of the syntax."

[1]: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf


Prototypes are required in C23 as part of the expungement of K&R syntax. This also brings harmonization with C++ where an empty parameter list is implicitly void.



But why does it have to be that way though, can't the compiler scan the rest of the code/files and see if a defenition/declaration is present somewhere?

There is no such requirement of a declaration before first call in Java for example?


It's because the C compiler was designed to be single pass, so as to be speedy and require less memory on the systems of it's time.


I suppose you could just create a ".d" file standard that doesn't have that requirement but processes into a ".c" file that has the necessary prototypes. You could probably also auto-insert all the #if'n'def nonsense automatically and skip it in the ".d" files.

Kind of like how the JavaScript dudes all use this ".ts" stuff now for convenience that processes into ".js"


Just to be a little picky, but if you want “convenient” then just stick with pure JS - it’s overly forgiving and simple. TypeScript is lovely and I much prefer it over JS, but having to type _everything_ is far from convenient imo


Isn't Typescript gradually typed?


It is! I’ve been working in an environment that essentially requires us to type as we code (rules against using the “any” and “unknown” types) that in just used to them being enforced now lol. So I suppose my point is moot, as the tediousness isn’t forced by the language necessarily.


It's also considered by many to be an antipattern to add a type that is otherwise inferred. For a trivial example,

let x: number = 6;

You should instead allow the compiler to infer where it can and do

let x = 6;

Inference doesn't work across function calls like it does (did?) in Flow, which is a good thing, so those always need to be typed.

If you wanted the type of x to be 6 instead of number, you would use

let x = 6 as const;


The Arduino build system does this (preprocesses your source code to pull out prototypes and put them at the top). To make things easier for beginners.


Like early Pascal compilers, or maybe all of them. Don't know about the latter case (all).


Is that a requirement that is relevant presently? I would say not so much. Do modern C compilers also make only a single pass?


Yes. Gcc throws errors like hell with c files which have the definitions after functions.


Modern compilers still have to follow the rules of the language.


Yes, but is the constraint that compiler shall make only a single pass, a rule of the language?


Prior to C99 (i.e., in C90), there was a rule that any undeclared identifier id that was followed by a function call parenthesis would be treated as though there were an implicit declaration in the scope in which it was used like this:

  extern int id();
The empty parentheses meant it could take any number of arguments, since it was declared in the traditional style, where the argument types weren't specified first.

This implicit declaration meant that if it was later defined in the same file as returning a type other than int, the compiler wasn't permitted to go back up in the file and treat the function call as though it returned a type other than int.

This requirement was removed in C99, but in practice, compilers kept doing it for backwards compatibility, even when not invoked in C90 mode.


What I understand is the preprocessor causes issues where you could do that maybe 99.9% of the time, especially with well written code. But it'd fail that 0.1% of the time.

You do have analyses like ctags. In theory the compiler could use ctags to find definitions in source code. My experience is ctags can get confused. It's possible in a set of files to have multiple implementations of a function and ctags can't tell which one is used. And I see cases where it can't find definitions.

Personally I'd be happy if the compiler tried to find a missing definition using ctags and issued a warning.

I have wondered if adding funct, public, private keywords to the language might allow the compiler to reliably find function and stuct definitions in source files.


Good question.


The fact that I'm calling a function, it must exist, otherwise the compiler will throw an error ("undefined reference to function"). So forward declarations is just needless typing.


> The fact that I'm calling a function, it must exist

That's not necessarily true. It's possible that the symbol is a function pointer; calling a function pointer requires slightly different code generation. Compare the generated code between:

  void fn(void);
  void call_fn(void) { fn(); }
and

  void (*fn_ptr)(void);
  void call_fn_ptr(void) { fn_ptr(); }
In practice, it's probably a function, and that's what the compiler assumes if there's no declaration to go off of. But we all know what happens when you make assumptions.


Making no assumption on safety, just stating that forward declarations are superfluous.


no they are not. but >The fact that I'm calling a function, it must exist, otherwise the compiler will throw an error ("undefined reference to function")

you mean the linker will throw an error. The linker is trying to link together the "references" be they forward or backward, that the compiler has created, and the compiler needs to have generated the right references, round peg round hole, square peg square hole.

You don't want your linker throwing errors, it doesn't have the context the compiler does; and you don't want to turn the linker into ChatGPT that can converse with you about your source code, just use the C version of forward references which are not particularly forward, they just say "I don't know where this is defined, it's just not defined here, but we know it's a square peg"

For example, there are architectures where space is tight (embedded for example) and nearby things can be called more efficiently than far away things, so the compiler needs to generate as many near calls as it can, falling back to far away when it has to. It doesn't know in advance how far away things are going to be, but it might uncover plenty of near things as it goes. Square pegs, round pegs.

when you recompile your project code, the library code, is not necessarily around. When other people recompile their library code, your project code isn't around. What's the size of what's being put on the stack? Still gotta get the square/round pegs right.


I know why it exists. It’s still superfluous to most use cases. Don’t force me. Require it when you can’t figure it out.


"long far pascal", et al, anyone?

Win32 C code from way back.

Heh.


The compiler needs to see it to know how to call it.


In which case, it needs to keep parsing the include tree until it finds it. I know why it exists. I’m just not happy about duplicating code. Other compilers are smarter than this.


If you're using a modern IDE, clangd can be configured to automatically insert #include statements (--header-insertion=iwyu).


The thing I hate about this is that it really has no idea what a “public” header is. If I have it on I’ll use something like uintptr_t and get a random include for <__bits/std/uintptr.h> or something that I don’t want. I assume there’s like some manual auditing one can do to go “don’t peek through stdint.h” but either nobody does this reliably or it doesn’t work.


A little bit of advice like that is a tremendous blessing to those of us who just need to touch C occasionally.


I haven't looked that deeply, but I don't see many sins in this source code, either, except for the K&R style, weird formatting and doing too much in one line, like this line in the file CAT.C:

  if(*(Ptr = argv[i]) == '-') {

Older C compilers did let you get away with more, like using integers as pointers, and dereferencing pointers as though they were struct pointers when they aren't. But I don't see that in this code.


The "sin" I was referring to was calling undeclared functions -- which is how there are so few #include directives in much of this code. Most of the files I looked at include <stdio.h> (probably required for variadic arguments on printf-type functions) and <file.h> (for the FILE type), and call other functions blindly.


That does make sense. My bad, I should have looked closer and noticed the implicitly defined functions.

It's not even a good idea to do that on modern computers, because implicitly declared functions do type promotions from float to double and char/short to int, and on the System V ABI, it has to pass in the number of floating point arguments there are in register eax.


It's not a good idea to do that in production code. FTFY. If you're writing research, experimental, or one-off programs then it can be a real productivity boon. I say do it for fun. You have a right to enjoy yourself and it'll still come out 10x more readable than Perl at the end of the day, let's be real.


> it'll still come out 10x more readable than Perl at the end of the day, let's be real.

A low bar, really :-P


Wait til you see old Fortran codes.


>Older C compilers did let you get away with more, like using integers as pointers

In older C compilers (maybe pre-ANSI, or later, can't remember), you could literally write i[a] instead of a[i], where a was an array and i was an int, and it would work equivalently, i.e. no compiler error, and give the same result as a[i]. This was because a was the address of the start of the array, and i was an offset, so a[i] actually meant *(a + i), which, by the commutative property of arithmetic, was equivalent to *(i + a), which was equivalent to i[a].

I had read this in some C book, maybe K&R or the Waite Group C Microsoft Bible.

Never forgot it, because it was counter-intuitive, unless you knew the above reason.

And tried it out in one or more C compilers at that approximate period, and it worked as stated.


This is still true, and it's mandated by the ISO C standard that a[i] is equivalent to (*((a)+(i))) (yes, they specify it with that many parentheses). You're still able to compile code that treats a[i] and i[a] interchangeably.

https://godbolt.org/z/37Kv44o1b

> I had read this in some C book, maybe K&R or the Waite Group C Microsoft Bible.

I haven't read the Microsoft C Bible, but it does say this in K&R while explaining pointers.


>This is still true, and it's mandated by the ISO C standard ...

Wow, good to know.

>but it does say this in K&R

Then that must be where I had read it.


This still works iirc.


Hmm implicit int conversion


Meanwhile, over here in the Rust mines, I wrote a simple program that is little more than an http listener with a single route.

Cargo pulled in something like 105 dependencies to build it.

Although, as an apples to apples comparison, it does only have 2 use statements.


In case you want to create a simple http listener without dependencies (besides the standard library), the official Rust Book has a tutorial for just that: https://doc.rust-lang.org/book/ch20-01-single-threaded.html


I’m aware, but thank you.


This is a culture problem, not a language problem.

Here is a http health check in 19 lines using only the rust standard library.

https://dpaste.org/f895z


There’s a lot of distance between “reinvent the wheel by implementing all your network functionality using nothing more than sockets” and “download 100 libraries to serve a file over http”.

There’s a happy medium to be had.

I’d also disagree this is not at all a language problem - I think it’s both, in that the language has moved an awful lot of core functionality into the crate ecosystem, where there are a bewildering array of options for almost any need. The resulting explosion in the dependency graph is an entirely foreseeable consequence — partially of that language design decision and partially due to the “npm culture” (for lack of a better description.)


Slighly off topic, but... how is npm culture different from CPAN culture? I have a feeling there is a difference but I'm too unfamiliar with both ecosystems to point it out.


Speaking as someone who used Perl pretty extensively back in its heyday I’d say the difference is CPAN modules were much more likely to be self-contained, or contain a handful of external dependencies, and those dependencies were almost always self-contained.


Aah, that makes a tonne of sense. When you develop an application you're free to pull in any libraries you want, but the libraries themselves should be more careful. For them, it might be worth reimplementing some essentials.


Sure, if you are putting in a health check and nothing else, that's fine. When you need to parse headers, negotiate content types, validate maximum lengths on requests, properly log the source of the request (it's not just the connecting IP if there's a load balancer in front of it), parsing request bodies, dealing with range requests, authentication, cookies, providing a good middleware mechanism...

The list goes on. While I'm not a Rust developer, there's probably hundreds of libraries because the problem is structured into a lot of small parts, and frameworks are expected to be able to satisfy the functionality you expect without needing to bypass it.


As a security engineer it is still usually cheaper to write specific functions I need for highly limited scope applications than pull in libraries I have to review, and review every update to, forever.


I've seen this attitude before. In that specific case, someone tried to not depend on the signal_hook crate and manually (unsafely) implement signal handling… without knowing that there's a ton of pitfalls to it.

(The signal_hook crate even contains documentation on those pitfalls. https://docs.rs/signal-hook-registry/1.4.1/signal_hook_regis...)

I mean sure, reinvent the wheel. But it might do good to at least have an inkling what those 105 dependencies for your http listener did.


The person you are referring to was likely also me. I do not know of anyone other than me trying to code defensively against supply chain attacks in rust. It is a lonely corner.

I ended up going with sigwaitinfo since the attempts you likely saw on matrix which is perfect for my application that will only ever run on modern linux kernels.

Combining that with the stdlib health check above and we end up with a dead simple health checking signal handling service pattern that works well and easy to confirm is free of supply chain attacks.

https://dpaste.org/z1cAz


I should have recognized the username… (Is signal handling even required here?)


And, the meme, for every comment in C or C++ on HN, there is one "but Rust".


we should turn it into a law or somthing...


While we’re making laws, we could add one where, if someone posts something even slightly critical of Rust, the first couple of responses will be from Rust apologists either: a) pointing out how wrong the criticism is, b) how the criticism is mis-directed and shouldn’t be aimed at Rust, or c) how the criticism is really a beneficial and well-thought-out feature, but under absolutely no circumstances admitting that there might be anything wrong with Rust.


No true Rustacean?

:)

https://en.m.wikipedia.org/wiki/No_true_Scotsman

Not sure if that's a good analogy, but put it out there, to see what people say.


This doesn't really surprise me, doing an HTTP service correctly is not actually trivial


Justine, you are one of less than 5 programmers that make me feel envy. Hope to have a coffee or a whiskey with you some day if we ever cross paths. Enjoy your day, you are an inspiration and goals. Both mental goals and presentation goals, which is essentially unheard of.


OTOH, here is a hash table in C implemented entirely as macros. It's super cool: https://troydhanson.github.io/uthash/


Because there were barely any libraries to include back then. If you wanted some functionality, you wrote it yourself. Which was fun, but most of the code pales in comparison to modern libraries that have had years, or decades, or eyes on them improving and testing them. Pre 2000, if you wanted some specific capability, you wrote it yourself!


Looked through the Linux kernel and I was genuinely shocked. Something so simple, easy to read, and improve upon. Makes modern web frameworks seem like spaghetti code. Art vs scrap.


From STYLE.TXT:

  - True=7 -

  Having lots of very low-level code and hardware experience, I developed a bit
  of tendancy to "minimize what can go wrong at low levels" - C treats 0==FALSE
  and !0==TRUE - most people use 0/1 ... but thats only 1 bit "difference".  I
  sometimes use 7=TRUE as thats 3 bits with no more chars to type (and of course
  foolish as such a 1 bit hardware error would "trash" pretty much any system -
  but I do tend to be a creature of habit :)
I have never heard of this convention before! Was "random bitflips messing with your conditionals" a common problem back in the day?


Even if it was, are you really going to think of every conditional as a tri-state boolean?

Or will you assume that one of the branches is safe to execute during failure?

Or will you count the number of bits in each conditional and assume more ones than zeroes is a true, with no error correction? Will you log that a bit has flipped or otherwise alert the operator? Will you consider that as evidence that an int has changed value too?

Will you store ints with three bits per bits also?

Error detecting codes have their place, but it takes more than just saying that true is 7.


No, and the author basically admitted it was silly. My counter would be that it makes the intent less clear. I loved reading through his style doc though and I love that he just threw all this stuff out there. Something in his collection is bound to scratch somebody’s itch.


tangential to 'how can a bit be wrong', when trying to see if a serial data line is working, i write 0xA5 ( 1010 0101 ) to send an alternating bitstream with a twist so i can test the greatest number of things i think can be wrong at once


Except that if you have the bit endian wrong, 0xA5 is the same forward and backward.


that's true! 0xAA 0x55 would work to differentiate that case?


Yes, AA and 55 are common test patterns for a variety of hardware.

Haven't seen A5 in the wild but I suppose it could be useful as a initial "Let's setup a connection" where endianness is unknown. Assuming the next thing that is exchanged is an endian negotiation.


I like to have several sequential ones. Easier to see on the oscilloscope. (I spent last night getting a microcontroller to talk to a SPI device, so I'm still licking my wounds.)


0xAA 0x55 is actually used as the last two bytes in the MBR just for this purpose


Endianness is byte order.


Bit endian is a thing in serial protocols. I had an issue with that when using a microcontroller to talk to an LCD last week.


How would a HNer who's not familiar in those nether regions of computing, but wants to feel the excitement of sending a bitstream over a (possibly faulty!) serial data line, get started? Two Arduinos and a cable maybe?


Personally I would recommend finding fun or useful projects where you have an outcome you really desire. Start simple - one sensor like a bath overflow warner (arduino is good or maybe raspberry pi).

Learning hardware just for the sake of it is tough to keep motivated and perhaps you would never use the skills you learn? Hardware adds a tougher level to debugging - but software experience gives you a fantastic start - a logical mind and rational drilling down.

If you can fix your car you have the skills to start on electronics!

A lot of skilled people grew up through the hardware generations e.g. I began learning basic electronics because on an Apple ][ everything was simpler and we were all at the same stage. My first job was writing low level serial driver code and regularly dealing with serial devices (e.g. on PC). Our modern context is just not the same. The internet is hard to learn from. It is difficult to write good articles to help - the experienced like me just know a huge variety of implicitly learned knowledge.

I suggest you concentrate on a useful or fun outcome - I believe it's good life practice (and good engineering) to stay focused on the outcome and not get too side-tracked by explicitly trying to learn. We implicitly learn just by doing!


>If you can fix your car you have the skills to start on electronics!

I'd like to think that this is a comment on the ease of fixing cars, rather than a comment about how fixing cars is basically embedded hardware/software dev....


yup that's what I was building :)

i was sending pixel data out from an Arduino (ESP32 really but using Arduino IDE) to a bunch of shift registers that seemed to be 74x595 (but couldnt know for sure) to resurrect an LED display for a local art project, and reading the data coming back out from the last register let me know I was at least getting back what I was putting in, which helped me troubleshoot a few wire length and speed/stability issues

to get started with electronics and hardware in general, I wrote a short tutorial: https://news.ycombinator.com/item?id=35116705


That tutorial of yours is a lot more than I expected to get out of my question, such a cool first project! Thanks!


Esp32 is the cool arduino.


The way that really clarified things for me was buying a 3d printer(an Ender 3 for me) and a Raspberry Pi. Setting it up and flashing a new OS to it should basically teach you the rudimentary workings of the hardware->software interface.


I would suggest to search for "Arduino starter kit" or "embedded starter kit" on Amazon. They come with lots of components and usually with some project guides.


To the degree that you were worried about such things, this wasn't a real answer. Yes, it saves you if you have a boolean variable... maybe?

  if (var == TRUE)
    ; // It was 7
  else if (var == FALSE)
    ; // it was zero
  else
    ??? what do I do here?
And you need to solve that "what do I do here" for every single conditional on a boolean, and have the extra lines of code to handle it and not crash.

But, you know, what if it was a variable that you used in a switch statement instead? Or just "if (i > 17)"? Bit flips can affect your logic all over the place, not just when it's a boolean variable.

And then, if a bit flip can affect a boolean, it can also affect a pointer. Or the return address on the stack (or the link to the previous stack frame).

Or it can flip a bit in the code.

So this is, at best, a very very partial solution, and it's non-trivial to implement. So this was very much not standard practice or a "convention".


I've been on a team trying to argue that exact thing. If you aren't going to handle the case where the var is neither true nor false, at least by explicitly documenting the fail-safe case, you're just cargo culting. You get a lot of that type of thing in MISRA and automotive codebases.

Any team that realizes that the compiler may choose to optimize out a shit-ton of such code gets an extra gold star.


Here is how I do it:

#define FALSE 0

#define TRUE (!FALSE)

ASSERT( TRUE != FALSE );

and let the compiler worry about which bits to use for TRUE


Why do you think you need the “else: ??? What do I do here?” case?

Until you added the 2nd test and the 2nd else case, there is no scenario under which both paths of an if/else would fail to execute due to a bit flip of the test variable, because with ‘if (boolean_condition) {} else {}’ there is only 1 conditional test. A bit flip could have caused the wrong branch to execute, but it could not have skipped both branches. A bit flip could change the jump instruction to something else, but in that case your imagined else case still wouldn’t help.

> this is, at best, a very very partial solution

FWIW, the author said this, and fairly succinctly, saying this TRUE=7 thing is “of course foolish as such a 1 bit hardware error would "trash" pretty much any system”. He was only having a bit of fun that cost nothing, and nowhere suggested this is a solution to cosmic rays or other data errors.


if var is neither this nor that then it's not a boolean


No, this is more a case of “this could conceivably happen, so why not guard against it where it’s easy to do”. Though personally I would have used -1.


The BBC micro and Archimedes used -1 as true in BASIC.

It meant that you didn't need the distinction of "logical operators" (like && in C) and "bitwise operators" (like & in C). You could just use bitwise operators, e.g. the bitwise NOT operator would convert 0 (all bits clear) was -1 (all bits set) so there was no need for "logical operators".

I always felt that was more elegant than C (but of course required a two's compliment machine, which BBC/Archimedes was, but C didn't require).


This is only sound if you have a boolean type that guarantees that the bits are either all zero or all one. Once a mix of bit values is possible, you have to define whether it mean true or false, and then you can’t use the bitwise operators anymore.


No. Random bitflips (aka hardware that doesn't work) are a relatively new thing. Bit flips due to buggy software was a thing though. This is why most database engines checksum the payload data even in memory. I've also seen network packets corrupted because a bridge (former name for switch) trashed data in flight, then reconstructed its CRC for the corrupt data on the onward leg.


>Random bitflips (aka hardware that doesn't work) are a relatively new thing

This implies that old hardware always worked, which I strongly doubt (what year did hardware go from always working to not?).


1993


I beg to differ. Early 90s there were some Amiga memory expansions that would constantly flip bits. I'm pretty sure it contributed to the sentiment that the system wasn't the most stable, although I'm pretty sure one or two of my friends with PCs saw similar issues on their machines. Maybe Microsoft Word wasn't to blame for all the crashes?

Of course, trying to work around it in software is utterly futile.


Bitflips aren’t a new thing. I’ve been rarely but painfully bit by them since at least 1986. This. Excludes serial and modem communications where it was a way of life.


SEE/SEU are not a relatively new thing. However, the frequency of events is inversely proportional to the feature size, which has been decreasing over time.

https://en.wikipedia.org/wiki/Single-event_upset

https://en.wikipedia.org/wiki/Die_shrink


> Random bitflips (aka hardware that doesn't work) are a relatively new thing.

I thought they (from cosmic rays, etc.) were always a thing, but so rare that you needed a very large system (in scope or time or both) to have a substantial chance of encountering one (outside of noisy comm channels, which use error correction protocols for exactly that reason.)


Some event (unknown) triggered multiple spikes in the "tell me three times" redundant three ADIRU units of Qantas Flight 72 causing a WTF unscheduled sudden and dramatic pitch down

https://en.wikipedia.org/wiki/Qantas_Flight_72#Conclusion

Cosmic rays were suspected but unconfirmed (kind of hard to confirm after the fact).

"All the aircaft in the world" for sixty years is kind of a large system given that currently there are on the order of one million people in the air at any moment.


There are lot‘s of thing that can go wrong beyond cosmic rays. Like timing on the bus or signals from close wires. Digital is an abstraction of an analog and chaotic reality.


> Random bitflips (aka hardware that doesn't work) are a relatively new thing.

Bits flipping due to hardware that didn’t work well was what caused Xerox PARC to implement an error correcting memory for MAXC, fifty years ago.

https://gunkies.org/wiki/Maxc

> Bit flips due to buggy software was a thing though.

No kidding.


What you mean by relatively new? I observed bitflips a couple decades ago, causing machine to panic.


Panics and consequent crashes or reboots (?) used to happen in Unixen at times, maybe due to bitflips or other hardware errors.


Cosmic rays ?


I’ve been involved with systems where 0xffff… was canonical “true”, but not something as specific as 7! If you’re going to turn on more bits, why not all of them? Though I think this was because the NOT instruction was used for logical inversion, so the bit flip theory doesn’t apply.


For example, the value of Visual Basic's "True" keyword is -1. This seems silly from the perspective of a C programmer, but -1 (0xffffffff) is "more true" than 1 because every bit is true, not just the LSB. :)

https://learn.microsoft.com/en-us/dotnet/visual-basic/langua...


Even in VB there is a grain of rationale .. I never even considered before WHY it was -1.. I always just thought it was VB doing VB, but now I have gained +1 respect for Vb..

Edit: "Gained" no "Earned"


In the long-ago world where integers were commonly used as arrays of bit flags, it made perfect sense that True = Not False.


The OP still wanted to only type a single character.


Still is. And there's little to be done about it.

Unless you can stop cosmic rays.

Luckily it doesn't happen THAT often. I forget the exact metric but I recall various Google Engineers saying that something like one out of a million test run failures is a random bitflip?


Cosmic rays were a theory in 70's era hardware for failures that ended up being proven to be particles emitted by the ceramic packaging itself. (Modern bitflips are have more to do with component sizes several orders of magnitude smaller.) (edit: not saying that cosmic rays aren't a problem now, just that they only became a problem as chip element sizes shrunk, and they're probably not the only source.)

Also, you can definitely stop cosmic rays, that was part of how they eliminated them as the source.


> Also, you can definitely stop cosmic rays

As I understand it, bit flipping in RAM is mitigated by error correction, via auxilliary and redundant bits.

https://en.wikipedia.org/wiki/Dynamic_random-access_memory#R...


ECC RAM is for the most part relegated to server-grade components, for what it's worth. So your phone, your laptop, your router? Almost certainly not using any ECC RAM, unless you've gone out of your way to do so.


I swear there was a google paper about using a DC as a really bad particle detector, but I can’t find :/


> I have never heard of this convention before! Was "random bitflips messing with your conditionals" a common problem back in the day?

Due to RAM/CPU failures? I don't think so (though I have seen it, fwiw). With weird serial protocols that don't have proper checksums/digests, running over sketchy wiring? Yeah, and that might be part of "very low-level code and hardware experience".


This doesn't make any sense even if the system isn't trashed.

If 7 == true and anything other than 7 == false, then one bitflip will still change the meaning. If 7 == true and 0 == false, then you could have code that does `if (mybool == 7) { ... }` and later `if (mybool == 0) { ... }` and end up with a situation where code path invariants are broken (i.e. mybool is neither true nor false.

If you use `>= 7` to mean true and `< 7` to mean false, while a 0 false value won't randomly become true if one of 3 bits randomly flips, a `7` true value will become false if any of those bits flip. And if any of the other bits flip, 0 will become > 7.


In C any value != 0 is considered true. Nothing special about 7, he could have used any other number, but 7 is a single character, so he used that.


It’s a problem even now if you have software security checks dealing with adversarial actors with hardware access.


Slightly off topic, but why did 1 become the truthy value and not -1?

Logical nots would then work.

And youre still an inc/Dec away from the opposite.


That depends on

a) Two's complement representation

and

b) Wraparound on arithmetic, which is still UB in low-level languages.


Ok. I used -1 as a short hand for 0b11111111(11111111(1111111111111111(11111111111111111111111111111111))))

Not doesn't rely on wrap around arithmetic.

Wrap around arithmetic is only undefined for signed values.

What platform doesn't wrap around signed integers?

Just because c has some undefined behaviour, doesn't make it some natural law of the universe.


I regret not archiving my early code for good so much. First non trivial program (a snake game). First utility in assembly. First device driver (for a Centronics printer). That perpetual calendar in Pascal for a uni assignment, written with enormous hangover within an hour and still my only program written entirely bug-free to the date. All seemed trivial and not worthy of preservation then but in the end I have no code surviving from before late 1990s.

Take good care of your code kids!


This is a problem only we'd to face. Kids these days use Git in some hosting hub or the other that it's a rarity that their code gets lots. Of course if these "free" services go down... it matters. Self-hosting has its uses.


yeah when GitHub is sold to PE 15 years from now, and we get emails like "you have 2 days to backup all your repos", i hope I won't feel too lazy


Luckily Software Heritage is backing up all of GitHub and more, so even the lazy ones won't lose code :)

https://www.softwareheritage.org/


It is this exact realization, while looking for some of my old code, that first got me started using git and github.


I have a lot of my old code, but I never want to look at it because it's super-cringe.


I lost the first 5-6 years of code thanks to an IBM Deathstar[1] when I was 20.

Got really depressed by it at the time, as it included most of the projects I worked on at the time. After that I got super paranoid about having backups.

I do enjoy going back and looking at the code I still have though. Being self-taught it's mostly not terribly great, but I do have fond memories of finally cracking a certain nut or figuring out some neat trick.

[1]: https://en.wikipedia.org/wiki/Deskstar


That tough lesson about backups.

Many a person has had to learn it the hard way.


Left all backups at a remote storage facility. Remote storage facility called me one day and said all of your hardware and media has been lost, except for this one [insert oldest most worthless computer of the bunch]. Cue me raging, cursing out this storage facility, threatening to never communicate with them ever again. Finally accepted the fault lied within me. Up until yesterday, I only had redundant storage but no true backups. So I purchased an LTO-5 and now I have two backup sets onsite and a third offsite at my colocation facility.

In this story the remote storage facility was my mom's house shortly before the GFC. The hardware were varying PS/2 computers from 286 to 486s with hard drives of zip files of my QBASIC, TurboPascal, Delphi, and VisualBasic code. The only hardware saved was our first computer, an 8088. All because she didn't want the clutter in the house anymore. No contact, no chance to retrieve said wares.. just poof gone. Gone were the Z80 ASM files of my rendition of PunchOut for the Ti-83+. Can't reference my old writings that I saved in various TXT files on the gazillion 3.5" floppy disks I kept in an old laundry basket. 5.25" floppies of DOS installs, random games, and an ancient version of SCO Unix. Gone.

Everyone learns the hard way.


>All because she didn't want the clutter in the house anymore.

A recurrent theme in retrocomputing forums. Never trust family with old computers; they consider them worthless.

I somehow managed to save mine. Hardware is with me, and data is well replicated, with warm, cold, remote, as well as cloud copies.

It is also all encrypted, thus it has a good chance to remain private unless I decide otherwise.


The deathstar of legend.


Mine did vary quite a bit within that period, from BASIC in middle school to some funky selective availability GPS handling prod code. But it's beside the point: I'd love it as memento, no expectation really that said game of snake would end up on Steam.


Same here. I made a DOS spreadsheet program (with modeX charting! And formulas), a couple of games and a couple of viruses (aaaa TSR looked like magic)... I think they might be in some floppies in my mom's basement.


Worth reading the Author's recollections of his almost dying in 2019:

https://dunfield.themindfactory.com/2019.htm


That was intense. It made me think about my father in law, who had a heart attack in 2015 that compromised 90% of his heart. His exams are so ugly that one of his physicians refused to threat him, probably worrying that he might die any minute during the appointment.

He is still alive today, he has a normal life and he even manages to go for a run in the beach every saturday. His exams haven't improved, he is always out of breath, but he just refuses to die. It's like what the physician said in the link above: "You look a lot better than what's in the paper".


> "Hug his children. Sleep in his own bed. Eat his meals. and Work a little with his hands." in her words "They shot everything she said down"

Anyone know why doctors do this? They did the same thing with my father when he wasn't getting better (leukemia with pneumonia) and they couldn't get him off the breathing tube. They were very adamant he'd be disabled for life.


It's tough. A vast majority of the time the doctors are right about recovery, and the family is wrong, and optimistic to a delusional degree. It's hard work telling family how bad things really are.

Still, if something happens to me or loved ones I hope I get doctors who can distinguish between zero and one in a thousand.


I mean they're giving the best information they have. Sometimes it's wrong, but unless you think they should hedge more (which people also hate, "Why won't doctors ever commit to something, it's always 'maybe' or 'I don't know' or 'we'll see', what's the point of the degree and the high pay if they don't know anything?!") I don't really see what else they can do.

We hear a lot about all the times they're wrong, because they're tragic or frustrating or confusing, and because biology is super non-deterministic they're probably wrong more often than say physicists, but they're also right a lot of the time too, enough of the time that we consider it worth having them. We just don't get as many articles and anecdotes about a doctor correctly predicting someone's disability, because it's not as interesting.


doctors are all completely insane and should never be trusted. the process of getting into and through medical school has a selection bias towards type-a sociopaths. and whoever makes it through that wringer and gets board certified has to be constantly on guard for malpractice lawsuits. half sarcastic but mostly i do believe this lol


Strangely reminds me of "The Shadow out of the time" by the reverent HPL.


Grim af but that looks like a happy ending


I love this. It has crossed my mind more than once to do something similar at some point in the future.

This is a bit like receiving an inheritance from your grandparents. There will be true gems and novelties mixed in with a lot of knick knacks and rubbish. But the totality of that tells a story of real people living rich and interesting lives that only a handful of highlights would not do justice to.


Why only when you are retired? Why not just right now?


depending on how organized you are... this can take a lot of time


I can definitely relate to this feeling of "when $this is all over, I'll open source a bunch of it, but it's too much work to factor it out now," where $this is more often a company or project than a career. Sadly, it almost never happens. It just goes to show the importance of open sourcing what you can, as you can (in other words, "now or never"). But it's a lot more work to do that than people imagine, even when they say "well just release it in the least polished form possible." You've still gotta deal with adding a new boundary to your codebase, which not only requires additional effort but also increases complexity of the wider project and makes it impossible to refactor without first refactoring a cascade of miniprojects you've created within it.


I often think of source code like moulding clay. While you’re actively working in a codebase, the clay is moist and malleable. Making changes is easy, because the context of what it does, and how it’s organised is fresh in your mind.

But if you move on to another project and let time pass, the clay dries out and becomes brittle. When you open the project up again, it takes time to “wet the clay” - and remember all that context that you’ve forgotten. It’s easy to add bugs, or reimplement methods that already exist somewhere else under a different name. But over time, you work water into the clay and it becomes malleable again.

I agree with your comment. Refactoring software to split out libraries that you can opensource is a lot of work. More work than people realise. But if you think refactoring is a lot of work when the clay is wet, it’ll be many times harder if you let the clay dry first. Refactoring as you work is always the best way, because it’s often the only way to get it done.


I wish I had saved something from my 40 years of programming, but I alwayds left everything behind when I moved to a new job. I did manage to keep my commercial memory allocator from the late 90's (single threaded, only supported Metrowerks CodeWarrior and the old MacOS), it was the fastest allocator on the Mac, and bug-free, but became obsolete with MacOS X. Not sure anyone would care today. I lost my source code to Trapeze as I mentioned yesterday ( https://en.wikipedia.org/wiki/Trapeze_(spreadsheet_program) ). I guess I never throught about saving most of my work for a day when no one cared if I shared it.


>Not sure anyone would care today.

There's a vibrant retrocomputing community.


This is really cool. It seems very 'pure' in comparison to what my code history will look like. In 2040, a lot of my code will show how I used a bunch of libraries and frameworks that nobody uses 'these days'. This doesn't seem good or bad, just a reflection of the times.


And unless you put in the effort to archive those dependencies yourself, nobody may be able to truly read or build your code anyway.

Today’s trendy development practices are shockingly ephemeral and fragile. Very little of today’s projects would survive one decade left fallow, let alone four.


A few years back my office threw away a PC running Windows XP with no service packs. It was left in a closet for many years just in case we had to fix a bug in some safety critical code.

A few years ago we tried to rebuild some safety critical code from sometime back and were unable to because the certificates had expired and so the machine that can build the source code refused to connect to our version control system.


This is why I really like Debians policy of being self-contained, that everything in Debian is built from sources that are in the Debian system.

It takes a lot more effort to package stuff, since you can't just download your dependencies from the internet. But you also create something that isn't as ephemeral.


Since you mention it, I recall that it's the same thing in OpenBSD: their policy is "base builds base."


> Today’s trendy development practices are shockingly ephemeral and fragile

My fellow human, you have just nailed what is wrong with today's software.


Or stated a tautology. The trendy is almost by definition ephemeral and fragile. Otherwise we'd call it timeless!


> And unless you put in the effort to archive those dependencies yourself

go makes this extremely easy to do

https://go.dev/ref/mod#go-mod-vendor

rust tool chain also includes a vendor dependency process

https://doc.rust-lang.org/cargo/commands/cargo-vendor.html


Do you use this and check in vendored code? I don't, maybe I should


Reading this thread makes me think about archiving my code too. I have backups of my project folders going back to the 90s when I started programming. But I often delete node_modules and other build artifacts before archiving because that stuff takes up so much space.

But maybe it’s worth going through and actively and explicitly downloading all those dependencies too. Who knows when npm will get hacked again, or old package versions will get yanked. Disk space is cheap. I’ve written a lot of code over the years. It would be nice to know it all still runs.


  > Very little of today’s projects would survive one decade left fallow, let alone four.
I hate to break it to you. 2040 is less than half as distant as you think it is.


I want off this ride.


It will be over sooner than you think it will be.


I think that's somewhat the curse of technology. It's so hard to make anything from scratch. How do you get metallurgy working without already having metals? How do you get electricity running without an outlet, or at least powerful, easily sourced magnets?

Thinking about the "dependency tree" for any modern convenience is truly staggering. I can't even start to think about how you can make a factory without first having a factory.


Checking dependencies into VCS should be more common as with yarn PnP and such.


all these `pip install` and `npm install` will be useless


They already are, if your internet connection has a hiccup or worse.

They already are, if something has been hijacked and is now malicious.

They already are, if you need to install something offline somewhere.

They already are.


Even before... Trying to compile archived versions of the python 2.7 runtime on recent Linux distributions is an exercise in frustration. Thank god for the gentle souls that keep putting out lightly updated compilable 2.7 python runtimes, your efforts haven't gone unnoticed.


I have a directory full of prebuilt wheels for the entire dependency chains of several python applications I use. All you need to do is tell python to build all the wheels and save them to X directory, and point it back at that directory for installing. In particular on Termux, there's a number of rarely-used python programs that have native dependencies, so I store them on my network drive to free up storage on my tablet. I have a similar setup for doing stuff on Colab. It's entirely possible to use python/pip in an offline environment, as long as you've planned for it ahead of time; all you need is pip and possibly wheel, and the correct version of python.


not sure if node has its own vendor process now

But languages like go and rust have had the ability to “vendor dependencies” for awhile now.

Don’t need an active internet connection. Just need to have the toolchain.


Node predates npm. All node does is look for dependencies in the nearest node_modules directory. (And all npm does is download dependencies into that folder). So you can simply archive / check in your node_modules directory if you want to. I think there’s tools to help out and make sure the dependency versions are all pinned. (npm shrink-wrap and friends)


I think his most impactful utility is ImageDisk: used to archive floppy disks from many different types of computers using IBM PCs.

Much of the old software found on bitsavers.org (and archive.org) was recovered using this utility.


Vernor Vinge's A Deepness in the Sky depicts a human society thousands of years in the future, in which pretty much all software has already been written; it's just a matter of finding it. So programmer-archaeologists search archives and run code on emulators in emulators in emulators as far back as needed. <https://garethrees.org/2013/06/12/archaeology/>

You've made a contribution to the hoard that someone will benefit from, whether tomorrow or in 5,000 years.


The part about the modern (read: far future) calendar being commonly thought to be based on mankind's first moon landing but ACTUALLY being based on the Unix Epoch is a favorite amoungst engineers I know that love Vinge


Very nice. Hope you enjoy your retirement.

----

One last bugfix before retirement (this is a joke):

I wanted to look at micro-cad it generates a 404.

URL: https://dunfield.themindfactory.com/dnld/sc/MICROCAD.ZIP Expected: I can download the .zip file.


I think the MCSAMPLE zip contains the full thing as well


Also ran into the same 404. There's not many original CAD programs out there. I'd love to see this one.


This is brilliant.. It's so interesting too because over the years I've built up a few "Bibles" that I always need on hand when working in a particular language or even just automation, I've learnt some very good organising processes (from HN to be honest), I never thought to 'release' them as they feel quite personal and specific for my mental process.

Looking through some of these though, I think I'm inspired. Super cool idea, I would donate to the retirement project financially to say thanks if possible.


I’m curious, what do you mean by “Bibles” exactly ?

And what are the organizing processes you learned; I’m always eager to learn productivity tips/software from others


I have quite a few of these bibles too. I'd love to swap some files if you're interested, I'm sure there is much to learn from yours. My Gmail username is the same as my HN username if you are interested.


Ah but when you say “bibles”, what do you mean exactly? Is it just common/useful code you fold related to a particular language/framework? Could you elaborate on this


Usually there's a getting started section, mostly links to important nuances in the fine documenting and short code examples. Then there will be a section for each problem that I've encountered - often things that I've solved by reading Stack Overflow answers. But then there are the footguns and pitfalls - this is where the real value of these files lie.


Oh that’s a really great idea. Thank you for elaborating; I think I will get into a habit of doing a similar thing


Not ready to retire, but I did something like that a few years ago with the previous generation of code I wrote: https://www.kmoser.com/sourcecode/


I like to download images of old programming CD's from archive.org, like Programmers Heaven[1] for example. All small and interesing programs/tutorials to look at.

[1] https://archive.org/details/Programmers_Heaven_InfoMagic_Mar...


Another link from DDS is Dave's Old Computers http://dunfield.classiccmp.org/ , a nice treasure of old pc reviews and images, (Left, right, front and back). This is amazing as I've been working on making 3D assets for a project of mine.


Any one catch the out of memory comment?

# we require more vespene gas; unix consensus; kNtErrorOutofmemory;


I like how he puts his email as a captcha https://dunfield.themindfactory.com/contact.htm

And slyly tells you the “password” to get past his spam filter


elvis70 are you Dave Dunfield (the source author)?

[It might be more a ShowHN if you are?]

I'm interested if all of the code is self-written? If you wrote any of it under contract and so had special terms to allow you to eventually release it? Which piece of code there that you are most proud of and/or gonna most useful?


I'm not Dave, but here's a thread on Vogons in which he announced his project, you could possibly contact him from there: https://www.vogons.org/viewtopic.php?f=7&t=97034


Quick question because I can't actually find any info on it, but what license are these released with ?


It's in COPY.txt, although it's homespun.

If you're the author, please please release into the public domain (CC0) if your purpose is educational. That makes it so anyone can learn from it and build on it without any fear of infringement.


[flagged]


Though because that license says "for any reasonable purpose" it's something that's vague when it comes to "is this FOSS" as it's vaguely Crockford-like ("this software shall be used for Good, not for Evil").

The [OSI requires](https://opensource.org/osd/):

> 6. No Discrimination Against Fields of Endeavor > The license must not restrict anyone from making use of the program in a specific field of endeavor. For example, it may not restrict the program from being used in a business, or from being used for genetic research.

[GNU/FSF](https://www.gnu.org/philosophy/free-sw.html) have as "Freedom 0":

> The freedom to run the program as you wish, for any purpose


It's just a homemade licence, IMO don't need to be pedantic about it.

If you think you are being reasonable, use it, if you think you are not, don't :)


Legally, "reasonsable" just means "for a reason" (that someone can describe). Ianal but, one told me this long ago.


So honestly I didn't read the "COPY.TXT" .. I wouldn't expect a license to sit there, and I didn't consider that a license personally, I was expecting a defined license.


[flagged]


If you're alluding to COPY.TXT meaning COPYRIGHT.TXT and therefore it would/should contain a license then I hate to disappoint you. Copyrights and Licenses are different things. So maybe put a dampener on your expressions of incredulity, it's not a great way to engage here.


Afaik there's s really common convention of a file named COPYING with instructions on when you can/cannot copy the code, i.e. the license.


> What did you think "COPY.TXT" meant, in all honesty?

so I'm most focused on this one : SYNC Synchronize two directry trees

While I was lost in the folder sync tools, Copy.txt really just stood out as a readme honestly.

Edit: Readme of the implementation. Like all the rest.


This is great - add them to github!


Or maybe don't feed the machine...


I do love personal websites - but the proper place for sharing code, where it can be forked and shared, is GitHub or a place like it. Plus, author has already licensed their code in a way to allow it anyway.


> the proper place for sharing code [...] is GitHub

Man how far people are brainwashed.


OK. Straighten me out. Explain the difference between sharing my 20 year old code on a personal sever with a license that says “do what you like” and posting my code on GitHub/GitLab/SourceForge etc.


That's not the problem. The problem is saying "the proper way to share code is with GitHub". There is no single proper way to share code, least using a commercial platform(s).


Personally I've become sceptical towards github since Microsoft took over it, and it's surprising to me that the open source community is so happy to use it in light of Microsoft's history of trying to fight open source.

Of course there would be a lot of reasons to use github, which I'll refrain from attempting to list since I'm not really an expert of that particular subject, but those benefits has to be weighed against handing over the control of such vast amounts of data to a huge corporation which I'd think its safe to say, primarily would be interested in profit and survival, rather than the wellbeing of the open source community. One might for instance consider the possibly of the data being used to train an AI, which in itself isn't necessary a bad thing, but that still raises some questions. Apart from that relying on github's, might lead to vendor lock in, and it might also mean that the processes that gets used to develop projects falls under control of a in a best case scenario selfish actor and in a worst case scenario a hostile one.

Perhaps you are familiar with the "embrace, extend and extinguish" strategy that Microsoft has been accused of employing? Things like these doesn't really inspire trust in the company's intention towards free software. Due to the size of the company, they are also capable of influencing the industry at large through various means, for instance via expensive advertisement campaigns, and to selling their solution to existing clients. So for instance they could create software such as VS Code and Teams, which would argubly be more or less copies of existing software, using their sizable pool of developers and then use it's huge marketing machinery to take over the market.

Even tough the open source community seems to be flourishing at the moment, there would be threats looming on the horizon. For instance the question of how to relate to service providers who can profit off of open source code, without really having to share back since the code is running solely on their own servers, another one being that open source code gets used to build closed solutions with the help of AI.

Personally I appreciate projects, that distribute code in the old-fashioned ways, which has proven to be successful in countless cases, and I would like to ask open source creators to consider the alternatives, and how they would fit in with the goals of the project. A lot of times I bet github still would be a good fit, but at the same time I'm sure that there are good ideas that could be implemented outside of those parameters.


People can poke around in it more easily. E.g. I wanted to look at the 6808 OS code but it's a zip file and I'm using a phone, so...

Not saying it needed to be on github only, but unzipping into a set of repos there in addition to posting the zips would be helpful.

I suppose anyone could do that, but then the provenance is not preserved.


You mean besides Microsoft R&D slurping all Github code up by default into an LLM training set by default? Not much.


> Or maybe don't feed the machine...

Curious as to why you consider that a bad thing.


Because it gives power to Microsoft to impose its will on millions of developers, and for little reason in this case, when the goal is just publishing software, and not development.

Its UI for presenting large number of software projects sucks, too.


There's also codeberg.org for git-shaped artifacts, or archive.org for everything else.


If it is not on Github it is never going to feed anything


A http server is all you need


… which dies with the author, or a couple years later when his domain expires.


You believe that Github is some kind of heritage organisation? Incentives are aligned now, kind of, except they train an AI that they sell to other people on your code. I use Github but do it with open eyes.


GitHub has Arctic Code Vault program.


Just looked it up. That is impressive. Probably could do with some Antarctic geo redundancy ;-).


Software Heritage are also archiving all of GitHub (and more):

https://www.softwareheritage.org/


Add $1000 to your Namecheap accounts, turn autorenew ON, you are good for couple decades ...


So we'll trust Namecheap for a couple decades but not a Microsoft-backed purpose-built website?


The question of "how long would a non-famous repository stay alive on github" is actually an interesting thought experiment.


GitHub's track record on this so far is fantastic. Repos that were created 15 years ago and didn't see another commit since their creation are still there today.


By this metric, folks should go for sourceforge: https://sourceforge.net/p/gnome-napster/code/ has last seen activity 23 years ago, while https://sourceforge.net/p/primal/code/ci/master/tree/ saw changes this year.


> Last Update: 2013-02-19

Am I missing something? Where did you get 23 years from?


Latest commit in CVS. I'm not sure what the Last Update date is about, but I think Sourceforge did some larger data shuffle in 2013, at least there are many orphaned projects where the site claims an update in 2013 even though nothing of the sort happened.


I see, thanks for clearing that up!


They are living four decades from now in 2040.


What is the actual downside to hosting it personally and hosting it on github or something like it?


Downside is GitHub or any of the commercial git-hosting sites might use your code in ways you didn't intend e.g. machine learning, training neural nets, etc. Alternatively they might go out of business and go down after hinting you to save a local copy. These are countered by self-hosting your repo in your own (home/cloud) server.

Downside of self-hosting is time, money and effort. You've to spend for energy and hardware and your time and effort to keep them shipshape. Chances of it surviving beyond you are slim.

Both has downsides; just pick one depending on what kind of person you're. If you only want to write code vs that and also know how to maintain it. The latter is necessary skill if you ask me, instead of being just a code monkey.


Well I was called "brainwashed" for suggesting it without any explanation so good luck getting a coherent answer ;-)


There is also the lesser known repo.or.cz


It's older than github, I think. I hosted one of my projects there in 2006 or so.


Not using a standard license but rather a bespoke one is a major legal roadblock.

The presence of use restrictions does also disqualify it from being Open Source (OSI trademark) or Free Software (GNU/FSF).

If a standard license was adopted instead, such as MIT (permissive and I believe well-aligned with the intent of the author), then any concern would go away.


I downloaded RINGSW.ZIP to check it out.

> This file is NOT included in the demo version of this product.

> For more information, please contact Dunfield Development Systems

I admire the effort, but if you're not going to make the source freely available, what's the point? What is somebody going to do 100 years from now when they get your .zip off archive.org and you're long gone?


> what's the point? What is somebody going to do 100 years from now when they get your .zip off archive.org and you're long gone?

The author seems quite aware of this. He calls it out specifically: it's for learning and curiosity purposes.


The seem to be three points of confusion here:

Confusion on your part regarding what the other commenter's complaint is. The complaint is that the source code archive they downloaded did not contain the source code. It contained an old copy of a shareware notice instructing the reader to write to Dunfield for access to the source.

Confusion on Dunfield's part: specifically, the belief that he had included the correct version of RINGSW.C when republishing this stuff to celebrate his retirement.

Finally, confusion on the part of the other commenter here, involving an assumption that Dunfield's oversight was a deliberate decision.


Thanks for clearing things up. I was indeed too hasty with my initial comment and didn't consider it wasn't a deliberate decision. Thanks again.


Surely, but the author also says:

> my goal now is to release 40+ years of source code

And there was no code in the .zip. Shrug.


At 70, I do not think anyone has anything to learn from my 40+ years of code. I envy Mr Mindfactory's confidence.


Thanks for your humility. Still, please consider sharing what you can -- even if only with customers of your software. We all have so much to learn.

(I do regret giving too much of my time to free projects, yet have found a satisfying balance by including source with purchases of software I sell.)


We need a new GPL that includes a clause that prohibits training any sort of AI or statistical model on it, unless the output of that model is inheriting the license.

Otherwise AI will be the end of anything open - which we can already see in stackoverflow now.


So, is this an issue of credit, a recognition thing? Or more an issue of just sharing with the “right” people?

I share what I do freely. If someone integrates that trivia and shares it with someone else, so much the better. I offer a fractional shoulder to stand on. Getting hovered up into an AI that then goes on to help someone else isn’t much different than having something random posted on the internet that solves someone else’s stumbling block.

But that’s just me.


Instead of impeding progress with copyright even more than alwe already do, maybe we should repeal copyright altogether.


It‘s my time as developer and I choose to license my output however I want. Thank you very much.


As a developer I don't think I should have the right to tell other people how to use their computers (even if they're using code that I wrote). Nor do I think that you should... thank you very much :-)


Put it on github! You might actually get people to fork it and continue working on it.


That implies that it needs people to continue working on it.

Is there no such thing as "done" anymore?


> That implies that it needs people to continue working on it.

It does not.

> Is there no such thing as "done" anymore?

Is there no such thing as "building upon it" anymore?


THere are reasons not to host on GitHub . There are workarounds to hosting on GitHub Google words why not put software on git hub Finds https://sanctum.geek.nz/why-not-github.html OR https://www.wired.com/2015/06/problem-putting-worlds-code-gi...


This code is enjoyable to look at - it's clean, well-documented, and clearly a work of love. I like all the small utilities that help the author accomplish a bunch of goals.

I wonder if the code manages be so clean because it's only aimed at a single compiler and a single platform. Multi-platform C code tends to be messy with preprocessor goo.


This is sort of unrelated OP, but did you ever write a follow up to this post? https://dunfield.themindfactory.com/2019.htm I’m very curious how well you’ve improved since then. -


Good idea. I should keep better track of all the stuff I've written...


Very cool to see such a long history, were the different projects you worked on related to what was going on at your job at the time?


Hate to say it but I remember when this stuff first came out. Thank you for releasing the code. Brings back memories.


This is wonderful. Thank you. Very moving that you choose to share this!!! Thanks for making a positive impact on the world.


Some links unfortunately are broken.


why not somewhere on git? :(?


Thank you! You show me a living history of computer programming.


I wish I remembered code my car accident made me dumb...lol


I wish I remembered how...my car accident made me dumb ...


Please put it on Github - nobody will ever find this otherwise


It's on the front page, so your comment seems pretty tone deaf.


For today -- and tomorrow everyone forgets about it.


it being on GitHub does not keep it in peoples memory. so this argument is not sound.

if it was on GitHub, and it made it to the HN front page, "tomorrow everyone forgets about it" would still apply.


Respect. I'll follow when my time come.


You have the same name as the billionaire guy. Are you him? :)


Warranty?


thanks for the tokens


Great LLM training data


Why didn’t he use more memory safe rust?




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: