Live data from Hacker News

Zig self hosted compiler is now capable of building itself

github.com

131–140 of 285 posts

Re: Zig self hosted compiler is now capable of building itself

#131
post #95

Earlier quoted context omitted.

And as we know from C, every developer is quite capable of taking care of use after free possible bugs.

The point of C and Zig is that you can solve any kind of problems with them. In particular there is much more to memory reclamation than garbage collectors or Rust's borrow checker. Some of the reclamation schemes offer wait-freedom, or efficiently support linearizable operations.

Any kind of problem?

So how do you solve SIMD with C, without language extensions?

C is not a special snowflake.

Re: Zig self hosted compiler is now capable of building itself

#132
post #130
post #16

Earlier quoted context omitted.

Kotlin has seen fantastic adoption in Android projects, because of the way Google pushes it, while stagnating Android Java on purpose. On the JVM world not really. https://www.infoq.com/news/2022/03/jrebel-report-2022/

That poll pours a cold bucket of water on “fantastic adoption” among all the respondents, but compare adoption of Kotlin and Java releases after Kotlin’s release. 1 in 6 respondents using language versions after 2016 are using Kotlin. I don’t think that’s too shabby.

Java is still Java, regardless of the version, otherwise we should add Kotlin versions to the discussion as well.

Re: Zig self hosted compiler is now capable of building itself

#133
post #120
post #26

Earlier quoted context omitted.

You have missed all the Kotlin only Jetpack libraries, NDK documentation now using Kotlin, Jetpack libraries originally released in Java now rewritten in Kotlin. They are still using Android Java on the system layers, because they aren't rewriting the whole stack. Even the update for Java 11 LTS subset on Android 13 is mostly likely caused by the Java ecosystem moving forward, than the willingness of Android team to…

> You have missed all the Kotlin only Jetpack libraries, NDK documentation now using Kotlin, Jetpack libraries originally released in Java now rewritten in Kotlin. Also, Oracle's lawsuit against Google for copying Java APIs.

This doesn't compute, because Kotlin is heavily dependent on the Java ecosystem, regardless how Google screw up Sun and the Java community with their Android Java.

Re: Zig self hosted compiler is now capable of building itself

#134
post #16
post #8

Earlier quoted context omitted.

Zig as the “Kotlin of C” makes it very appealing. Kotlin has seen fantastic adoption in JVM projects because you can convert files one at a time from .java to .kt, with only a modicum of one-time build system shenanigans up front. Then your team can gain experience gradually, fill in missing pieces like linters over time, all without redesigning your software. What zig offers is even better - because zig included a C…

Kotlin has seen fantastic adoption in Android projects, because of the way Google pushes it, while stagnating Android Java on purpose. On the JVM world not really. https://www.infoq.com/news/2022/03/jrebel-report-2022/

Huh. I read about this the other day as well - https://news.ycombinator.com/item?id=30842602:

> If only [Oracle] hadn't sued Google, Java would still have been the pre-eminent language for Android development. Sadly Android is stuck at legacy Java 8 permanently now. So, modern Java is stuck as a server-side language with dozens of competitors.

A reply argued that Android is on Java 11 now, and then you noted (hi!) that it's "a subset". Huh.

I'm trying to get a handle on understanding the ramifications of the legal/licensing situation, and the actual concrete impact on Java's use in Android. The subject seems somewhat murky and opaque. Is there possibly a high-level disambiguation about what's going on published anywhere?

Re: Zig self hosted compiler is now capable of building itself

#135

I was thinking of learning Rust but it seems a bit overkill due to manual memory management as compared to languages with similar speed like Nim, Zig, and Crystal. How would one compare these languages? Is it worth learning Rust or Zig and dealing with the borrow checker or manual memory management in general, or are GC languages like Nim or Crystal good enough? I'm not doing any embedded programming by the way, just…

It's funny i came to Rust from Go, Python, NodeJS, etc after a combined .. 15 years or so. I've been using Rust full time (work & home) for ~2 years now. Obviously i'm biased, but i quite enjoy it. I find i am more efficient now than before, because it manages to give me the ease of the "easier" languages quite often with a rich set of tooling when i need to go deeper. Personally i feel the concern over the borrow ch…

