News for hackers. Stuff that matters.
Re:Zig's New Relationship with LLVM by kristoff_it on Monday September 28, 2020 @08:51AM (#24616069)
I think Zig will reserve a few interesting surprises also in the webdev world, it just needs a bit more time to get there.
Re:Zig's New Relationship with LLVM by sam0x17 on Monday September 28, 2020 @09:12AM (#24616254)
If anything, Zig will have much fewer restrictions (no borrow checker) than Rust when it comes to web dev, once Zig matures to the point where there is a good standard HTTP client and server implementation and a package manager.

I'm a fan of Rust for things like a missile control system or a stock exchange, but not, say, writing a CRM. I'd gladly write a CRM in Zig however, given the proper library support and tooling. Why? productivity. In my experience it just takes 2-3x longer to get the same thing done in Rust vs. something like Zig/Crystal/Go and certainly vs. Ruby/Python/etc. For extremely mission critical code, this is fine, but for most startups I would argue it probably isn't appropriate.

Definitely staying tuned as Zig develops.

Re:Zig's New Relationship with LLVM by ikskuh on Monday September 28, 2020 @09:16AM (#24616285)
One experience i can share with Zig and webdev is this:

I was writing a emulator (and later: a compiler) in Zig which was originally written for PC. But i got the idea that hosting this stuff on the web page would be cool, so i learned how to do Wasm. The result was for both project a glue file with ~150 LOC Zig and ~150 JS and both compiler and emulator ran in the browser, and porting both projects took less than an afternoon of time.

Re:Zig's New Relationship with LLVM by sam0x17 on Monday September 28, 2020 @09:22AM (#24616337)
Very cool. In my case, I have my eye on Zig as the target language for some web framework ideas I've had for a while, and I'm just waiting for some library maturity at this point before I get started.
Re:Zig's New Relationship with LLVM by johnnycerberus on Monday September 28, 2020 @09:21AM (#24616325)
While I like what Rust is trying to achieve, I would never use something that is not formally proven. There are many, many other static analysis tools in the C and Ada world that can achieve exactly the same thing. They imply less risk, they are way more mature (~40 yo) and have bigger communities around them.

Zig is a better C and C++. It should be used accordingly. It will do well in game servers, simulation servers and real-time systems that don't require hard safety constraints. Bonus points for Zig, it is a simple language and because of its nature it will be easy to build tooling around it to prove properties.

Re:Zig's New Relationship with LLVM by smaddox on Monday September 28, 2020 @09:47AM (#24616542)
Rust's borrow checking algorithm has been formally proven for a subset of the full language. Although this is one of those places where intuition is adequate to show the value, i.e. of enforcing exclusive mutability. After all, the intuition and implementation came before the proof (as is often the case).
Re:Zig's New Relationship with LLVM by viraptor on Monday September 28, 2020 @09:29AM (#24616404)
> that can achieve exactly the same thing

That's a bold claim. What's the C formal validator which automatically handles both memory management and concurrency in source of any size within seconds/minutes? (Without making the source its own dialect rather than C)

Re:Zig's New Relationship with LLVM by johnnycerberus on Monday September 28, 2020 @10:23AM (#24616881)
I don't think we can call it "automatic handling", you just play by the borrow checker's rules. Automatic are the garbage collectors but not Rust's model.

Anyway, you can verify the critical part of your C/Ada program by using: Why3 http://why3.lri.fr/ Frama-C http://frama-c.com/ (which is also extensible) SPARK https://www.adacore.com/about-spark

One company that I've worked for used generators, they were specifying the model with a DSL and they generated the code based on that. Can't give more information about that but there are others doing the same (SpaceX and NASA). Rust is very good for people that don't have the resources and money to throw at or are working in an industry where they don't need a certification, for example I have friends at Amazon in Romania that build Firecracker, a virtual machine that is supposed to improve the safety story on AWS Lambda.

And as an answer for your second question, at what cost? Also we don't know if Rust gets the scaling right. The compiler is already slow for the size of projects we already have.

Re:Zig's New Relationship with LLVM by viraptor on Tuesday September 29, 2020 @01:49AM (#24624503)
There's a bit of disjoint between what those tools do and they what Rust does. Rust provides something different - you write the source in standard code and get a sound app. Verifiers can't do that with C. You essentially either write a parallel list of annotations or generate the app from another language. It's a valid approach, but that's why I objected to "exactly the same thing".
Re:Zig's New Relationship with LLVM by sam0x17 on Monday September 28, 2020 @09:45AM (#24616524)
True, I'm familiar with ones in Java but not in C/C++. Having written a leak / double free detector for C, I have to say, you can only do so much statically and that wouldn't give me peace of mind exactly.
Re:Zig's New Relationship with LLVM by pjmlp on Monday September 28, 2020 @10:47AM (#24617186)
Frama-C and Microsoft's Security Description Language.
Re:Zig's New Relationship with LLVM by sam_bristow on Monday September 28, 2020 @07:29PM (#24622400)
There is work to get Rust qualified for safety critical domains [1]. Someone else pointed out that parts of the borrow checker have been formally proven already. Still a long road ahead, but I'm glad people are looking at it.

https://ferrous-systems.com/blog/sealed-rust-the-pitch/

