News for hackers. Stuff that matters.
Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by WalterBright on Sunday October 14, 2018 @06:48PM (#18216001)
"C++, Rust, and D have a large number of features and it can be distracting from the actual meaning of the application you are working on. One finds themselves debugging their knowledge of the programming language instead of debugging the application itself."

It's an interesting point. My experience with it, though, is that if the language is too simple, the complexity gets pushed off into the application. The result is "boilerplate", a lot of code that gets routinely cut&pasted into applications.

The thing about complexity in the language, on the other hand, is once you do learn the language, that skill follows you with every app you work with. With complexity pushed to the app, you have to re-learn it with every app.

A screwdriver can do a lot of things - chisel, hammer, scraper, prybar, punch, paint stirrer, shim, etc. But I prefer having a set of tools designed to be chisels, hammers, etc. My projects come out a lot nicer.

Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by nerdponx on Sunday October 14, 2018 @07:06PM (#18216100)
It's an interesting point. My experience with it, though, is that if the language is too simple, the complexity gets pushed off into the application. The result is "boilerplate", a lot of code that gets routinely cut&pasted into applications.

This is a frequent complaint I hear about Go: they made the language too simple in certain places. People also tend to cite Rich Hickey's distinction between "simple" and "easy".

So the question about Zig becomes one of what exactly was kept simple, and what was allowed to become complex?

I think the world would benefit from a Hyperpolyglot-style comparison here. Rosetta Code is too much of a mess; ideally, I want to see a thoughtful side by side comparison of the same program written in several languages, with commentary.

Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by int_19h on Sunday October 14, 2018 @07:32PM (#18216237)
Zig might get away with it by restricting itself to a narrow niche where this kind of simplicity is advantageous. Go tries to eat a much larger piece of the pie, and the deficiency is felt more as a result.
Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by veebat on Sunday October 14, 2018 @10:59PM (#18217119)
There's a profound wisdom to knowing the niche you're in, and Zig does seem to have that. The applications part of the stack is saturated with options, all trying to encroach on each other, but when it comes to the genuinely low-level, unsexy stuff...the viable options are all pretty old languages, and languages that patch over those old languages.

And with respect to discussion of boilerplate, you can, of course, always have a "Zig++" language that patches over Zig. By cutting out its own metaprogramming functionality, it's much more straightforward to generate useful Zig source. There are a lot of advantages to restraint in the design, and Go does share that, too.

Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by weberc2 on Sunday October 14, 2018 @07:28PM (#18216213)
I think many Go developers would consider this a feature (I do, anyway). A little boilerplate is better than a complex language. I say this with a background in C++, Java, and Python. I’m a fair bit more productive in Go and my code tends to be of higher quality (less headspace devoted to language complexity and more room for application complexity).
Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by bachmeier on Sunday October 14, 2018 @09:21PM (#18216740)
You're obviously familiar with D, but in response to your post defending D's complexity, let me offer a different take. You are free to ignore a lot of that complexity with D. I don't use most "features" of the language, and in a lot of cases, I don't even know how they work. My code is a lot like C code. I don't mess with attributes, templates, CTFE, etc. in most of my programs.

You can use a style in D that is even simpler than Go if you want, but it's nice to have the extra features for the times that they're handy. Just because the features are there doesn't mean it's a good idea to use them - and D allows you to program that way.

Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by ludston on Sunday October 14, 2018 @09:47PM (#18216850)
This attitude is fine for personal projects, but it does not scale when working with other people.

Even in a two person project, one person using a language feature will inadvertently force the other person to learn how that feature works. And they will not even know if the feature was appropriate to use until they have learned it.

With this small amount of reasoning we are back to the tired old argument of "Which is better? Ease of expression or ease or learning?"

Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by bachmeier on Sunday October 14, 2018 @10:09PM (#18216938)
> This attitude is fine for personal projects, but it does not scale when working with other people.

Even if true, so what? "Personal projects" don't count?

But honestly, this is one of the worst programming language arguments there is. Any feature can be misused. There has to be discipline - full stop. Restricting the language is not the answer because that just leads to worse code, not better. Decades of C code demonstrates that lack of features does not translate into good programming practice.

Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by dgellow on Monday October 15, 2018 @01:48AM (#18217667)
C has clearly other issues than just a lack of features.
Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by btschaegg on Monday October 15, 2018 @08:13AM (#18219049)
You could very well argue, however, that many of the issues with C are symptoms of a lack of some specific features. To work around that, you need just as much discipline (to avoid, for example, buffer overflows) as you would need not to misuse the features that aren't there.

That's more or less the reason I too don't find "multiple people projects may have problems with discipline" to be a good argument for anything. That's a culture issue and pretty much orthogonal to any technical factor of your environment, including the choice of programming language.

Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by piano on Friday October 19, 2018 @07:16AM (#18255820)
> This attitude is fine for personal projects, but it does not scale when working with other people.

True, but the same is true of Go, which may be surprising to people. Despite its claims, Go didn't solve this problem.

One reason is that larger projects typically start to invent their own abstractions on top of the base language and Go is no exception here, in fact, what with its lack of some common abstractions, built-in support for code generation, frequent use of external add-ons (like go vet etc.), Go very much encourages this. And so you're going to have to learn specifics of larger projects just like with "complex" languages. The solution to this problem is meticulous and somewhat restricted code style standard, but that's a solution that works with "complex" languages just as well, in fact, I'd argue that even better.

The other reason is that the Go language is not just the Go language. That is, what with the lack of abstractions for error handling, code re-use, etc., people end up following a bunch of conventions, styles, patterns and using external tools (like the already mentioned go vet). And so in effect the language becomes "the base" + "lore". This is of course true of any language. With Go and early Java, for example, this becomes more pronounced, since the base part is very small, larger parts need to be taken care of by the "lore". This is why Design Patterns become so popular in the Java world. And this why it's not good to have the base part too small, which is the problem of Go. Of course, the other extreme is equally bad - that is, when the base part is too large, which is the problem of C++, where now "lore" has to take care of deprecating/removing language features.

I feel like the authors of Go decided to do the opposite of what C++ does and thought that since C++ is horrendous, doing the opposite would yield a great result. But unfortunatelly that's not the way things work. You can't just negate someone's bad approach and expect great results.

Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by Volt on Monday October 15, 2018 @01:18AM (#18217525)
Are you not doing code reviews in your organisation?
Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by BurningFrog on Sunday October 14, 2018 @11:23PM (#18217193)
You're assuming the multi person project has no coding standards.

Then again, you are perhaps making a decent argument for using simple languages in multi person projects!

Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by yellowapple on Monday October 15, 2018 @01:28PM (#18221696)
Perl is another language with a lot of features. I tend to appreciate those features, since once you know how to use them they're a huge timesaver and productivity boost. However, the more obscure/clever the feature (or application thereof), the less likely another programmer (your future self included) is going to understand it. And if you're tasked with maintaining old code written by someone (your past self included) who knew/used a different subset of the language's features than what you currently use, you're suddenly going to need to learn that subset.

So yeah. I love feature-rich languages, but caution is prudent, and I can understand why Perl or D or what have you might be too feature-rich.

Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by bachmeier on Tuesday October 16, 2018 @04:36PM (#18233016)
This is actually exactly what I'm arguing. If you have a language with lots of features, you don't write clever or obscure code. The stuff people do with Perl is because the language allows it, but doesn't include features to do it for you. That's a sign that something is missing from the language.

Consider the Go vs D comparison. D has good support for templates. Occasionally, templates are a big help, so every once in a while you should use them. In those cases, if you're writing D, you add a templated function and everything is concise and readable. In Go, you do one of several things, none of which is concise and readable. Future you will thank you for using D and taking advantage of it's features.

Features support the writing of disciplined code. Lack of features forces hacks, duplication, and crazy workarounds. The latter is what you're seeing when you look at ugly Perl code.

Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by sedatk on Sunday October 14, 2018 @09:18PM (#18216727)
Not only learning the language but also learning any language can equip you with necessary tools as many of the paradigms are interchangeable between different programming languages. That’s why people complain so much about the lack of generics in Go because we are already accustomed with it from other programming languages. Depriving the programmer from “basic luxuries” doesn’t make much sense.
Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by DubiousPusher on Sunday October 14, 2018 @07:14PM (#18216136)
Case in point, any interface heavy C codebase. Function after function of laying out function pointer vtables.
Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by the_clarence on Sunday October 14, 2018 @07:35PM (#18216262)
Or not having a good std crypto library: a million of shitty libraries
Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by simias on Monday October 15, 2018 @04:12AM (#18218174)
I don't think that's a very good example, there aren't that many "production grade" crypto libraries out there. I think the root of the problem is that C simply lacks the features necessary to write safe code, it sometimes feel like the language is actively trying to trip you up instead of having your back (implicit casts, weird aliasing rules, lack of generics and in particular "safe" containers like C++'s std::vector, completely implicit ownership semantics etc...). This makes is very difficult to interface crypto code nicely and safely using a pure C API.

That's not to say that C crypto libraries don't suck for other reasons (I've used OpenSSL, I can't really defend that) but the language itself limits what you can do, in the standard library or otherwise. I mean, look at the many flawed or error-prone interfaces in the C standard library itself, I don't think stdcrypto.h would be the panacea.

Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by jstimpfle on Sunday October 14, 2018 @10:21PM (#18216988)
Out of curiosity, what would be an example programming domain with a lot of interfaces?
Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by xfer on Sunday October 14, 2018 @10:56PM (#18217108)
gobject library? Gtk uses this, which tries to emulate OOP.
Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by DubiousPusher on Monday October 15, 2018 @02:35AM (#18217825)
You mean programming domain in general or a codebase in C?

There's a ton in Java, C++ and C#. One example in C is the proton implementation of AMQP.

Re:Why Zig When There Is Already CPP, D, and Rust? (2017) by dilap on Sunday October 14, 2018 @10:26PM (#18217009)
I dunno. I find myself fiddling a lot with the language in C#, in C++, in elisp. In Go, mostly I just focus on solving my problem. It seems to have strong enough abstractions for me to express solutions succinctly, while being simple enough to not get in the way. I find it extremely pleasant. (I do admit to the less-than-extremely-pleasant chore of copy-pasting various hand-rolled specializations of functions like, e.g., filter.)