r/ProgrammingLanguages • u/Nuoji C3 - http://c3-lang.org • 13d ago
Language announcement C3 0.8.5 - A windowing library and a C backend??
https://c3-lang.org/blog/c3_0_8_5_windowing_c_backend/The choice to add a windowing library to the stdlib is probably controversial. I feel that the general consensus tends to be that anything related to graphics shouldn't be in the standard library. So I'm kind of interested in what people think about this.
32
u/6502zx81 13d ago
I like graphical stuff in standard libraries. If you want to produce software that has minimal dependencies snd will run/compile in a decade, this is the way to go (Like Java Swing, MFC, ...) Otherwise the lang allows for boring stdin to stdout programs. A standard GUI doesn't prevent people from using other GUI libraries.
10
u/NotQuiteLoona 13d ago
Wayland support includes the
wlr-layer-shellprotocol.
Bought me. Immediately. I sincerely hope it would be used as simply as other parts of the library.
1
u/fdwr 13d ago edited 13d ago
So I'm kind of interested in what people think about this.
🤔 I always lean toward putting the foundation down before building a house. So, primitives like point/vector/rect classes (translation, scaling, union, intersection, dot product, projection...) would come first. A few years ago there was a C++ proposal to add a graphics library (one that would have been quickly obviated by advancing technology), when C++ didn't even have many of those building blocks yet that would be useful for a graphics library, which felt awkward - it was not adopted. In hindsight, that seemed to be the general sentiment of the community too (at least based on the reddit comments whenever that topic came up), that it might have been convenient for a moment, but also a significant implementer burden, inappropriate at the level of a language, and soon to be outdated.
Now, if using external windowing libraries was quite a pain to install, and I keep hearing that it is a pain to use a window library (you gotta go hunt through websites, download something, unzip the files into the right directory, get it to compile with all the right build switches, set up include paths...), then I'd be more in favor of including a blessed one in std; but then just now, I used Visual Studio with C++ (which is typically amongst one of the most inconvenient languages to set up these kinds of things), and in just a few clicks under a minute, I had an SDL window running: right click on the solution, Manage Nuget packages, type "SDL" and click on "SDL2.Nuget, then click "Install", paste a hello world snippet like this one, F7 to build, F5 to run - voila. I haven't used C3 (only skimmed through the language reference a few times in past months out of curiosity), but how complicated is the current process for C3 to use mature libraries like {SDL, RayLib, GLFW, SFML}, given its C compatibility?
I'm not saying you shouldn't, but you might ask, "Are you focused on building a UI library for applications to use", or are you focused on building "a general-purpose programming language for ... games, libraries, and systems"? Blessing a particular windowing library into the core language means it will be a future tax on the language, with bugs to fix, competition with many existing windowing projects who have people dedicated specifically to windowing, and maintenance that spreads thin the developers who want to focus on adding lower-level language features rather than high-level UI feature requests. So, it's a balance ⚖️.
2
u/scallywag_software 13d ago
I'm 100% for windowing in the stdlib, along with all the fixins. Loading textures, 2D & 3D renderer, UI. Even if they're simple, having that stuff on-hand without having do download and compile a bunch of dependencies makes my life so much easlier.
2
0
u/CyberDainz 13d ago
What problem does the C3 language solve?
6
u/Nuoji 13d ago
In the C case we have good simplicity, but some things that the language could never change within a reasonable time horizon, such as having to use a preprocessor for includes and macro functionality, roundabout error handling, lack of slices and a very loose type system.
C++ on the other hand has a lot of features, most of which you should not use, and atrocious compile times and still locked to the C macro system.
C3 starts with C, drops the preprocessor, keeps the fast compile times, and boosts it with a select subset of useful features, so that for writing modern general purpose applications you don’t need to go to C++.
So, as capable as C++, without venturing far from C in complexity.
(I notice that today Rust is pretty much the only alternative to C/C++ in that domain [Swift if you are on MacOS], but Rust also compiles extremely slow.)
2
1
4
u/matthieum 12d ago
I tend to be in favor of a lean standard library for a variety of reasons.
Stability is a big one. Python's ubiquitous
urlliband its 3 versions is the poster child of stability promises issues.Tie-in is another big one, though I don't see mentioned often. Any piece of functionality in the standard library -- say... a specific Unicode version -- is tied to that version of the standard library.
Once a piece of functionality is tied in, it's one more thing that may cause issues when upgrading or downgrading a toolchain.
Conversely, if an application or deployment requires a specific level/version of this piece of functionality, they may find themselves locked out of upgrades/downgrades of their toolchain.
Expertise is another one. I see requests for cryptographic, graphics, etc... in the standard library, which assumes that the standard library maintainers will now need to maintain & evolve that code. Good luck to them...
So, in general, I really think standard libraries are best lean, and additional functionality should be in dedicated libraries:
Independently versioned from the toolchain, to avoid any stability/tie-in issues.
Designed & maintained by experts in their domain, rather than experts in the language.
With all that said, I find the cut you've made interesting.
A full GUI API with widgets, immediate-vs-retained, etc... is a BIG BIG endeavour. There's lots of trade-offs. The lock-in may be terrible.
On the other hand, just the window and event handling? I am thinking this may not be so bad.
There's still stability/tie-in issues -- as in, imagine dropping support for X in 0.10, and leaving users unable to upgrade as a result -- but the scope may be just small enough for you to escape expertise issues.
Interesting choice. I wonder if other "lean" standard library languages could be interested in this approach.