Wanting to use dwl with Rust rather than C

Hi, so there is this tiling window manager called dwl (which is similar to dwm except dwl is for wayland whereas dwm is for x11) which allows me to configure the entire tiling window manager in C lang.

However I wanted to use Rust instead of C.

If I build the entire project, it will create a config.h file. I am supposed to be playing with config.h file to configure this config file. But I am wondering like maybe I should keep the rest of the C files C, but for the config.h I want to use Rust instead.

What would be the best approach for this?

If the entire project is in C, why would you bother creating a separation configuration handler in Rust? You'll have to come up with a way to parse the configuration you'd like to manage yourself through a separate file and/or command line and put it back into that C header file anyway, even if you do.

Why complicate things for yourself further if there's a way to keep them much simpler?

1 Like

What if I used C2Rust or something instead?

Like as in I should just stick to using C, is that what you are suggesting?

Again, why? It's just a configuration file.

Of course, unless you're planning to re-write the whole WM in Rust, just configure it in C, the way it was meant to be done.

I'm not specifically experienced with dwl, but to me it looks like you are probably better off in this case just using C. I think using Rust would probably over-complicate it.

@Ideator @zicklag

Its a header file which is used as a configuration, so it is the source code you directly edit.

And the reason is cause I want to use Rust over C since I like the language a little more.

So I was wondering if it is possible to get C2Rust to completely convert the project from C to Rust?

Is that possible? Would it mess up the code?

Correct - and you don't like the idea of editing it manually?

What exactly do you mean by using Rust over C here? As previously, you said that:

If that's the case, you'll need to go through all the options you can set up in that header file, create some separate program to handle configuration for you, in Rust, which generates that same file, before building the whole project the way it was meant to be done.

Now you want to convert the whole project? You could use a tool like that, sure - then manually edit all the code bit by bit, getting rid of the unsafe and coming up with safer alternatives that would satisfy Rust. Are you sure you have the time and the energy to do that just to use a language you like?

It's possible, sure - and it's most likely going to mess the code significantly, as programming in C is quite different than programming in Rust. Could be a fun learning experience, though.

1 Like

Most likely it would not be that simple. It seems like a program that takes a C header config file is probably the worst case scenario for just being able to use C2Rust, because the program itself is designed specifically to use C, and in a way that is not natural from Rust, due to the way cargo works.

So I think that converting it is probably not worth your time, unless you are OK with a lot of work.

Agree with that part. :wink: But I think in this case it probably is much easier just to use C.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.