site  contact  history  index

The Zig language

October 21, 2024 — BarryK

Back in 2022 when I was looking around for alternatives to BaCon, did briefly look at Zig, but decided on Nim. Here are introductions to BaCon and Nim:

"The BaCon programming language"
https://easyos.org/dev/bacon/index.html

"The Nim language"
https://easyos.org/dev/nim/index.html

Last couple of days, took another look at Zig; it has grown enormously in popularity since 2022. Why?...

Zig is a relativitely young language, started by Andrew Kelley in 2015. It is a complete compiler, generating binary executables, unlike BaCon and Nim that generate C code and then require a C compiler such as gcc to generate the binaries. I've been "kicking the tyres" of Zig...

I compiled the traditional "Hello World" CLI program, and it is only 3KB. Furthermore, that binary is statically-linked. First impression, that is incredible.

But it gets better; out of the box, the Zig compiler cross-compiles. You can choose any target you want, x86_64 or aarch64 for example. Furthermore, you can specify specific CPUs. I specified the Intel "nocona" CPU for my "Hello World".

Right off, I see why this will appeal to people who code for embedded systems.

The Wikipedia has an overview:

https://en.wikipedia.org/wiki/Zig_(programming_language)

The Zig website:

https://ziglang.org/

img1

There are some great getting-started websites:

"Introduction to Zig"
https://pedropark99.github.io/zig-book/
...online, also available as an ebook or printed.

"Zig Guide"
https://zig.guide/

"Getting started with the Zig programming labguage"
https://blog.logrocket.com/getting-started-zig-programming-language/

I have a particular like for associative arrays, and yes, Zig has them in the standard-library; they are called "hash tables". I also want the language to support regular expressions; it seems need an external library for that.

I have a need to create small statically-linked binaries, for use in the initrd. But they are useful anywhere, as no reliance on glibc or any libc library. Developers will have encountered this problem, when linked against a particular version of glibc, the binary won't work with a different version of glibc. Yes, you can statically-link with glibc when compiling, but the binary is enormous. So, I have used musl. Up until now.

Another thing I like is to write little programs with GUI, that is, Graphical User Interface. Most commonly I do this with shell scripting and one of the GUI tools, such as gtkdialog, xdialog and xmessage. BaCon and Nim also have GUI toolkits; I have used HUG with BaCon.

What about GUI toolkits for Zig? There is a website with links to all-things-Zig:

"Awesome Zig"
https://github.com/zigcc/awesome-zig

I like the look of "capy":

https://capy-ui.org/

https://github.com/capy-ui/capy

img2

Here is another GUI toolkit, not in the Awesome-Zig list:

https://github.com/desttinghim/zig-libui-ng

...awhile back, in 2022, did look at the Nim binding for libui-ng and liked its simplicity.

Finally, some Zig reviews:

From the perspective of a Rust programmer:
https://blog.lohr.dev/after-a-day-of-programming-in-zig

This looks like a sales-pitch:
https://leaddev.com/tech/why-zig-one-hottest-programming-languages-learn

From the perspective of a Go programmer:
https://medium.com/@vladimirvivien/things-i-like-about-zig-as-a-go-programmer-75eb02aab00f

Looks good. The intention is that once Easy Daedalus 6.4 is released, will take some time out from Easy development and play with Zig. As an exercise, might rewrite 'debdb2pupdb' in Zig, see how it compares with the Nim code.

EDIT:
Here is another Zig tutorial, very recent:

"Programming with Zig: from basics to mastery"
https://gencmurat.com/en/pages/programming-with-zig/
   

Tags: linux

EasyOS Daedalus-series 6.3.93 (6.4RC) released

October 21, 2024 — BarryK

Fantastic, we are fixing bugs! See previous announcements:

Download:

https://distro.ibiblio.org/easyos/amd64/releases/daedalus/2024/6.3.93/

Feedback welcome:

https://forum.puppylinux.com/viewtopic.php?p=133746#p133746