Re:Zig's New Relationship with LLVM by sam0x17 on Monday September 28, 2020 @09:25AM (#24616366)
Agreed that Rust has a bit of an odd fit -- it is in many ways a bit too onerous for day-to-day things like CRMs and web dev, but for the real scenarios where you want formal verification, you can of course also use actual formal methods and get a much higher degree of certainty perhaps. It is well suited for OS and driver dev though, which is arguably the target use case.
Re:Zig's New Relationship with LLVM by jorangreef on Monday September 28, 2020 @11:12AM (#24617487)
"It is well suited for OS and driver dev though"

Rust is brilliant, but for drivers, I would go for a language with OOM safety and strict static allocation, especially for embedded environments.

Re:Zig's New Relationship with LLVM by skohan on Monday September 28, 2020 @10:26AM (#24616920)
Where does the extra productivity in Zig come from in your experience? I haven't worked with it, but my understanding is that memory management is manual and explicit, which tends to come with some cognitive overhead. If Zig has a good solution for this I would be curious how it achieves it.
Re:Zig's New Relationship with LLVM by dnautics on Monday September 28, 2020 @11:02AM (#24617359)
Defer and errdefer help make the memory handling dead easy.
Re:Zig's New Relationship with LLVM by higerordermap on Monday September 28, 2020 @10:07AM (#24616725)
I don't think zig is very well suited for / should target web dev.

There a GC'd language with modern features should do best. Imagine OCaml but modern and great tooling. That would be easy for developers, more productive to write, less type errors, also more productive because of IDE support, and much faster than current crop of scripting languages.

Sadly, there is a vacuum for such a language. Go is too gruntwork and minor details, Rust is designed for high reliability system programming, Zig is designed as sytem language in spirit of C, OCaml is archaic and does not seem to improve by much.

The hopes in this area are

Nim - Nice python-like syntax, but feels a little unpolished, metaprogramming may be hindrance to IDE tooling and code readability on large codebases.

Crystal - Ruby like syntax and stdlib. LLVM compilation, very young language, no windows support, and (personal opinion) I think some work can be done on performance of idiomatic code.

OCaml - there is not much manpower behind it. All those Reason XYZ attempts to provide javascript syntax over it don't seem to have gotten traction. Tooling is pretty good considering how obscure language is. They might need a modern interface to toolchain, and an optimizing compiler seems to be being worked on. La k of multicore is often cited as a drawback but it is being worked on, and Python doesn't do multicore either, I don't think multicore matters to 90% of people doing webdev.

F# - Would be nice if it was not confined to .NET ecosystem and had good native compilation story.

Re:Zig's New Relationship with LLVM by skohan on Monday September 28, 2020 @10:24AM (#24616897)
> There a GC'd language with modern features should do best.

I predict that there will be a paradigm shift away from GC in the next round of languages. I suspect what will win for something like web-dev will be a language with static memory management like Rust, but at a higher level, with slightly more tolerance for abstractions of non-zero cost.

Re:Zig's New Relationship with LLVM by pjmlp on Monday September 28, 2020 @10:49AM (#24617209)
I predict that GC languages will prevail and adopt affine types for advanced users to code application hot paths, like D, Swift, Chapel among others are pursuing.
Re:Zig's New Relationship with LLVM by throwaway17_17 on Monday September 28, 2020 @11:41AM (#24617821)
I think this is in general the right call, but I would prefer seeing the adoption of a more general substructural type system implementation and the inclusion of uniqueness types. It would not add that much complexity when the use case is specifically limited to advanced users and the obvious trade offs in syntax increase and annotations are limited to those that want/need it.
Re:Zig's New Relationship with LLVM by nyanpasu64 on Monday September 28, 2020 @10:44AM (#24617145)
https://boats.gitlab.io/blog/post/notes-on-a-smaller-rust/ might be inspiration for such a language.
Re:Zig's New Relationship with LLVM by skohan on Monday September 28, 2020 @10:48AM (#24617197)
Aside from the notes on concurrency in this article, the author could easily be describing Swift
Re:Zig's New Relationship with LLVM by pkphilip on Monday September 28, 2020 @11:09AM (#24617461)
Julia is a good language - has excellent performance and it has a pretty decent web development framework as well.

https://genieframework.com/

Re:Zig's New Relationship with LLVM by tikej on Monday September 28, 2020 @04:17PM (#24620807)
Re:Zig's New Relationship with LLVM by kristoff_it on Monday September 28, 2020 @10:17AM (#24616823)
>There a GC'd language with modern features should do best.

There's still a market for more performant and predictable networked services. It's a bit too early for a full-fledged post explaining the feature in detail, but as far as I know Zig is the only language that can do async/await and at the same time ensure that when memory limits are reached, the system still behaves correctly (i.e. you can preallocate upfront the memory you need to instantiate a coroutine and, if that fails, you can gracefully return a 500 http error code).

Serious webdev is out there, and when SREs talk about the importance of predictability and low-variance in metrics, they aren't (just) writing content for marketing purposes.

Re:Zig's New Relationship with LLVM by higerordermap on Monday September 28, 2020 @10:31AM (#24616975)
Yeah but majority of webdev is not that, right?
Re:Zig's New Relationship with LLVM by cgh on Monday September 28, 2020 @12:39PM (#24618506)
Kotlin seems to fit what you're asking for? And so does modern Java, to be honest.