4 ms·
I don't know... To me, zig does not look like C at all. IMO, go and zig are as similar to each other as they are dissimilar to C.
by agapon 7y ago
I don't know... To me, zig does not look like C at all. IMO, go and zig are as similar to each other as they are dissimilar to C.
- agapon 7y agoI mean, is this C-like? fn add(a: i32, b: i32) i32 { return a + b; }
- AndyKelley 7y agoYes: https://godbolt.org/z/72Dvpe https://godbolt.org/z/72Dvpe
- iruoy 7y agoSimple stuff like this looks very similar to Rust: https://godbolt.org/z/spkKai https://godbolt.org/z/spkKai Rust quickly becomes harder though, while Zig is much easier to grasp.
- tsimionescu 7y agoThe fact that they compile to the same assembly instruction does not make them similar source code.
- tzjmetron 7y agoSemantics vs syntax.
- abainbridge 7y agoThe languages are similar enough that the Zig tool-chain can translate C source into Zig source. There's mostly a one-to-one correspondence.
- tzjmetron 7y agoTo be fair, that's not really a very strong point, is it? Any language can be translated into C via an appropriate transpiler.
- deleted 7y ago[deleted]
- balfirevic 7y agoIt could hardly be more C-like. Are you getting distracted by the syntax?
- kelnos 7y agoWhen we talk about something being "C-like", the syntax is what we're talking about. Being "distracted by the syntax" doesn't make sense when the syntax is the entire point of the statement being made.
- balfirevic 7y agoWhen "we" talk? I suggest that in the future if you mean syntactically similar you say syntactically similar. But then, of course, it wouldn't have much to do with Zig's "appeal as better C than C", which prompted this whole discussion.
- dnautics 7y agoAdmittedly it's been decades since I've done any C (literally since 1999, except for an LD_PRELOAD shim I wrote about 5 years ago) but being someone who prefers C and other ALGOL-syntax derivates I find the syntax to be relatively easy to grok. One advantage over C is that the confusing pointer/array/function pointer thing has a well-defined order in Zig, there's no "spiral order" nonsense going on.
- naniwaduni 7y agoThere is no spiral. C's pointer declaration syntax is arguably backwards ("declaration follows usage") but fundamentally follows normal precedence rules. The so-called spiral is total nonsense misinformation.
- saagarjha 7y agoWhat about this do you find disagreeable? http://c-faq.com/decl/spiral.anderson.html http://c-faq.com/decl/spiral.anderson.html
- yarrel 7y agoIt's about 50% C-like. Which is giving people a That Dress experience answering yes or no to the question.
- deleted 7y ago[deleted]