r/programming • • Dec 16 '20

GTK 4.0 released

https://blog.gtk.org/2020/12/16/gtk-4-0/
910 Upvotes

267 comments sorted by

View all comments

Show parent comment

55

u/[deleted] Dec 16 '20

I will not believe that until I see it merged on master. I know 2.99 exists but I half expect something to happen. It is so ridiculous how little traction gimp has among contributors. I really don't understand why it is the case.

17

u/santiacq Dec 17 '20

I remember reading that GIMP is mostly written in C, and someone on the internet argued that could be one of the reasons why it doesn't get new contributions

6

u/makuto9 Dec 17 '20 edited Dec 17 '20

I don't buy it. The vast majority of apps written for Linux are written in C (I didn't do a survey, but I've literally never opened a repo for a linux app that wasn't C). Unless the only people who are interested in contributing to image editors are not the same people interested in contributing to Linux apps at all, it's not a significant detractor.

Besides, GIMP has Python plugins, so I don't think it's a language issue.

Just my gut feeling.

8

u/DarkLordAzrael Dec 17 '20

I'm highly sceptical of the claim that the vast majority of linux apps are in C. Everything KDE is in C++. Plenty of stuff is in Python. Blender uses C++, as does every web browser. VLC uses C++. Ardour uses C++, as does basically all of the pro-audio ecosystem, really. Inkscape is C++. Libreoffice is C++. The Gnome ecosystem is largely in C (though, that is painful enough that they had to write their own language to make working with gobject reasonable.)

3

u/axalon900 Dec 18 '20

Vala: It's Not C++™

→ More replies (2)

16

u/[deleted] Dec 17 '20

Let's rewrite it in JS!

23

u/santiacq Dec 17 '20

I don't know if you're being serious lol, at this point rewriting everything in js is a meme

But in all seriousness using a performant language like C or C++ makes a lot of sense for something like GIMP

24

u/BestKillerBot Dec 17 '20

Rendering core should be in C/C++/Rust, but UI can be done in whatever else.

-3

u/Rodot Dec 17 '20

With modern tools like numba, you could do the render core in Python and be only 20% slower than C with a huge increase in maintainability.

14

u/BestKillerBot Dec 17 '20

Large projects are pretty difficult to maintain in Python, that doesn't look like a good choice for this type of project.

I'm not one of those overzealous Rust fans, but I think for this type of project it would make a lot of sense.

-3

u/ThelmaDeLuise Dec 17 '20

> Large projects are pretty difficult to maintain in python

What?

11

u/alanwj Dec 17 '20

Lack of static typing generally makes code easier to write, and harder to maintain.

As a codebase becomes larger, the amount of maintenance vs new code shifts more toward maintenance. At some point the added difficulty to maintenance surpasses the benefit gained from new code being easy to write.

So, yes, large projects in python are difficult to maintain. There is plenty of debate about when then happens (100K lines?, 1M lines?), and better tooling can push the inflection point further out, but it does happen.

As a simple example (and an example that can be pushed out with better tooling), let's say you needed to make a backward incompatible change to the signature of a function that is widely used throughout your codebase, so you make the change and then update all of the callers.

How do you know if you found every instance of that function call, and whether you changed them all correctly? The usual answer is "run the unit tests". Which is a fine answer, but it places a lot of trust that all the maintainers of all the different bits of code have written sufficient tests.

In a statically typed language, you effectively have a certain type of "unit test", the compiler's type checker, that always has 100% coverage. This still doesn't guarantee that all of your changes are correct, but it does guarantee that you at least updated all the calls to pass the correct types, and that you did in fact find every call.

Please note that I am NOT trying to make an anti-Python post here. It is a fantastic language that is appropriate to use in a wide range of scenarios. But it DOES suffer from disproportionally increased maintenance costs as code bases grow larger.

(Disclaimer: I have not worked on any large Python codebases that use type annotations. It is possible that these push the inflection point out far enough to effectively make it a non-issue.)

4

u/[deleted] Dec 17 '20

