3 ms·
Is syntactical similarity or even compatibility to C a positive thing? Not taking away anything, D is a really cool language that definitely doesn’t get the fam
by kaba0 5y ago
Is syntactical similarity or even compatibility to C a positive thing? Not taking away anything, D is a really cool language that definitely doesn’t get the fame it would rightfully deserve, I just think that breaking with some old habits (eg. postfix types with : are simply superior from a parsing perspective, and the pointer magic of C is just as terrible and the change in Zig is very welcome) when they are superseded is a good thing.
- gavinray 5y agoI do actually prefer postfix types, so I'm not against you there. The bit about D is that while you CAN write it to look like C, (or even directly embed ASM blocks in it), it's usually written in a higher-level form without pointers that looks more like JavaScript: // Count line length of stdin void main() { import std.range, std.stdio; auto sum = 0.0; auto count = stdin.byLine.tee!(l => sum += l.length).walkLength; writeln("Average line length: ", count ? sum / count : 0); } ---- import std.algorithm, std.conv, std.functional, std.math, std.regex, std.stdio; alias round = pipe!(to!(real), std.math.round, to!(string)); static reFloatingPoint = ctRegex!(`[0-9]+\.[0-9]+`); // Replace anything that looks like a real number with the rounded equivalent. void main(){ stdin .byLine .map!(l => l.replaceAll!(c => c.hit.round) (reFloatingPoint)) .each!(it => writeln(it)); }