
Tbox: A GLib-like cross-platform C library - waruqi
https://github.com/tboox/tbox
======
j1elo
I see " _Micro: compiling micro library (~64K) for the embed system_ ", now
that caught my attention!

Should I then assume that the compatible platforms are actually more than the
listed Windows, Linux, Mac, and mobile OSes?

I'm on the front of AVR development, and cool new things always arrive late
(understandably, if they arrive at all...) to our little corner of the world
:(

But I assume that "embedded" here will mean mainly ARM.

(similarly, I'm still excitedly waiting for more progress on the Rust front :)

~~~
waruqi
Yes.

------
torstenvl
Your source files contain the following in the commented header:

"Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements."

Did you in fact specifically license it to the ASF? Or are you just licensing
it under the Apache license?

~~~
waruqi
I just used the Apache license.

~~~
jahewson
Apache committer here - you’ve got the wrong header there. That one’s for
source which has been committed to ASF repos under a CLA.

You want the header for non-ASF code which can be found here:

[http://www.apache.org/licenses/LICENSE-2.0.html#apply](http://www.apache.org/licenses/LICENSE-2.0.html#apply)

~~~
waruqi
Oh, got it, I will modify headers.

Thanks.

------
mises
They've got a bunch of other cool projects, too:
[https://tboox.org/project/](https://tboox.org/project/)

I wouldn't have thought to look, but I saw something about xmake the other day
(by the same people). I still am probably going to stick with cmake (inertia),
but cool stuff.

------
desiderantes
I think that if you're going to compare your library to GLib, then at least a
basic comparison of features, side by side, should be available

------
waruqi
Provides stream, container, iterator, algorithm, coroutine, database ..
modules.

And we use xmake to build it.

------
azhenley
I’m working on a compiler right now that generates C. Should I use this for
the generated code? (Or should I use glib, musl, or uclib?)

A comparison chart would be helpful! Similar to:
[http://www.etalabs.net/compare_libcs.html](http://www.etalabs.net/compare_libcs.html)

~~~
flukus
> Should I use this? (Or should I use glib, musl, or uclib?)

I agree that a comparison would be good, but musl and glibc are low level
fundamental API's for things like printf and opening files.

Glib and this are higher level libraries to build applications with. If you're
building a compiler you probably want one of these, for the generated code it
would depend a lot on the specifics.

Edit - I'll also add that a lot of people's experience with C seems to com
from college or beginner material where they're learning in a very bare bones
environment. Combine C and libraries like this and it's not just good for app
development but can be great for scripting where python or bash would
typically be used.

~~~
waruqi
Yes.

------
tomcam
Congratulations on an absolutely massive achievement! I love seeing high-
quality C libraries appear. What version of C does it target?

~~~
waruqi
c99

~~~
Gibbon1
Not supporting obsolete versions of C is utterly awesome.

~~~
waruqi
C89 is too old, too many grammar restrictions. And now the mainstream compiler
basically supports c99.

~~~
Crinus
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 they're rarely used
(the next most common one is designated initializers, which for me are the
most annoying to convert).

I mean, it is your code, i just found the grammar restrictions part weird
since really there isn't that much of a practical difference between C99 and
C89 to the point i personally never felt the need to use C99.

(note that i focus on the language bits, C99 provides some extra library
functionality but even then the most useful part is stdint.h which can be
implemented in almost any C89 compiler anyway)

~~~
waruqi
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.

~~~
Crinus
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.

~~~
waruqi
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.

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

~~~
WoodenChair
It's too many grammar restrictions _for this person_. That's obviously what's
implied by the person's original comment.

------
ggm
how does it handle u_128 (IPv6 comparison/sorting/hashing)

two u_64 is .. sad (sometimes unavoidable)

no bzip2 but other good modern compressors which I guess is about what you
_need_ for jar and zip files.

openssl compatible crypto .. oy vey the chain of "who audits the code is now a
mile long at the microphone"

~~~
waruqi
There is no support for u_128 yet, but I can consider it.

~~~
ggm
If you think about radix tries and other data structures (AVL) it would be
useful to be able to code good x>y tests against the binary state of IPv6. If
you have to segment into two u_64 then shift-and-mask stuff becomes harder.
So, purely for IPv6 (and I work with internet addresses a lot so my bias is
showing) I think this makes sense.

But I totally get it may not be in your use case or first pass. Tiny home
router builds? they'd want this. Anything doing IPv6 packet work testing or
finding IPs in a structure will want this unless people code to the /64 model.

~~~
waruqi
Yes, I agree.

------
hliyan
What does "modern" mean in this context?

~~~
waruqi
Ok, Now the title has been modified, maybe the previous title is not
reasonable.

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

~~~
eps
> _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).

~~~
andrewbinstock
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.

------
sansnomme
Congrats on shipping! This is really good advertisment for Xmake btw :)

------
mikelpr
why didn't you build off musl?

~~~
waruqi
I don't want to have any third-party library dependencies.

~~~
mikelpr
oh no I thought you were talking about a glibc replacement (making your own
libc) while this is about glib as in gnome, sorry

------
mlindner
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?

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

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

