Live data from Hacker News

Writing C software without the standard library

weeb.ddns.net

51–60 of 188 posts

Re: Writing C software without the standard library

#51
post #42
post #39

Earlier quoted context omitted.

What ? You just write your OS layer for each platform and it's portable.

True. The OS layer you write (and port to other OSes) is called "the standard library". :-)

But at least now you know what's in there, what's going on behind the scenes. And on top of that, it's filled with all sorts of brand new bugs and vulnerabilities! ;-)

Re: Writing C software without the standard library

#52

The guy is definitely a fan of old-school minimalism: http://weeb.ddns.net/0/articles/modern_software_is_at_its_wo... I have to say I miss the old days of Gopher, too. It was so much easier to focus on the content back then.

I find myself agreeing with him 100%. Not just on Gopher (although i did write a Gopher client some time ago - http://runtimeterror.com/tools/gopher/ ) but on the entire rant about wasting resources, UIs that waste screen real estate and become unusable in smaller resolutions, fonts that only look good with anti-aliasing and have weird misplaced pixels with antialiased disabled (which i also do), websites that make r…

I agree that most of software stack seems bloated and wasteful, but there are good reasons for it. The IT has exploded in last few decades and it's no longer just engineers and computer scientists writing code. If they were, software would maybe be of higher quality, but it would be rare, expensive, and insufficient to support all industries.

Web is especially good example. With all its short-comings, it's still sandboxed and portable platform with very capable (and ugly) programming language for delivering same codebase across desktop and mobile devices (even servers, unfortunately). There are many hits and misses like TODO apps built on Electron, but that's to be expected with any technology and isn't a reason to dismiss all the good applications.

To me, consuming all the hardware resources of each new generation seems to be the price we have to pay to build more complex software in larger and larger quantity.

What's bothering me is that it doesn't seem to be converging in desired unification of different applications and services. Everyone is building their own stacks and environment without much care for interoperability. For example, few years ago it seemed clear that XMPP is a way forward in chat clients that everyone should adopt to enable federation. Nowdays we are expected to have 3+ chat clients installed on phone and remember which contact is on which service. I really don't understand how users put up with it.

Re: Writing C software without the standard library

#53

Your first paragraph makes me wish this site supported Markdown.

Yeah off topic but if HN supported markdown (and GitHub's flavor of markdown so we could take different types of syntax with their language) would be amazing. There would be a ton more coding examples and discussion, in my opinion, if this were to happen.

How do we summon Dang? :)

Re: Writing C software without the standard library

#54
post #29

Earlier quoted context omitted.

But still, Linux syscalls are different on each architecture.

Indeed, stupidly different. Different syscall numbers, different argument orders, different values for constants, different struct layouts, ... Some architectures, like MIPS, are particularly bad, with nods to Irix compatibility thrown in. The BSDs are all exactly the same for every architecture, sane.

Does that mean you can run Irix binaries on MIPS Linux?

Re: Writing C software without the standard library

#55
post #3

> Executables are incredibly small (the http mirror server for my gopherspace is powered by a 10kb executable). Is this ever an real issue, even on any embedded system in the last 20 years?

Honestly, if I can, I try to cut down on sizes of compiled binaries and even minified and combined web app code. Sure many times it's unnecessary but if I can save on bandwidth and memory typically that means I'm including less crap that can have problems, too. I see it as including far more benefits than simply getting a file size smaller.

But sometimes it can take so much extra work that it's not worth it. So gotta do the cost benefits analysis or hell if it's something you're interested in doing just do it anyway.

Re: Writing C software without the standard library

#56
Myth busted : printf("Hello world") is simple and is a relevant C program for a beginning.

The "hello world" example is just the first step to annihilate your capacity of understanding how thinks works by relying on institutional black magic, that maybe wrong

(see all the scanf bugs that have been living in C code for so long and all bugs coming from respecting the old's man wisdom)

Re: Writing C software without the standard library

#57
post #29

Earlier quoted context omitted.

> He claims that your code will be easy to port but then goes straight to Linux system calls. Many linux developers believe "code is portable" means "can run on different linux distros". Edit: To be fair, he said architectures, and i think he meant CPU architectures, i.e. AMD64 and i386.

But still, Linux syscalls are different on each architecture.

...which is why he used the SYS_ #defines.

Re: Writing C software without the standard library

#58

The guy is definitely a fan of old-school minimalism: http://weeb.ddns.net/0/articles/modern_software_is_at_its_wo... I have to say I miss the old days of Gopher, too. It was so much easier to focus on the content back then.

I can get behind some of that, I do hate the argument "it doesn't matter if it's inefficient, modern computers are fast" because everyone taking that stance results in things staying the same speed. When you do encounter modern software that's well optimised and not bloat, it's a real pleasure to be in awe at it's speed (Redis is an example I can think of off the top of my head)

That being said, I'm happy the web isn't still just plaintext or minimally styleable

Re: Writing C software without the standard library

#60
post #47
post #42

Earlier quoted context omitted.

True. The OS layer you write (and port to other OSes) is called "the standard library". :-)

A .h file with different syscalls IDs and perhaps a few inline functions is hardly a standard library though

Not exactly syscall ids: I built network services (telnet daemon, snmp client and server, DNS) that compiled without change for win32 (both on Windows and some embedded win32 compatible abomination) and Linux with just a handful of defines and function wrappers as part of a contract once. A lot of apps can get away with very narrow interfaces to the OS.
Post reply on HN