http://www.devheads.net/desktop/gnome/user/how-about-adopting-kotlin-gnome.htm
By Tony Houghton at 11/18/2017 - 09:11
I've been thinking about what language I should choose if and when I
start writing a significant program using G* libraries. I don't want to
write GObjects in C any more. All that boilerplate, casting macros,
manual set up of vtables and explicit reference counting. I will make
mistakes with it.
C++ is an improvement, but tends to add more complexity and is still
prone to runtime bugs such as buffer overruns, and there are some quirks
in its G* bindings.
Vala is very attractive, but I'm afraid I have to side with the
doomsayers. The compiler doesn't have enough developers with the time
and expertise to maintain it adequately. That's frustrating enough when
you're relying on any project, but when it's a compiler it's even more
serious. Maybe its poor health has been exaggerated, and its benefits
outweigh the risks (after all, it seems to have an entire desktop
environment banking on it), but I'm not filled with confident.
So there's Python. It's rather nice, especially if you use type
annotations to get at least half-decent auto-completion in your
IDE/editor and the ability to catch some bugs before runtime. It's well
supported. But... its runtime has a poor reputation for efficiency, and
it can't truly multithread on multiple cores. Its GI bindings are
somewhat opaque ie it's difficult to find out what members a class has,
or a function's signature, if separate documentation hasn't been provided.
I see Rust is getting popular, but it appears to be difficult to learn,
and it doesn't have an object model that would make GObject fit in
naturally.
I've been writing an Android app in Kotlin for a few weeks. It takes a
bit more getting used to than Java or Vala for a C programmer, but I'm
enjoying it, and nobody seems to have a bad thing to say about it. I
thought it might even be worth using the JVM on Linux desktops/servers
for, but now I've discovered there's an LLVM target too, Kotlin-Native.
Look at this:
<https://victor.kropp.name/blog/kotlin-native-0.2-and-gtk/>. That DSL
implementation is so cool. Kotlin's object model in general fits quite
well with GObject I think, eg its interfaces support concrete methods
and abstract properties. It shouldn't be hugely difficult to develop an
automatic gir-to-Kotlin bindings generator.
One fly in the ointment is that Kotlin-Native doesn't have IDE support
yet, but that will come. It looks like using the JVM for development in
the meantime isn't really viable, unless whoever writes the bindings
generator is prepared to support two different modes, because it looks
like Kotlin-Native has its own way of interfacing with C that's
different from the JNI used by the JVM version.
Comments
Re: How about adopting Kotlin in GNOME?
By Adam Tauno Williams at 11/18/2017 - 18:11
On Sat, 2017-11-18 at 14:11 +0000, Tony Houghton wrote:
I thought I saw that Javascript was going to the language of choice for
GNOME - yet I haven't seem much else on that front.
Your question is an important one - I've been thinking the opposite -
that perhaps it is best to abandon the 'nicer' languages and just go
back to C. More boilerplate perhaps - but less drama.
Ditto. It looks like C# to me - mono on GNOME was great - but the
momentum is gone. Not something I want to make a wager on.
The one contender with C, IMO.
As someone who had many tens of thousands of lines of code in Python -
the multi-threaded issues are ***GROSSLY*** exagerated. It is not a
real-world problem.
Absolutely true; to often the answer is "look at the C docs and try to
translate". Which is a serious waste of time.
Re: How about adopting Kotlin in GNOME?
By Tony Houghton at 11/19/2017 - 08:03
On 18/11/17 23:11, Adam Tauno Williams wrote:
That was mentioned in at least one of the articles I read about Vala,
mainly this one I think:
<https://blogs.gnome.org/mcatanzaro/2017/02/19/on-problems-with-vala/>.
I don't think Javascript is that terrible, and it's getting better, but
it's always going to be difficult to find bugs (probably considerably
harder with gjs than in a browser), and you have to use some weird
idioms to make its OOP work like other languages. The main problem for
gjs is its bindings, so it's almost the opposite of Vala. Overall I
really don't understand why they chose that over python.
The trouble is the boilerplate has a lot of potential to add drama if
you make a mistake. "Nicer" languages not only save you the work, but
also make sure it's correct (well, that's the theory). Did you ever use
GObjectBuilder (gob)? That was really nice, you would write object
declarations in a Vala-like style and function bodies (which were
declared inline; each gob file would generate both a .h and .c) in
almost pure C. Nowadays the project is unmaintained. I think it was a
one-person effort, so it should be possible for another individual to
pick it up and do any necessary maintenance. But the big drawback for me
is that since being spoilt by developing for Android, I would really
miss auto-completion and edit-time error detection. I managed to write a
usable vim syntax definition for it, based heavily on C's, but
completion etc is a whole other level.
I suspect Mono would be completely dead if it wasn't for Unity3D. Any
project that hasn't converted from GTK2 to GTK3 by now shows that it's
either desperately short of developer hours or the developers don't care
about the future (or even the present) of their project. GTK2 is not OK
any more, it's terrible with hidpi scaling enabled.
Yeah, that's not really a problem for desktop or server applications.
But it would put me off using it for writing games (even though simple
games don't need multiple cores), and I suspect it's holding it back a
bit in scientific circles too.
Re: How about adopting Kotlin in GNOME?
By Arnaud at 11/18/2017 - 22:12
There's <a href="https://lazka.github.io/pgi-docs/" title="https://lazka.github.io/pgi-docs/">https://lazka.github.io/pgi-docs/</a> for the docs, it does the job
most of the time.
Re: How about adopting Kotlin in GNOME?
By Adam Tauno Williams at 11/18/2017 - 18:15
On Sat, 2017-11-18 at 18:11 -0500, Adam Tauno Williams wrote:
One advantage of Python is the existence of a World Class ORM -
SQLalchemy - and I have a hard to imagine writing any non-trivial
application without an ORM. If there was an equivalent for
JavaScript/GJS it would be far more tempting.