The problem is that when lifetimes cause you problems, it can force the entire feature development to stop until the problem is fixed. There is no reasonable escape hatch or alternative (clone doesn't always work).

Re: Zig self hosted compiler is now capable of building itself

#136

I was thinking of learning Rust but it seems a bit overkill due to manual memory management as compared to languages with similar speed like Nim, Zig, and Crystal. How would one compare these languages? Is it worth learning Rust or Zig and dealing with the borrow checker or manual memory management in general, or are GC languages like Nim or Crystal good enough? I'm not doing any embedded programming by the way, just…

It's funny i came to Rust from Go, Python, NodeJS, etc after a combined .. 15 years or so. I've been using Rust full time (work & home) for ~2 years now. Obviously i'm biased, but i quite enjoy it. I find i am more efficient now than before, because it manages to give me the ease of the "easier" languages quite often with a rich set of tooling when i need to go deeper. Personally i feel the concern over the borrow ch…

> Personally i feel the concern over the borrow checker is way overblown. 95% of the time the borrow checker is very simple.

I have been using Rust professionally as well and had a different experience. For anything singlethreaded I agree with you. For any asynchronous behavior, whether it's threads or async or callbacks, the borrow checker gets very stubborn. As a response, people just Arc-Mutex everything, at which point you might as well have used a GC language and saved yourself the headache.

However, enums with pattern matching and the trait system is still unbeatable and I miss it in other languages.

Re: Zig self hosted compiler is now capable of building itself

#137
post #117

Earlier quoted context omitted.

Crystal doesn't have built-in support for parallelism, let alone production-grade support. This is a significant lack for a modern language. For a language that is around 8 years old, this may be a serious problem, since the surrounding ecosystem has been probably written without parallelism in mind, and it may take a very long time to be updated (if ever).

> Crystal doesn't have built-in support for parallelism They do, but it is hidden inside a compiler flag, if you compile your prject with `Dpreview_mt` then it will come with multi-threaded support. This has been an experimental feature for a few year though, and there is not much improvement since it first got introduced. Personally I don't use crystal for this kind of feature, and it runs stable enough when I use i…

I use PyPy for such cases. Is Crystal better than PyPy?

Re: Zig self hosted compiler is now capable of building itself

#138

Earlier quoted context omitted.

> because automatic deallocations lead to hard-to-predict lifetimes (excess memory usage, and bugs for resource handles that are destructed at hard to predict moments). I don't really feel this is the case in Rust.

But it is. If you have a String on the stack, it's memory is only reclaimed at the end of the scope, while it often could be free'd before. This is especially bad in async code around await point since it means the memory need to be kept alive more than needed.

I disagree. It is substantially and unequivocally better to hold onto memory until the end of scope than to leak memory by default. How can anyone argue that leaking memory is a better default? That’s a ticking time bomb. Maybe someone is so optimistic as to believe they’ll catch every leak before shipping new code?

You can easily add a manual “drop” call in Rust at any point if you want to force an allocation to be freed sooner, but I speak from years of experience using Rust for work when I say that Rust’s RAII model is not problematic in practice. I’m not simply speculating or theorizing, and I have professional experience with a variety of languages at all levels of the stack. I personally don’t mind garbage collectors most of the time, but Rust is great when you need more control.

In C++, RAII can absolutely be problematic because you are able to easily do things that cause undefined behavior by accident, which is arguably worse than either leaking by default or the mere act of holding onto memory for the duration of a scope.

If you can propose a system which cannot be contrived to have any downside, that would be fantastic! In the real world, Rust’s approach to memory management is extremely pragmatic and beneficial. I’m sure someone will eventually improve on Rust’s approach, but “leak by default” isn’t it.

I honestly do enjoy following Zig… it is a fascinating language taking a really interesting approach to solving many problems, but its memory safety story is not where I want it to be yet. Leaking memory by default is technically safe, but it's not exactly endearing.

Re: Zig self hosted compiler is now capable of building itself

#139
post #133
post #120

Earlier quoted context omitted.

> You have missed all the Kotlin only Jetpack libraries, NDK documentation now using Kotlin, Jetpack libraries originally released in Java now rewritten in Kotlin. Also, Oracle's lawsuit against Google for copying Java APIs.

This doesn't compute, because Kotlin is heavily dependent on the Java ecosystem, regardless how Google screw up Sun and the Java community with their Android Java.

I still see it as a passive aggressive move for Google to get back at Oracle. They can't back away from Java API completely but they can hurt Oracle by discrediting Java language.

Re: Zig self hosted compiler is now capable of building itself

#140
post #131

Earlier quoted context omitted.

The point of C and Zig is that you can solve any kind of problems with them. In particular there is much more to memory reclamation than garbage collectors or Rust's borrow checker. Some of the reclamation schemes offer wait-freedom, or efficiently support linearizable operations.

Any kind of problem? So how do you solve SIMD with C, without language extensions? C is not a special snowflake.

Are there languages that "solve" SIMD?
Post reply on HN