I'm very grateful to you guys for testing and finding bugs. Are we there yet? Maybe 6.4 is almost ready to go.   

Tags: easy

Mime handling fix for KDE apps

October 20, 2024 — BarryK

This fix is going to apply to more than KDE apps; any app that reads /usr/share/applications/mimeapps.list to determine file associations. For example, a .doc file should be opened in LibreOffice.

This issue came up in discussion of Dolphin file manager on the forum:

https://forum.puppylinux.com/viewtopic.php?p=133545#p133545

I have focussed on file associations for ROX-Filer, which are generated by /usr/bin/build-rox-sendto. This script is run in woofQ when easy.sfs is created, and also when any app that has a .desktop file is installed or removed, or any sfs installed or removed. It creates the associations in /etc/xdg/rox.sourceforge.net/OpenWith -- if you look there, be warned, they are all hidden folders.

SeaMonkey and Firefox, and some other apps, look at /etc/mime.types for file associations, but my understanding is that this is an older mechanism not read by most modern apps.

I discovered that Dolphin, a KDE app, stores file associations in ~/.config/mimeapps.list

A bit of online reading, found the system-wide location, for all users, is /usr/share/applications/mimeapps.list

build-rox-sendto now also generates /usr/share/applications/mimeapps.list, and it works great. Here right-clicked on a .svg image file in Dolphin:

img1

...it has chosen mtPaint as the default, that will run if left-click on the .svg file. To change the default, you would have to edit the ~/.config/mimeapps.list file. I presume just copy the one you want as default from /usr/share/applications/mimeapps.list, under the "[Default Applications]" heading. It seems that Dolphin can't do this for you.

Here is the change to /usr/bin/build-rox-sendto:

https://github.com/bkauler/woofq/commit/cba281b0cb79720ff8bb47c9ad588bdeaff39cef

This is a great improvement for running many different apps in Easy.   

Tags: easy

New desktop icon themes

October 20, 2024 — BarryK

Forum member nilsonmorales has created two new desktop icon themes for EasyOS:

"pop_blue"
https://forum.puppylinux.com/viewtopic.php?p=131908#p131908

"paperforeasyos"
https://forum.puppylinux.com/viewtopic.php?p=132084#p132084

I have made these into PETs and uploaded:

http://distro.ibiblio.org/easyos/noarch/packages/pet/pet_packages-noarch/

You can download them directly, or via PKGget (after updating the database).

Thanks for the contributions!   

Tags: easy

EasyOS Daedalus-series version 6.3.92 (6.4RC)

October 19, 2024 — BarryK

Version 6.3.90 ws released a couple of days ago:

Thanks to the guys who have tested it, lots of bugs identified and fixed.

There was a 6.3.91 release with many fixes and new SolveSpace and Audacious apps builtin. Also some infrastructure for KDE apps. 6.3.92 has more fixes, especially the PKGget package database can now be updated.

PKGget calls /usr/local/petget/0setup to perform a database update, which calls /usr/local/petget/debdb2pupdb, which was failing.

There is a long history here. debdb2pupdb was written in the BaCon language, and that is the one in Daedalus 6.3.91 and earlier. I'm not sure if I recall rightly, but I think that in woof-CE Dima (dimkr) wrote in C. Mid-2022 I was learning the Nim language, and as a learning exercise rewrote debdb2pupdb in Nim. It is here, in the woofQ project:

https://github.com/bkauler/woofq/blob/main/easyos/source/nim/debdb2pupdb.nim

I don't know why, but with EasyOS I stayed with the BaCon version. Which works fine in Scarthgap, but for some unknown reason is broken in Daedalus. I could probably figure out why, but then remembered the Nim version and gave it a go -- it works.

So, 0setup script has now been modified to call debdb2pupdb-nim if it exists.

In the forum, I posted about two outstanding problems:

https://forum.puppylinux.com/viewtopic.php?p=133485#p133485

The aplay failure is still not fixed. It is so weird, as did fix it, then it became broken again. You can see the problem for yourself:

# aplay /usr/share/audio/2barks.au

