Comments by "" (@pierreollivier1) on "Developer Voices" channel.

  1.  @_Karlsson  I'm curious now, like I can understand that one might not like Zig's syntax depending on your taste and background, I come from C so for me it's very familiar, and intuitive. Now for the ceremony part I've done some Java so I'm very much aware of the "ceremony fatigue" same with C++, I hate C++ for that reason, I'm tired of spending 5 minutes writing the same thing for each class definition. But in zig I really don't have that feeling, like it's not more verbose than C, it's actually less in a lot of ways, and C is well known to be simple. The stuff that's added is usually small and readable. For example in C when you have a complex struct with lots of dynamic memory allocation for the  initialization, you have to eitheir have a :  this->field3 = (field*) malloc(1 * sizeof(field)); if (this->field3 == NULL) { ....free(this->field1) ....free(this->field2) ....free(this) } and the thing gets longer and longer. or you have to use GOTO: label. in zig just :   errdefer allocator.free(this); and this is just a silly example but point being there's actually a lot of conveniences . Zig has done a fantastic job of making correct but hard thing in C trivial in Zig but easy and error prone stuff from C harder in Zig (like type casting for example, const vs var, unused variable or wrong type, exhaustive switch etc) So I would really appreciate if you could provide any example such that I could see if there is something that I'm missing, because I'm not sure where zig is more verbose ?
    3
  2.  @Kuraitou  have they tho ? I hear this all the time that people have been trying to replace C for decades but failed like it was impossible ? All those languages who ""tried"" to replace C where failing from the start. For example Jave could never be a C replacement yet in the early days it was advertised as such, On the other hand nowadays we have in my opinion real contenders, Zig for examples actually feels like a C replacement, as a C developer, Zig makes me feel at home, it's imperative, there is no inheritance, it's lower level than C. Everything feels better in Zig than in C, the type system feels better, the std is light years more useful, the semantic feels more cohesive, the error handling is better, testing code as never been easier, building it too, allocators as first class citizen is awesome, I could go on but all those things considered makes me feel like Zig could be an actual replacement to C, same with Rust, It feels a lot like Cpp, I hate Cpp, but Rust makes it more fun, it's still way too convoluted for my taste but It's a fantastic C++ replacement. So I think the argument of many have tried and they all failed isn't relevant anymore, because now that programming as a whole as evolved people have grown tired of C, myself included, it's a great language but the developer experience is really terrible and outdated, I see that everyday around me the programmers I work with all hate C in one way or another, and none of them use C in their spare time to build toy project, they all use Rust, Zig, Odin, Nim, OCaml and whatnot. I think the question is not about whether any of these languages will replace C, it's more of a when ? because it's pretty obvious that nobody in the industry wants a decade more of C, let alone another 50 years of it.
    2
  3. 2
  4. That's a feature not a bug imo, firstly all the syntax of the language can and will probably evolve, I remember Andrew saying that once the language is "stable" they will try to improve the syntax to make it more cohesive. But second one of the reason why you have to write a bit more code in Zig is because one of their moto is "no hidden control flow", the reason for this is that it makes the code more readable but it also offers a new capability which is that even people who never programmed in Zig can fairly easily read and understand what some zig code is doing I have one example of that I was working on a linter for C to autofix my style and I had a bug in the AST and a friend of mine who never coded in Zig was able to sit down with me and help me figured where the bug came from despite never seing any Zig prior to that, I don't think I would be able to do the same in C++, Rust or Haskell for that matter. The same thing can't be said about C++ templates, or Rust Macro, yet Zig comptime just read like normal code to anybody. One good exercise that I can advice you to try for yourself to understand how the explicitness of the language makes it trivial to read it, is to go into llvm compiler c++ codebase, pick a random part and try to understand what it does, then try going into a similar part of the Zig compiler codebase and understand what it does. The difference is the answer why it's a bit more verbose and less syntactically convenient. On top of that I don't think syntax should be a primary concern, the lifetime of any code is that you spend less than 10% of your time typing code, 90% reading it. Even for projects in teams at companies, your code will maybe take a few weeks or month to be written, but it will lives for years, so in the grand scheme of things I don't think that syntax is such a big deal especially if the trade off of weird syntax, enhances readability and maintainability at scale. Also you've mentioned C++ and Rust which in my opinion have both one of the ugliest and convoluted syntax that I know, in comparison zig feels simpler, but I guess it's familiarity.
    2
  5. 1
  6. 1
  7.  @_Karlsson  I get your point, but still can't really understand it, in my experience C end up more verbose when you try to make idiomatic and correct code. Because of dynamic memory allocation failure you always need to check if the pointer is valid and if not you need to either signal an error and do some cleanup or do the cleanup directly which in both cases is quite verbose. Probably 10 % of my code is just if (this == NULL) cleanup; and the lack of optional value makes it even more cumbersome to handle error correctly because as soon as one of your function does some memory allocation, it can fail and as such you need to check that where it's called we check and include some cleanup code, which ends up polluting everything. Also the fact that you don't have generics means you either have to write custom code for each data types, or use void* which is slower and ugly, or use header and casting which is dangerous, or use macro which is cumbersome, error prone and not easy to debug. Zig is not perfect of course, there's quite a few area where it's inconsistent at best and straight up weird in the worst case. But I really don't understand the "verbosity" complaint, like if you write even a small program like idk reimplenting cat, The same code in Zig is easier to follow, and quite a lot shorter, because it's easier to handle options, and arguments, it's easier to handle errors, and memory management is pretty much automatic with defer. The same code in C is ok I'm not saying it's bad but if you look at it there's a lot of verbosity involved in checking every pointers, and cleanup code everywhere, premature returns etc.
    1
  8. 1