March 13, 2022
On 13/03/2022 4:46 PM, StarCanopy wrote:
> And thus, perhaps compiling druntime along with a libc? After all, I hear that statically linking with glibc is quite difficult.

I don't know, extensions alone probably would kill ImportC being of any help.

At very least its a build management problem. Something[0] should help with.

[0] https://wiki.dlang.org/Building_LDC_runtime_libraries
March 13, 2022
On Sunday, 13 March 2022 at 03:11:58 UTC, rikki cattermole wrote:
> That gets you the binding, not the actual library itself.
>
> What bachmeier is looking forward to is having libraries like sqlite, zlib, lua and sljit to be copiled with the D compiler rather than having to supply binaries or hope its installed in the user system.
>
> This way it'll "just work" without needing to worry about external dependencies.

Yeah, and it's not just the external dependency, but the version of that dependency. A good example with sqlite is the recent json functionality. If you include the sqlite source in your project, you can use all the latest and greatest.
March 14, 2022
Good to see it working for ya!
March 14, 2022

On Saturday, 12 March 2022 at 09:55:03 UTC, Ki Rill wrote:

>

I tried using Raylib with importC, and I thought I should share my recent experience using it... Works like a charm! Worked from the first (second really) try!

What I did step by step (in case someone needs directions):

raylib.c:

#include "raylib.h"

main.d:

void main() {
    import raylib;

    InitWindow(640, 640, "ImportC raylib test");
    // game loop
    CloseWindow();
}

Compiling:

gcc -E raylib.c > raylib.i
dmd main.d raylib.c -L=-lraylib
./main

The big problem is that #define are missing. So a lot of const must be redefined or made explicit like:

ray.h:

#include "raylib.h"
Color RAYLIB_BLACK = BLACK;

But it's not so comfortable to use.

I would like to mix different languages, just like kotlin+java on android development or like calypso did.

March 14, 2022
On Mon, Mar 14, 2022 at 10:47:24AM +0000, Andrea Fontana via Digitalmars-d wrote: [...]
> I would like to mix different languages, just like kotlin+java on android development or like calypso did.

Have you checked out Adam's jni.d?  Makes calling Java functions from D (and vice versa) so nice that it almost made me want to write Java again. :-P


T

-- 
Let's call it an accidental feature. -- Larry Wall
March 14, 2022

On 3/14/22 6:47 AM, Andrea Fontana wrote:

>

On Saturday, 12 March 2022 at 09:55:03 UTC, Ki Rill wrote:

>

I tried using Raylib with importC, and I thought I should share my recent experience using it... Works like a charm! Worked from the first (second really) try!

What I did step by step (in case someone needs directions):

raylib.c:

#include "raylib.h"

main.d:

void main() {
    import raylib;

    InitWindow(640, 640, "ImportC raylib test");
    // game loop
    CloseWindow();
}

Compiling:

gcc -E raylib.c > raylib.i
dmd main.d raylib.c -L=-lraylib
./main

The big problem is that #define are missing. So a lot of const must be redefined or made explicit like:

ray.h:

#include "raylib.h"
Color RAYLIB_BLACK = BLACK;
  ```

But  it's not so comfortable to use.

I would like to mix different languages, just like kotlin+java on android development or like calypso did.

Yes, C does not allow manifest constants of anything other than integers via enum. Raylib has eschewed most (all?) #defines of integers, preferring enums, but e.g. a Color struct cannot be an enum.

The pain of having to not only redeclare manifest constants but also give them a different name is pretty high.

-Steve

March 14, 2022

On Monday, 14 March 2022 at 13:30:44 UTC, Steven Schveighoffer wrote:

>

Yes, C does not allow manifest constants of anything other than integers via enum. Raylib has eschewed most (all?) #defines of integers, preferring enums, but e.g. a Color struct cannot be an enum.

The pain of having to not only redeclare manifest constants but also give them a different name is pretty high.

-Steve

I can't belive compiler can't handle a simple optimization for a non-manifest color const.

Is really a performance penalty to declare BLACK like this?

const struct Color BLACK = (Color){0,0,0,255
March 14, 2022

On 3/14/22 12:26 PM, Andrea Fontana wrote:

>

On Monday, 14 March 2022 at 13:30:44 UTC, Steven Schveighoffer wrote:

>

Yes, C does not allow manifest constants of anything other than integers via enum. Raylib has eschewed most (all?) #defines of integers, preferring enums, but e.g. a Color struct cannot be an enum.

The pain of having to not only redeclare manifest constants but also give them a different name is pretty high.

I can't belive compiler can't handle a simple optimization for a non-manifest color const.

Is really a performance penalty to declare BLACK like this?

const struct Color BLACK = (Color){0,0,0,255

You can submit your request to raylib, and see if they accept it. I doubt it.

One thing that is very obvious from a few of my PRs is that raylib is not interested in making changes specifically to be binding-friendly. I think you will probably find this from many C libraries -- their focus is their library, not yours. If ImportC cannot work with C libraries as they stand without "simple tweaks", then it's just not going to be worth much.

-Steve

March 14, 2022

On Monday, 14 March 2022 at 17:49:23 UTC, Steven Schveighoffer wrote:

>

[snip]

One thing that is very obvious from a few of my PRs is that raylib is not interested in making changes specifically to be binding-friendly. I think you will probably find this from many C libraries -- their focus is their library, not yours. If ImportC cannot work with C libraries as they stand without "simple tweaks", then it's just not going to be worth much.

-Steve

Would there be any benefit to having raylib-d take advantage of importC, rather than the user, but also keep around some of the things that make it easier to use, like the Colors enum?

March 14, 2022

On 3/14/22 2:02 PM, jmh530 wrote:

>

On Monday, 14 March 2022 at 17:49:23 UTC, Steven Schveighoffer wrote:

>

[snip]

One thing that is very obvious from a few of my PRs is that raylib is not interested in making changes specifically to be binding-friendly. I think you will probably find this from many C libraries -- their focus is their library, not yours. If ImportC cannot work with C libraries as they stand without "simple tweaks", then it's just not going to be worth much.

Would there be any benefit to having raylib-d take advantage of importC, rather than the user, but also keep around some of the things that make it easier to use, like the Colors enum?

ImportC could replace much of the binding, sure. However, we have an additional problem in that raylib-d adds things to structs, such as operator overloads. That's not so easy to do.

ImportC itself is great for things that you want to "just use". Again, though, it needs to provide some mechanism to access #define constants and macros.

But as a D developer, using an actual C library gets quite annoying. You deal with it because it's what's available. But if I can add niceties to it, I'd rather do that.

Raylib itself is such a simple and well-organized library that I've contemplated just rewriting it in D with a D-like interface (use strings, use overloading, operator overloads, etc). But contemplation is all I have time for unfortunately :(

-Steve