Live data from Hacker News

Tbox: A GLib-like cross-platform C library

github.com

61–70 of 71 posts

Re: Tbox: A GLib-like cross-platform C library

#61
post #8

Why was it written in C instead of Rust/C++? Additionally why are there a bunch of generic sounding Chinese names in the comments with dead comments? Bot comments/SEO?

It's a C library. If it were a Rust or C++ library it would be written in those languages.

That does not always necessarily follow. The VC runtime, for the C portion of the library, is now written in C++ internally.

Re: Tbox: A GLib-like cross-platform C library

#62
post #60
post #58

Earlier quoted context omitted.

What grammar restrictions? I've converted a few C99 libraries to C89 (since i prefer that one and i often work with older compilers because they are faster) and 99% of the time the reason a library uses C99 is inline variable declaration (which IMO is a bad style, but that is subjective) and // comments (which most C89 compilers support as an extension anyway). The versions do have other differences, of course, but t…

C89 cannot mix variable declarations and code. printf("Hello World!\n"); int x = 7; printf("%d!\n", x); return 0; This is a very serious restriction for me.

Yes, that is what i meant with "inline variables". IMO this is usually a sign of code that is too long to be readable and if you really need that you should either split the function to make it more readable or, if that cannot be done, enclose the affected code in their own brackets (with a comment that makes it easy to distinguish). Brackets also make sure that the variable wont "outlive" its context (although again that is a sign of code that is too long).

Of course that is my opinion (and i'm generalizing of course), but that comes from my experience with working with others' code.

Re: Tbox: A GLib-like cross-platform C library

#63
post #62
post #60

Earlier quoted context omitted.

C89 cannot mix variable declarations and code. printf("Hello World!\n"); int x = 7; printf("%d!\n", x); return 0; This is a very serious restriction for me.

Yes, that is what i meant with "inline variables". IMO this is usually a sign of code that is too long to be readable and if you really need that you should either split the function to make it more readable or, if that cannot be done, enclose the affected code in their own brackets (with a comment that makes it easy to distinguish). Brackets also make sure that the variable wont "outlive" its context (although again…

Even if the function code is very short, I still like to define and declare variables nearby.

Unless a function has only two lines of code.

Re: Tbox: A GLib-like cross-platform C library

#64
post #63
post #62

Earlier quoted context omitted.

Yes, that is what i meant with "inline variables". IMO this is usually a sign of code that is too long to be readable and if you really need that you should either split the function to make it more readable or, if that cannot be done, enclose the affected code in their own brackets (with a comment that makes it easy to distinguish). Brackets also make sure that the variable wont "outlive" its context (although again…

Even if the function code is very short, I still like to define and declare variables nearby. Unless a function has only two lines of code.

Right, that is your style, but i wouldn't call that "too many grammar restrictions" :-).

Re: Tbox: A GLib-like cross-platform C library

#65
post #55

Earlier quoted context omitted.

Until rust came along you had three non CG options C, C++ and ADA. If you also have a no heap requirement you're left with just C and ADA. Rust is interesting if you can live with slow compile times and 4X the memory footprint of C.

Why does the no heap requirement preclude C++? Obviously, you couldn't use much of the STL (not really a loss in constrained environments), but I don't see a reason to write off the language itself?

It is used in embedded. I think that refutes the claim.

Re: Tbox: A GLib-like cross-platform C library

#66
post #64
post #63

Earlier quoted context omitted.

Even if the function code is very short, I still like to define and declare variables nearby. Unless a function has only two lines of code.

Right, that is your style, but i wouldn't call that "too many grammar restrictions" :-).

It's too many grammar restrictions for this person. That's obviously what's implied by the person's original comment.

Re: Tbox: A GLib-like cross-platform C library

#67
post #54

I'm not seeing tests anywhere. Am I blind or are they hidden away or non-existent? Thx in advance.

> I'm seeing tests anywhere. Am I blind or are they hidden away or non-existent? Thx in advance. While this might be a valid point, I really don't like the manner in which it is expressed. Feigned surprise, pretend humility and, most importantly, lack of basic respect towards fellow developer(s).

Wait, you cited my text and changed it from the original dropping a key word and then attacked me for it. Not cool. There is no feigned surprise or lack of respect either implied or actually present in my inquiry about the lack of tests.
Post reply on HN