Good day,
I recently hit Nim, by accident, to be honest. I was thinking about using Rust, but found the syntax way too complex for my free time to be enough to understand it in a reasonable period of time. Don't know exactly how Nim came out on a search, so I started to read about it (while docs are few and scarce), and ended up deciding that it's the right choice to go with. The pythonesque syntax helped here, of course. Reading some code examples in Nim seemed quite straightforward to understand, while Rust's seemed more like Swahili to me.
Then, doing some research on what is available for Nim at the moment, and what people are doing, some questions came up, thus I come here asking for any insight on these in order to clear my ideas on how to do things (as easy as possible, of course):
1- For a project I'm working on, I've been doing some prototypes in PyQt. I've read that GUI development in Nim is somewhat not mature enough and info on GUI sdks is a bit on the short side, so I was wondering if I can use PyQt for the GUI and Nim for the rest of the apps, either by building Nim modules to be imported by Python or by including PyQt code inside Nim. Which approach would be more feasible and robust?
2- For that same project, I was searching for something related to Wayland and Nim, and found none. I found stuff related to X.org, specifically, XCB, though seems a bit outdated? I'm thinking XCB because it looks like it's the path to go with X.org right now. Is this XCB module mature enough for, let's say, build a simple Display/Login manager and a simple Window Manager as well?
I plan to use Vim for de Nim development as it is available on any OS that I may put my hands on. So any advice on how to optimize Vim for Nim development would be also appreciated.
I sincerely appreciate any hints on this topics. Best regards, Noxnivi
any advice on how to optimize Vim for Nim development would be also appreciated.
Switch to Neovim and use this plugin.
With regards to GUI libraries: my understanding is the gintro, the GTK wrapper, is pretty mature. On the less mature side, but probably still functional, there is wxnim, nimqml and nimx.
If you want to call nim code from python, consider using genny: https://github.com/treeform/genny
Good day,
First of all, thanks all for your replies, I've been doing some homework based on them.
I took a look at nimpy as @ynfle pointed out, and looks very interesting, and it seems to work both ways, so I'll certainly be giving it a try. Including Python inside a Nim program, if I understand it correctly, could allow a program to be scriptable with Python, or maybe add plugins in python, same as Blender does. If it is stable it can be a very usable add-on to any Nim application aiming to be scriptable, or "plugin-able".
Regarding the GUI, I try to keep away from GTK, that is why I use PyQt, though wouldn't mind to use a native Nim GUI API. I've looked into wxnim, as pointed out by @PMunch and @auxym, but from my understanding, it needs some target system GUI API as if I understood correctly, wxWidgets just translate the widgets to the default system widgets, thus, if I'm building an DE from scratch, there won't be no default widgets available, therefore, wxWidgets wouldn't be able to call the system GUI API. I might be mistaken on this one as I'm not an expert on this topic. Nimqml seems interesting and should give it a try. Taking a look at nimx looks promising, and from what I could deduce, it is a new native Nim GUI API, which makes it appealing, though lack of documentation might be a cause of more trouble than benefit in the long term, at least as of today. Not sure though.
I also took a look at genny, as pointed out by @auxym, so I'll need to compare nimpy and genny and decide. I've also done before some library building usin Python to write the code and then use Cython to build the library, to be used by another Python script. I wonder if I could code some PyQt GUI in Python, make it a library with Cython, and then use it in Nim. I should do some research on that topic, though it seems that should not be needed as long as nimpy works well enough.
Regarding IDE and Vim, the issue I see with neovim, as indicated by @miran, is that it isn't available on Haiku, as far as I know, as well as VSCode/Codium, which seems to be the best tool to develop Nim programs. I might end up using Codium where it's available and Vim where it's not, but for now I think I'll stick with Vim as it allows me to bring the .vimrc file along to any OS and have exactly the same dev environment.
What I haven't found much info on was XCB. I did research the Wiki for the "curated" resources and packages. I've looked into some Window Managers developed with Nim and all use Xlib. To be honest, I don't really know the real difference between these two, just read that XCB is the path to go now while Xlib is going to be deprecated?. No word on Nim and Wayland neither, though I'll be fine with XCB.
Right now, I'm using Fedora 35 LxQt, though might end up switching to FreeBSD. Nonetheless, this is a long term project. Therefore, the better decissions I take now, the better in the long term.
Sincerely appreciate your comments and help on these questions. Thanks a lot. Regards, noxnivi
Another thing you can do if you want your Nim project to be plugable or scriptable is to either load dynamic libraries (which can be created from Nim, or any other language) or you could embed NimScript with Nimscripter.
Not sure what you have aganst Gtk, it is pretty much the default for most Linux distros. WxWidgets does indeed use the system framework, this means it would use the Windows framework on Windows, Gtk on Linux, and Cocoa on Mac for that truly native look. If you're building your DE from scratch and not using Qt or Gtk you would have to build all your widgets yourself anyways, not sure what you meant there. Owlkettle is another alternative if you want to use Gtk in an easier way: https://github.com/can-lehmann/owlkettle.
For creating a WM in Nim I've used xlib in the past because it's old and has a lot more tutorials. Then avahe-kellenberger/Prestige came along and wrote Nimdow and used xlib probably because that is what I was using and I managed to help them out. XCB is probably the future for X11 window managers, but I have yet to find a good WM tutorial for it so I haven't tried writing a WM in it. Wayland is a completely different system and as auxym pointed out you can use it in Nim with nim-wl. The way it works is that it uses Futhark to simply import the C library directly and use it as if it was C code (but from there abstractions can be built).
Good day,
Thanks @auxym, @federico3, @PMunch and @kobi for your replies. I'm learning with each one of them.
As @auxym pointed out, I checked the wayland project and it does seem to be at a very early stage, so for now I will stay away from it. Nonetheless, I'll keep track of it.
Libadwaita, if I remember correctly, is GTK. I don't have any specific thing "against" GTK, in fact I did some program with PyGTK, PyObject using Glade and GnomeBuilder. This was an easy thing to do as GnomeBuilder exports directly to Flatpak, and Glade is quite easy to use for GUI design, might be because of this that many apps are coming to the Gnome ecosystem. I don't like so much the GTK thing because every widget is "oversized", taking way too much space on screen for my liking. Besides, it looks like GTK is copying Apple, who is copying Deepin, who is copying Gnome making it even simpler. That is a weird evolution circle that scares the hell out of me. Regardless this, I acknowledge that GTK seems to be the best suited to be used with Nim, as I even found an online book "Computer Programming with the Nim Programming Language", which is mainly GTK based. So it seems like the easiest path to take. I'll think about it again.
Regarding OSes, and native look, I don't care much about Windows, and I don't care at all about Apple stuff, as I've been inside that cage for years. Now that I'm out, I have no intention of going back in again. My only purpose here is targeting Linux/BSD/Haiku desktops, not even mobile. I have to limit the scope :) And for Linux/BSDs, Qt or GTK could do, even build the widgets could be an option, but I find the later way too complicated at the moment. I also thought about Kivy, as pointed out by @kobi, but it looks more mobile oriented, and my target right now is desktop. Didn't know about Flutter nor Dart, so I checked a bit today, and it looks also mobile oriented. Will have to check deeper though, to have an educated opinion on that. Also checked nimx and fidget, and looks like I need to do more research on the GUI side of it, even the QML/Qt part.
The idea I'm working with is to "make" a WM-DE integrated with one another, that is, the Window Manager and the Desktop Environment is the same thing. Simple (which I know doesn't mean easy to achieve), visually ergonomical though themeable, with a consistent look and feel. This, by no means is something that I want to achieve by the end of the year, I'm not in a hurry, and I know I still have plenty to learn about, so I understand it'll take time. Let's see what comes out from this idea, it might be worth it, or it might end up being some piece of c**p.
I've checked TinyWM in Nim, which is short and easy to read, Nimdow and Minimal Window Managers, all made in Nim. Great to know that @PMunch worked on Nimdow, Kudos!. I've seen some video on youtube and looks quite production ready, and everything is Nim, which proves me right about the things that can be done with the language :D I'll check the XCB package and if I can find any info, but as @PMunchen noticed, Xlib might be the way to go at the moment, as all the WM named before use Xlib, so it looks like it is the path to take now. I would like to use XCB because, it "is the future of X11", but then again, what is available is what I'll use. Thanks for the tip on that one @PMunchen.
Didn't know about Nimscript but will take a look at it. Nonetheless, the scripting part is optional, and might depend on specific use cases, thought about Python, because it's what I know a bit of, and Blender also is scriptable with Python, so seems it can be done. Not sure now, but I think I saw something related to a Python interpreter written in Nim? somewhere... :? To be honest, I didn't know about the complexities, just was thinking about including . Regular, simple applications wouldn't need scripting, I mean in-app scripting. Another thing is scripting the DE, a la AppleScript from, you know, Apple, or the Hey scripting language from BeOS. That's a different thing to study too.
Anyway, step by step.
Thanks again for all your replies. Sicerely appreciate your hints and explanations.
Regards, noxnivi