The 'pcm_direct.c' file in the source code calls the glibc 'getgrnam_r' function, and it seems that the "audio: ..." line in /etc/group is too long. I made it shorter and aplay worked. Thinking, good, now fixed, built 6.3.92, but get the same failure, even though the "audio:" line is shorter. Which I cannot understand. No problem in Scarthgap.

Anyway, download from here:

https://distro.ibiblio.org/easyos/amd64/releases/daedalus/2024/6.3.92/

...the update from 6.3.91 is only 2.3MB. Testers welcome!

Here are some old blog posts in 2022 about debdb2pupdb written in Nim:

https://bkhome.org/news/202208/debian-to-puppy-package-db-conversion-in-nim.html

https://bkhome.org/news/202209/nim-168-compiled-in-oe-with-simplified-recipe.html    

Tags: easy

Junction-box for custom trike

October 17, 2024 — BarryK

Continuing the custom tadpole recumbent trike project, here are recent posts:

I have now constructed a "junction box", with circuit breakers and various input and output plugs and sockets. Here is a simplified sketch:

img1

...the negative wires are not shown; they are all connected together, in a star configuration. Photo of inside of the box, mostly assembled:

img2

Another view:

img3

It is a snug fit. Could have used a bigger aluminium box; however, wanted one with side-flanges, for convenient mounting, and Jaycar, a local store near me, had limited range. I bought this one.

The box is going to be mounted underneath the seat, where I can reach down and flip the "motor" circuit-breaker to get going. There is also a "mppt" circuit-breaker that goes to the solar-panel MPPT controller, and an "output" circuit-breaker that connects the battery to output sockets -- Anderson socket to bring out the 48V battery, USB sockets and 12V accessory (cigarette lighter) socket.

The USB and Anderson socket combo also came from Jaycar, here. However, what I did not realise, is that the USB panel-mount socket is also available with higher input voltage. The ones from Jaycar and everywhere else locally, are 12 or 24V input. But I discovered in Aliexpress, they are also available for electric-vehicles, input voltage up to 90V. So, I bought this one:

https://www.aliexpress.com/item/1005001756428902.html

img8

The back of the aluminium box has a DC-DC converter mounted, input from the "48V" battery, output 12V going to the accessory socket. Photo of back:

img5

If I had stayed with the Jaycar USB socket, with only 12V input, would have had to go through two DC-DC converters, which is very inefficient. Each DC-DC (buck) converter is about 90% efficient. The lost power is dissipated as heat. Now, the USB socket is connected directly from the 48V battery (through the circuit-breaker). There is also a on-off switch on the USB socket.

Bought the DC-DC 12V-output converter from here:

https://www.aliexpress.com/item/1005005631226496.html

Photo of the front panel:

img4

After taking that photo, I went to the "men's shed" workshop near me, and used an etching tool to write what each circuit-breaker is for.

A note about those external cables; they will have XT60 plugs, bought from here. Photo:

img6

...these are popular with remote-control (RC) enthusiasts, as well as other situations requiring small size, light weight and high current rating. I originally bought a pack of T-plug type, from here.

img7

...however, found those T-plugs to be extremely difficult to plug together. Also difficult to unplug. Also, read online that the type of plastic used can soften when soldering, compromising the performance of the plug. There are some online comments that most RC enthusiasts have moved to XT60 type. Unless, I suppose if you need extreme small size.

Regarding the circuit-breakers; they are rated for DC usage. Got them from here. Got the "10A" ones, which might not be high enough for the motor. It is only a 250W motor and pedal-assist, so I reasoned the startup surge current will be modest, well below 10A.  We shall see.   

Tags: light

EasyOS Daedalus-series version 6.3.90 (6.4RC)

October 16, 2024 — BarryK

Devuan is a Linux distribution forked from Debian, almost identical except does not use systemd. Debian Bookworm is the current stable release, and Devuan calls it "Daedalus". I posted about building EasyOS with Daedalus packages a couple of days ago:

A bit worried about fracturing my development effort, but decided to go with it. There are now three projects; Easy Scarthgap-series, Quirky Void (QV) and Easy Daedalus-series.

EasyOS version numbering is based on the Easy infrastructure, not what packages are used to build the distribution, so version numbers keep going up, yet changing the packages could result, will result, in new issues.

Download the drive-image file, courtesy of ibiblio:

https://distro.ibiblio.org/easyos/amd64/releases/daedalus/2024/6.3.90/

Thanks to the Netherlands Linux/Unix User Group for mirroring:

https://ftp.nluug.nl/os/Linux/distr/easyos/amd64/releases/daedalus/2024/6.3.90/

And AARNET in Australia (but 6.3.90 not yet there):

https://mirror.aarnet.edu.au/pub/easyos/amd64/releases/

If you are new to EasyOS and need help how to write a drive-image file to a USB Flash drive, read this:

https://easyos.org/install/how-to-write-easyos-to-a-flash-drive.html

Or, you could open up the image file and install direct to the internal drive. See install tutorials here:

https://easyos.org/

...it is very simple if you already have a boot-manager such as GRUB or REFind installed; just need to copy three files to a folder in any ext4 partition, then make an entry in the boot-manager.

Oh yes, the obligatory photo:

img1

After limited testing, looks good, but testers are welcome -- I'm sure you will find issues! Feedback welcome at the forum:

https://forum.puppylinux.com/viewtopic.php?p=133213#p133213

Some usage notes from my limited testing:

I tested samba and it worked, but I left out the 'samba-vfs-module', that I had included in earlier Bookworm testing. I don't know what that package does. Without it, was able to open a folder on another computer over the local network.

The discussion thread on Easy Daedalus started before this release, and I posted about a problem with KDE Dolphin file manager:

https://forum.puppylinux.com/viewtopic.php?p=133193#p133193

...note though, Dolphin works fine OOTB in QV. But then, QV is built from the ground-up using the XBPS package manager.

Devuan uses Debian packages, except where they have had to modify the package not to require systemd. The Devuan package server is deb.devuan.org and in most cases it forwards a package request to one of the Debian mirrors. However, at certain times the forwarding fails -- it seems deb.devuan.org becomes overloaded. PKGget will seem to have frozen; in that case, click the "Abort" button and there will be another window offering to retry. It has always worked on the retry. Anyway, most of the time downloading is OK.

Any more issues, let me know!

Will Daedalus-series be a long-term "stayer"? Don't know, depends on user interest and also my level of interest and available time.    

Tags: easy

Playing with Easy Daedalus

October 14, 2024 — BarryK

There are those who loved Easy Buster, EasyOS built with Debian Buster packages. This had access to the enormous Debian repository, which was the main attraction.

Awhile ago, I experimented with Easy Bookworm; however, could not get LibreOffice to start. There were no error messages, just nothing, not aven the splash logo. It was waiting for something, and back then I tried to trace it; found where it was not returning from a function, but couldn't understand what it was waiting for. Online searching did not help.

Devuan Daedalus is the equivalent of Bookworm, except without systemd. Decided to give it another go, except this time build with Daedalus packages.

Note, I did download DevuanPup, created by josejp2424, see forum. Wrote the .iso to a usb stick, booted it and got a black screen.

EasyOS Daedalus-series looks good:

img1

Brief testing, everything is working ...except LibreOffice. Same problem, hangs at startup.

Did a lot more online reading last night, and came up with a reference to apparmor causing startup hanging. Easy Daedalus has the apparmor package installed, to meet some dependency requirements, but the daemon isn't running. Played around a bit with that, then decided to compile LibreOffice, in a running Easy Daedalus.

...and, LibreOffice works.

Too big though, as I built with minimal use of system libraries. Today will have a go at compiling again, and reduce the size.

I did post yesterday about incorporating the Debian repositories into Easy Scarthgap-series; will probably continue to investigate that. However, Easy Daedalus is looking good, so tempted to release it. Will do some more testing first though.    

Tags: easy