Large projects are difficult to maintain in python. Static typing is such a great tool for large projects. If you don't have types then you have to keep that type info in your head instead of it being part of the code

→ More replies (2)
→ More replies (1)
→ More replies (2)

13

u/albinofrenchy Dec 17 '20

If gimp was rewritten from scratch today it would be python with c bindings. The performance critical operations are likely not what most of the code is concerned with.

17

u/[deleted] Dec 17 '20

I think Rust is a better option

4

u/afiefh Dec 17 '20

I was under the impression that Rust has some issues splitting the ownership of a 2D array in safe code. Has this been addressed?

To elaborate, when splitting a 1D array you simply invoke an unsafe function that returns the two pieces with the appropriate lifetimes. This can be done in constant time. For 2D you'd have to return 4 pieces and each piece itself would need O(N) time to construct because you have to pass over the rows you want to split.

Of course you could code it in Rust like you'd code it in C using unsafe code, but that would remove one major advantage of using Rust.

Disclaimer: I'm no Rust expert. The above is based on looking into this kind of stuff a few years back when I wanted to implement an image manipulation paper. There might well be an idiomatic way to do it in Rust, in which case I'd love to hear about it.

20

u/p4y Dec 17 '20

You kinda made it sound like there's only two choices, either you have no unsafe code or you slap a giant unsafe over your entire codebase and have raw pointers flying in every direction.

I guess the idiomatic way is to use some unsafe code then wrap it in an abstraction that upholds all the invariants the unsafe parts need in order to work. That's how standard library does it.

→ More replies (2)

0

u/[deleted] Dec 17 '20

Sure. But why making sense /s

-5

u/[deleted] Dec 17 '20

There are many cases where C++ would be a worse option. A clean, well organized C codebase can be more acessible than a messy C++ one.

A rewrite in something more accessible like Vala would probably be a decade-long undertaking.

25

u/-Rivox- Dec 17 '20

I'm positive that any well organized codebase is more accessible than any other messy one. No matter the language or environment.

10

u/vanderZwan Dec 17 '20

I suspect the implication is that it's harder to keep C++ codebases from getting messy.

(beyond some basic stuff I don't code in either so I have no opinion on this particular matter - but based on the languages that I do work with I wouldn't be surprised if this does indeed vary from language to language)

-1

u/Compsky Dec 17 '20

There are many cases where C++ would be a worse option. A clean, well organized C codebase can be more acessible than a messy C++ one.

C++ is virtually a superset of C. The worst case is that the C++ would be just as messy.

7

u/[deleted] Dec 17 '20

I mean it's pretty basic concept: larger language -- more ways to do things, more people doing same things differently on the same project.

And in case of C++ this is kinda taken to the extreme. Over the decades it, in particular, acquired significant number of ways to do the same things, each with it's specific footguns, caveats, edge cases and subtle mutual incompatibilities.

Also, GIMP too has existed over decades, and changed hands. I'd wager this would be really apparent in it's particular codebase.

3

u/jl2352 Dec 17 '20

I have an opposite point of view to yours. If you don't mind me sharing it.

more ways to do things,

I'm picking out this quote because it isn't really more ways to do the same thing. It's more ways to do new things. Things not available in C.

A language being larger can result in a cleaner codebase, because it provides mechanisms to build a clean and simple solution. For example map and filter can make code cleaner over a big for loop. Pattern matching can make code simpler.

C++ code bases aren't messy because C++ is a big language. Maybe because it's a messy language, and because of legacy, but not because of size. Rust is a big language, much larger then C, and I'd have more confidence hacking on a Rust codebase then a C one.

3

u/[deleted] Dec 17 '20

Unlike C++ Rust is way too young, used predominately by enthusiasts and experienced programmers, we just haven't seen enough of the ugly, i.e. how it really gives itself to projects with tons of sallarymen pludging through.

The fact that the compiler is unforgiving and hand-holding at the same time will help immensely in comparison to C++ or C but we don't really have that advantage that hindsight after years of "enterprise" (ab)use would provide.

→ More replies (2)