News for hackers. Stuff that matters.
Re:GTK4 Bindings for Common Lisp by kazinator on Tuesday September 20, 2022 @01:12PM (#32914754)
I'm guessing this is small because it relies on GObject Inspection.

This is a Gnome feature whereby C libraries are accompanied by an XML description of functions and types. The XML description annotates semantics, not only syntax. Like if a function has a pointer parameter, does it have to be malloced, and does the caller free it or the callee? This information is not possible to determine from parsing C header files.

If you can parse the GObject XML, you can then generate FFI bindings (which can be done in Lisp easily without any textual code generation hacks).

Re:GTK4 Bindings for Common Lisp by audidude on Tuesday September 20, 2022 @03:34PM (#32916678)
Before people get too up-in-arms about that being XML, that is just the first step in the GObject Introspection compilation.

The second step builds a .typelib file which is a mmap()'able data-structure used at runtime by dynamic languages. It's smaller as it doesn't contain things like function/class documentation.

Additionally, the language bindings tend to use the GIRepository base structure which handles loading those mmap()'able data structures with an C API on-top of it.

Re:GTK4 Bindings for Common Lisp by kazinator on Tuesday September 20, 2022 @07:40PM (#32919226)
Before people get too up in arms about a C API accessing some binary blobs, rest assured there is XML you could process instead.
Re:GTK4 Bindings for Common Lisp by jmercouris on Tuesday September 20, 2022 @11:57PM (#32920693)
Well, actually not everything possible via CFFI is possible via GIR. I've run into some issues before. I cannot recall what exactly, but it was a showstopper for me :-(.
Re:GTK4 Bindings for Common Lisp by paines on Wednesday September 21, 2022 @10:14AM (#32925443)
Crosscompatiblity? IIRC the same concept was used for some exo-lisp gtk bindings, IIRC fennel, and I couldn't get it work for the life of it under M1 macs....
Re:GTK4 Bindings for Common Lisp by ducktective on Tuesday September 20, 2022 @01:00PM (#32914608)
Also see: https://lispcookbook.github.io/cl-cookbook/gui.html

These may be of special interest:

A lightweight QML-only ECL binding to Qt5/Qt6 : https://gitlab.com/eql/lqml

CLOG - The Common Lisp Omnificent GUI : https://github.com/rabbibotton/clog

Re:GTK4 Bindings for Common Lisp by kaeland on Wednesday September 21, 2022 @12:27AM (#32920787)
+1 for CLOG
Re:GTK4 Bindings for Common Lisp by tabtab on Tuesday September 20, 2022 @02:20PM (#32915785)
It's not good D.R.Y. to reinvent a binding library for each and every application language. What's needed is a state-ful GUI markup standard. Then any language that can emit and read XML can use the GUI kit/browser/component, no binders needed.
Re:GTK4 Bindings for Common Lisp by Spivak on Tuesday September 20, 2022 @03:28PM (#32916615)
What you're describing is GObject inspection. It's literally a series of XML documents that can be used to autogenerate ffi bindings in any language. The future is now.
Re:GTK4 Bindings for Common Lisp by nerdponx on Wednesday September 21, 2022 @01:55PM (#32928724)
...which is literally what these Lisp bindings use.
Re:GTK4 Bindings for Common Lisp by pavon on Tuesday September 20, 2022 @05:01PM (#32917753)
No one will want to write GUI code that directly parses and generates XML, so every language will end up putting wrappers around that, and you are back to where you started with an expensive translation layer in-between.

Having a machine format that describes the interface and facilitates auto-generating the bindings, like GObject introspection is a better option and exists today. Even then the auto-generator will need to be custom for each language, to handle integration with the language's standard library data structures, memory management and the like.

Re:GTK4 Bindings for Common Lisp by carapace on Tuesday September 20, 2022 @09:06PM (#32919803)
> XML User Interface Language is a user interface markup language developed by Mozilla. XUL is an XML dialect for writing graphical user interfaces, enabling developers to write user interface elements in a manner similar to web pages.

https://en.wikipedia.org/wiki/Xul

Re:GTK4 Bindings for Common Lisp by JasonFruit on Tuesday September 20, 2022 @02:38PM (#32916024)
That way, your language can use any toolkit, such as WebKit or Gecko.
Re:GTK4 Bindings for Common Lisp by spicybright on Tuesday September 20, 2022 @04:26PM (#32917326)
If you did that, you limit what the API of a framework can do, you either can't use ones that fall outside that spec, or you have to jump through hacky hoops to get it working.

Experienced engineers know D.R.Y. has it's uses, but isn't a good hill to die on.

Re:GTK4 Bindings for Common Lisp by 13415 on Tuesday September 20, 2022 @02:22PM (#32915805)
What's the advantage? This merely seems to add another layer of abstraction.
Re:GTK4 Bindings for Common Lisp by bmitc on Wednesday September 21, 2022 @01:36AM (#32921161)
I'm not sure DRY applies across language boundaries. If a binding exists in one language, creating a binding in another isn't really repeating anything.
Re:GTK4 Bindings for Common Lisp by sylware on Tuesday September 20, 2022 @12:09PM (#32913754)
Does GTK4 finally implement its own C coded unicode text shaper (or at least, a roman script text shaper)? No I don't want that horrible c++ diareha which is harfbuzz.
Re:GTK4 Bindings for Common Lisp by audidude on Tuesday September 20, 2022 @03:38PM (#32916733)
Harfbuzz exposes a C API, why would you need to use C++?

Additionally, it works extremely well with GTK 4 via Pango and you can often interoperate between the two layers if you even need to touch a hb_face_t/etc. In fact, the only time I had to mess with Harfbuzz was when integrating GPU-rendered glyphs via Behdad's GLyphy shaders.

Re:GTK4 Bindings for Common Lisp by sylware on Tuesday September 20, 2022 @04:16PM (#32917208)
It has a C API, but it is written using c++. A long time ago, I did a build of GTK3, to remove the c++ dependency, I did an implemention of this C API in C, only for roman scripts though. I bet this C API was "obsolescence planned" and if I ever need GTK again (unlikely), I will code again a C implementation for roman scripts.

There is an alternative from IBM, ICU, it was properly coded in C, but it was switched to toxic c++.

Re:GTK4 Bindings for Common Lisp by audidude on Tuesday September 20, 2022 @04:40PM (#32917493)
Sounds like C++ has hurt you quite a bit.

I mean, I don't use it, and I've been writing C for a solid 25 years, but Behdad is one of the best engineers I've ever met in my life. So I definitely don't share your opinion of the code or the quality.

Re:GTK4 Bindings for Common Lisp by sylware on Tuesday September 20, 2022 @05:37PM (#32918137)
c++ is toxic for humanity because of its grotestquely and absurdely complex and massive syntax and its compilers. This is not a matter of opinion, this is an absolute unquestionable truth.

Carefull, I am not saying plain and simple C is better: it is only orders of magnitude less worse as there is already way too much in its syntax. Some would call that, the "most reasonable compromise".

Re:GTK4 Bindings for Common Lisp by pjmlp on Wednesday September 21, 2022 @04:18AM (#32922130)
So you also only use C compilers written in C, so no clang nor GCC for you I guess.
Re:GTK4 Bindings for Common Lisp by sylware on Wednesday September 21, 2022 @09:33AM (#32924927)
Indeed, I am currently trying to remove as much as I can gcc and llvm from my stack (I am now targetting much more, probably too much). llvm is financed by apple (vanguard/blackrock), and gcc by the MIT/redhat(IBM). I wish I had that much money to hire ppl in order to remove that toxic c++.
Re:GTK4 Bindings for Common Lisp by cowtools on Wednesday September 21, 2022 @12:27AM (#32920789)
There was article here the other day on a project by herb stutter to improve c++ syntax, I can link it to you if you want.

But I get the impression that the syntax is a fixable problem. Usually critics point so something like the template system or something.

Re:GTK4 Bindings for Common Lisp by audidude on Tuesday September 20, 2022 @06:03PM (#32918408)
Cool story.
Re:GTK4 Bindings for Common Lisp by sylware on Tuesday September 20, 2022 @06:36PM (#32918698)
The beyond sanity complexity of c++ is not a story unfortunately. The real sad story is that some ppl think they are smart because they code c++.
Re:GTK4 Bindings for Common Lisp by d_tr on Wednesday September 21, 2022 @06:02AM (#32922853)
The really sad story is the unjustified amount of shit C++ gets given its history and design goals.

C++ provides features to write much safer and nicer code than with C, for the same effort, with minimal overhead. You have proper constructors and destructors, smart pointers, the STL, templates, and much more.

Your comments in this thread make no sense.

Re:GTK4 Bindings for Common Lisp by sylware on Wednesday September 21, 2022 @08:20AM (#32923962)
It is perfectly sensible: c++ syntax and its compilers are grostesquely and absurdely massive and complex, and this is an issue.

There is no opinion here, just facts: for instance, due to the abysmaly (the word is fair) difference between c++ and C, it is reasonable for a team of averagely skilled individuals or individuals to write a naive C compiler, which is absolutely not the case for c++.

If you don't want to acknowlegde this is a issue, at least I tried to open your eyes on the matter.

Re:GTK4 Bindings for Common Lisp by colejohnson66 on Tuesday September 20, 2022 @12:32PM (#32914148)
What's wrong with Harfbuzz?
Re:GTK4 Bindings for Common Lisp by chris_wot on Tuesday September 20, 2022 @12:34PM (#32914180)
What is the problem with harfbuzz? we use it extensively in LibreOffice, works great!
Re:GTK4 Bindings for Common Lisp by nerdponx on Tuesday September 20, 2022 @01:39PM (#32915125)
I love that LibreOffice lets me use the full range of OpenType features in fonts. Do I have Harfbuzz to thank for that?

But please let me edit the sample text in the OpenType features modal, so I can actually see the effects of my changes without leaving the entire Font window :)

Re:GTK4 Bindings for Common Lisp by audidude on Tuesday September 20, 2022 @03:39PM (#32916756)
Re:GTK4 Bindings for Common Lisp by nerdponx on Tuesday September 20, 2022 @06:19PM (#32918558)
Based on the font chooser, absolutely. Thanks for this link.

...but did they fix the file picker yet?

Re:GTK4 Bindings for Common Lisp by chris_wot on Thursday September 22, 2022 @09:06PM (#32946728)
Without Harfbuzz, I doubt it would have been as easy to implement.