Live data from Hacker News

sp.h: Fixing C by giving it a high quality, ultra portable standard library

spader.zone

91–100 of 222 posts

Re: sp.h: Fixing C by giving it a high quality, ultra portable standard library

#91
post #89

Earlier quoted context omitted.

> Your computer won't explode just from downloading and compiling some C code, don't worry ;) This is the first time I ever saw anyone dismissing the risk of downloading and running stuff off the internet. "Don't worry".

Compiling

[deleted]

Re: sp.h: Fixing C by giving it a high quality, ultra portable standard library

#92
post #80

First, thanks for sharing this link, it was an interesting read! A few remarks below. I had a hard time reading the wc code in the article. First I had to go to the GitHub to understand that "da" stands for dynamic array, and then understand that what the author calls wc is not at all the wc linux commands, which by default gives you the number of lines, words, and characters in a file, not the count of occurrences o…

By the time you know enough to reasonably use clone3, you have also learned that doing so is an exceptionally bad idea save for very rare circumstances.

Re: sp.h: Fixing C by giving it a high quality, ultra portable standard library

#93

Earlier quoted context omitted.

> I am trying to track down where the function `sp_mem_allocator_alloc_type` is defined A quick glance at the source on github and here you go: https://github.com/tspader/sp/blob/e64697aa649907ce3357a7dd0... `sp_mem_allocator_alloc_type ` is going through a couple of macro resolutions which ends up at `sp_mem_allocator_alloc` > I'm not going to clone and build this (too dangerous). Your computer won't explode just fr…

> Your computer won't explode just from downloading and compiling some C code, don't worry ;) This is the first time I ever saw anyone dismissing the risk of downloading and running stuff off the internet. "Don't worry".

Did you never install anything on your computing device? It's the same risk, or even worse if it was closed source software installed via an app store

Re: sp.h: Fixing C by giving it a high quality, ultra portable standard library

#94
post #68

Earlier quoted context omitted.

That seems to be a pretty consistent quality level for the entire library. Look at the implementations in sp_math, yikes.

sp_math.h is, as noted at the top of the file, a repackaging of https://github.com/HandmadeMath/HandmadeMath It is not part of the core library. It is certainly not meant as a reference-level implementation of math functions. It's there so you can write an easing function for a game without pulling in libc. It seems like its existence has offended you. If that's the case...I'm sorry? At every possible point, I note a…

I don't like that slopcode angle either, but unfortunately I have to say that you do have picked a wrong library to bundle. For example, it's almost likely that there is a correct (not just accurate enough, but correct) implementation of sqrt in your CPU because IEEE 754 mandates that. Unless you're doing softfloat you simply want to wire it via asm.

Re: sp.h: Fixing C by giving it a high quality, ultra portable standard library

#95

Earlier quoted context omitted.

> I am trying to track down where the function `sp_mem_allocator_alloc_type` is defined A quick glance at the source on github and here you go: https://github.com/tspader/sp/blob/e64697aa649907ce3357a7dd0... `sp_mem_allocator_alloc_type ` is going through a couple of macro resolutions which ends up at `sp_mem_allocator_alloc` > I'm not going to clone and build this (too dangerous). Your computer won't explode just fr…

> Your computer won't explode just from downloading and compiling some C code, don't worry ;) I have no idea what's in the Makefile, and I'm not going to review it just so to try and figure out where a function is defined :-/

I found the function body in about 30 seconds by browsing the code on github via plain old text search. Is that also to dangerous? ;)

Re: sp.h: Fixing C by giving it a high quality, ultra portable standard library

#96

> I’ve been working on fixing C by giving it a high quality, ultra portable standard library If the only problem with C was that the stdlib is terrible that would be a very different situation. There are much more fundamental problems with the language. Problems that are entirely understandable in K&R C but aren't acceptable half a century later. A "high quality" standard library can't fix these problems. In some cas…

Sure but it's definitely true that a significant part of the problem with C is that it's standard library is crap. So if you are forced to use C for some reason this could help.

Re: sp.h: Fixing C by giving it a high quality, ultra portable standard library

#97

> I’ve been working on fixing C by giving it a high quality, ultra portable standard library If the only problem with C was that the stdlib is terrible that would be a very different situation. There are much more fundamental problems with the language. Problems that are entirely understandable in K&R C but aren't acceptable half a century later. A "high quality" standard library can't fix these problems. In some cas…

These are all just your personal preferences. Just use another language instead which better matches your taste, nobody forces you to use C and there are plenty of more opinionated alternatives.

FWIW, the standard library being stuck in the K&R era is an actual problem since it doesn't make use of more modern language features and some functions are downright footgun magnets, but nobody quite agrees what a modern stdlib should look like, so a stdlib2 probably will never happen.

Re: sp.h: Fixing C by giving it a high quality, ultra portable standard library

#98
post #64

Earlier quoted context omitted.

The natural comparisons are libraries like glibc and newlib, which do support lots of architectures and more importantly make porting to new architectures or taking advantage of platform features pretty straightforward.

I’m not as experienced as some people here, but in ~10 years, I’ve never needed to write code for anything other than x86 or arm. So I agree with the author on their priorities.

Not all ARM systems are created equally. For example many of the 32bit ARM processor didn’t even support floating point ops. So they’d have to be calculated in software.

Aside from various different variations of ARM, I’ve worked several variations of x86 and AMD64, SPARC, PowerPC, MIPS and others I’ve likely forgotten. Not to mention a few 8-bit CPUs too, but those there more than 20 years ago and not really fair to discuss here.

Re: sp.h: Fixing C by giving it a high quality, ultra portable standard library

#99

> Principles > Be extremely portable > sp.h is written in C99, and it compiles against any compiler and libc imaginable. It works on Linux, on Windows, on macOS. It works under a WASM host. It works in the browser. It works with MSVC, and MinGW, it works with or without libc, or with weird ones like Cosmopolitan. It works with the big compilers and it works with TCC. > And, best of all, it does all all of that becaus…

Yeah he doesn't even try to support major platforms like RISC-V. I know there is fragmentation, but best effort attempts at portability would show some sign of goodwill.

Re: sp.h: Fixing C by giving it a high quality, ultra portable standard library

#100
post #41
post #30

Earlier quoted context omitted.

I could not even find a mention what platform it supports. There is a Linux example on the bottom. Have never seem a libc implementation that does not even mention for which platforms it is meant.

You could, of course, spend 30 seconds look at the code on Github which you would have to do if you were interested in using it anyway? TRIPLES = \ x86_64-linux-none x86_64-linux-gnu x86_64-linux-musl \ aarch64-linux-none aarch64-linux-gnu aarch64-linux-musl \ aarch64-macos \ x86_64-windows-gnu \ wasm32-freestanding wasm32-wasi Or you could actually try the compliance suite on an architecture and report back to us if…

You've rejected a user. You can't complain that he has no interest in your project at that point. The bridge is burned.
Post reply on HN