News for hackers. Stuff that matters.
Re:File for Divorce from LLVM by wyldfire on Friday June 30, 2023 @01:27AM (#36530849)
Andrew is super sharp so I imagine he and the team will get there now that it's declared as a goal.

But man, it seems to me (uneducated on the challenges zig faces w/LLVM) that this shifts the team's capacity away from zig and towards things like binutils. When I read the headline I assumed that they were throwing out the compiler (IIRC they had mostly/totally excised it already). But for a project like zig it just seems like there's a lot to be gained from keeping it.

That said -- the prospect of rewriting a lot of the stuff that's in the LLVM project now in zig instead of c++ - that's pretty cool and ambitious. Just as ambitious as it was for Lattner to create LLVM, I suppose.

But code that's accidentally quadratic - well, that's bound to happen to zig too, if it's as popular and useful as LLVM project is.

Re:File for Divorce from LLVM by Hermitian909 on Friday June 30, 2023 @01:54AM (#36531038)
I'm reminded of a recent interview with Chris Latner about the success of Swift - he credits the success to the fact that you could start with a large objective C project and begin writing Swift without rewriting anything. Part of Rust's success is off the back of a similar compatibility with C/C++.

It is difficult for me to imagine Zig succeeding without a similar capability - which is to say I hope they do not follow through on this milestone.

Re:File for Divorce from LLVM by Ashymad on Friday June 30, 2023 @02:26AM (#36531247)
But rust absolutely does not have any C/C++ compatibilty besides arguably very good FFI. And that's where zig shines. They have a c/c++ compiler built into the zig compiler via zig cc, that's even easier to use than clang or GCC due to having the benefits of a buildscript and baked in libcs for different architectures, making crosscompilation a breeze.

In zig you _can_ actually start with a c codebase and rewrite it file by file in zig and you _can_ include c headers in your zig files verbatim. Both of these are not possible in rust.

This milestone is only gonna remove the c++ (and objective c/c++) compiler for now from zig cc. So while you could argue this will ostracize people rewriting their c++ codebases in zig, I don't imagine there's actually many people like that. EDIT: I just looked at the discussion and there's actually a lot of people that use the c++ capapbilities.

Re:File for Divorce from LLVM by colinsane on Friday June 30, 2023 @03:25AM (#36531633)
> In zig you _can_ actually start with a c codebase and rewrite it file by file in zig and you _can_ include c headers in your zig files verbatim. Both of these are not possible in rust.

well, you can: i have done this, with Rust. but yes, it’s more the type of thing that well-resourced companies do rather than solo devs, because even with Bindgen and the like Rust really wants the atomic codegen unit to be the “library”, not C’s notion of a “compilation unit”. still, C FFI compatibility is exactly why porting from C to rust incrementally is feasible while C to, say Java, is probably a bigger leap.

Re:File for Divorce from LLVM by flohofwoe on Friday June 30, 2023 @05:08AM (#36532253)
You still need a separate compiler toolchain next to Rust in order to compile the C, C++ and ObjC dependencies which is a massive build system headache (especially across UNIX-oids and Windows).

In Zig that all "just works" with the standard Zig install.

Re:File for Divorce from LLVM by duped on Friday June 30, 2023 @10:20AM (#36535411)
Show me a C/C++ project that doesn't need a build system.
Re:File for Divorce from LLVM by flohofwoe on Friday June 30, 2023 @10:56AM (#36535988)
My stuff for instance:

https://github.com/floooh/sokol

...inspired by:

https://github.com/nothings/stb

(here's how the sokol headers are integrated into a Zig project, note that there is only a build.zig which builds everything: https://github.com/floooh/kc85.zig)

But it's not so much about build systems, but requiring a separate compiler toolchain to build any C++ or ObjC dependencies (Rust needs this, Zig currently does not - unless that controversial proposal is implemented).

(also even complex C++ libraries can be wrapped in a build.zig, so you don't require a separate build system like cmake for the C++ dependencies)

Re:File for Divorce from LLVM by duped on Friday June 30, 2023 @11:45AM (#36537058)
I still don't see why this is a problem. Single-header dependencies are cute but blow up compile times, and most of the world needs CMake/Meson/Autotools anyways so there's not an added cost to using it for your own projects.

Similarly I don't really understand why you want one toolchain for a multi-language project. It's not that useful or convenient since it's going to need to be orchestrated with a buildsystem somehow.

Like with Rust, you probably only have a build.rs file. It invokes a separate (possibly multiple) toolchains. Or with CMake. A simple project has a single CMakeLists.txt that can invoke any number of toolchains. I don't see why zig can't do that with a build.zig file, or why it matters.

Re:File for Divorce from LLVM by flohofwoe on Friday June 30, 2023 @12:19PM (#36537722)
Did you try the stuff you are proposing? This is all a royal pita in real world projects which the Zig toolchain solved wonderfully.

(also it's a myth that STB style libs increase compile time, that's only true for typical C++ single header libs with inline methods and template code)

Re:File for Divorce from LLVM by higherhalf on Friday June 30, 2023 @05:11AM (#36532266)
> But rust absolutely does not have any C/C++ compatibilty besides [..]

> In zig you _can_ actually start with a c codebase and rewrite it file by file in zig and you _can_ include c headers in your zig files verbatim. Both of these are not possible in rust.

You can. Either via FFI and bindgen-ing headers, or by using c2rust. The latter is not just a toy ambitious project, but actually a very impressive piece of engineering and does produce a result where you can transpile a project or file and start rewriting file-by-file or function-by-function.

Re:File for Divorce from LLVM by the_duke on Friday June 30, 2023 @07:20AM (#36532989)
c2rust is definitely cool, but it also supports transpiling to a single architecture, which often misses a lot of architecture dependent code and specialisations in real world c code. Especially because it has to do macro expansion and you only get the expanded code.

It also doesn't supportal a good amount of more complicated c features.

It's a help for sure, but the few times I tried I ended up just doing the rewrite by hand instead to actually cover all the cases.

Re:File for Divorce from LLVM by flohofwoe on Friday June 30, 2023 @05:28AM (#36532353)
Can Swift really be called a success when it's only being used in the very narrow niche (the Apple software ecosystem - and only because it's essentially dicated by the platform owner)?
Re:File for Divorce from LLVM by pjmlp on Friday June 30, 2023 @05:47AM (#36532458)
Yes, that is how languages become a success on the market, either being pushed by the platform owner no matter what, or by having a framework written in them that everyone feels like using.

Everything else are aspiring extras in the cinema of programing languages, waiting on the sidelines for that major role that will come someday, it really will, one just has to believe enough.

Re:File for Divorce from LLVM by mike_hearn on Friday June 30, 2023 @06:19AM (#36532607)
Counter-example: Kotlin.
Re:File for Divorce from LLVM by doctor_eval on Friday June 30, 2023 @07:37AM (#36533134)
How is that a counter example? Doesn’t Kotlin fulfil a similar role for Android?
Re:File for Divorce from LLVM by mike_hearn on Friday June 30, 2023 @11:22AM (#36536560)
Kotlin wasn't created by Google and wasn't pushed by them. It's more like they accepted it because the Android developer base was adopting it organically en-masse anyway. That's also the case for many other places where Java is used.
Re:File for Divorce from LLVM by pjmlp on Friday June 30, 2023 @11:30AM (#36536755)
It was pushed by Android team, the same folks that came up with Jetpack stuff.

Additionally JetBrains has their fingers all over the place in Android.

Kotlin, Android Studio a mix of InteliJ and Clion, Compose,...

Re:File for Divorce from LLVM by still_grokking on Friday June 30, 2023 @08:10AM (#36533460)
That's not a counter example:

https://miro.medium.com/v2/resize:fit:720/format:webp/1*sojK...

Kotlin would be likely still nowhere without Google and Android.

Re:File for Divorce from LLVM by pjmlp on Friday June 30, 2023 @08:37AM (#36533786)
Not at all, given the way Google is pushing it on Android, they are even mischievous enough to compare Kotlin with Java 6 when going on about why Kotlin.

For all practical purposes ART has turned into the Kotlin Virtual Machine.

However it so happens, that to keep the advantage of using Java libraries in the Android ecosystem, they actually need to support newer Java libraries unless they feel like rewriting all of them into Kotlin.

So Android 12 and 13 got a subset of Java 11 LTS, and Android 14 is getting Java 17 LTS support.

That doesn't change the reasoning that Android is all about Kotlin nowadays, unless one is writing platform code itself.

Re:File for Divorce from LLVM by mike_hearn on Friday June 30, 2023 @11:21AM (#36536544)
The idea Kotlin wouldn't be successful without Android isn't right. It was taking off in a big way even before Android did anything with it officially. Google's stated rationale for adopting it was because developers were already migrating to it regardless of what Google wanted.
Re:File for Divorce from LLVM by pjmlp on Friday June 30, 2023 @11:28AM (#36536697)
Bollocks, everyone was trying to use Scala as alternative.

Google is in bed with JetBrains in what concerns Android.

Re:File for Divorce from LLVM by throwawaymaths on Saturday July 01, 2023 @01:33AM (#36546950)
Counterexample: python
Re:File for Divorce from LLVM by Aerbil313 on Monday July 03, 2023 @12:28PM (#36575263)
Yeah, python filled an essential gap of a easy, high level language.
Re:File for Divorce from LLVM by masklinn on Friday June 30, 2023 @02:45AM (#36531370)
> Just as ambitious as it was for Lattner to create LLVM, I suppose.

A big difference is there was an element of no choice to LLVM, at least in Apple’s takeover of the project: GCC didn’t want to allow / do what Apple wanted / needed out of it.

Re:File for Divorce from LLVM by whizzter on Friday June 30, 2023 @04:22AM (#36532007)
binutils is quite a bit of a jack-of-all-trades code for handling binary code formats in portable ways, a compiler doesn't need half of it (incl legacy) if you focus it more like TCC, the larger part will be code-generation across a bunch of architectures.
Re:File for Divorce from LLVM by jimwhite42 on Friday June 30, 2023 @07:14AM (#36532944)
There's a document that I think was an unofficial project management document from NASA, I can't find it now, but one of the items was something along the lines of 'if your space mission isn't reusing an existing launch vehicle, it will be a launch vehicle development project and everything else, including what you think is the focus of your mission, will be secondary to this'.

Edit: additional bit I remembered, this statement is prefixed with something like 'you may start thinking you project will be cheaper/more efficient if you develop a launch vehicle suited to your particular mission instead of compromising on an existing one, but', then the above.

Re:File for Divorce from LLVM by runlevel1 on Friday June 30, 2023 @08:30AM (#36533717)
Akin's Laws of Spacecraft Design

https://spacecraft.ssl.umd.edu/akins_laws.html

Re:File for Divorce from LLVM by cbsks on Friday June 30, 2023 @10:38AM (#36535698)
The relevant law is:

39. Any exploration program which "just happens" to include a new launch vehicle is, de facto, a launch vehicle program.

Re:File for Divorce from LLVM by von_lohengramm on Friday June 30, 2023 @01:55PM (#36539342)
> now that it's declared as a goal

No. It's an unaccepted proposal.

Re:File for Divorce from LLVM by tredre3 on Friday June 30, 2023 @02:20PM (#36539740)
By the creator and benevolent dictator of the Zig language.

I think it's same to assume it's an official goal, now.

Re:File for Divorce from LLVM by somethingor on Friday June 30, 2023 @04:44PM (#36541996)
Here’s a list of rejected proposals made by the BDFL:

https://github.com/ziglang/zig/issues?q=is%3Aissue+label%3Ap...

Re:File for Divorce from LLVM by TUSF on Friday June 30, 2023 @05:45PM (#36542796)
And most of those were rejected without all that much pushback, as opposed to this one where there's about 100 comments already.