Hacker News new | past | comments | ask | show | jobs | submit login

the rust port is 16K LOCs despite the crazy C verbosity?? (I'm reffering to the github addition count)



Sounds about right. Well written C just isn't very verbose.

You can make it verbose by adding a ton of patterns that you don't need, like the gobject code in gnome. But you don't need to.


strong disagree, C is a very poor language that does not provide a proper stdlib to reuse, collections/containers/functors. No OOP means no efficient code reuse, zero syntax sugars, manual memory noise, etc etc C toy programs can be short though.


Disagree all you like. The rust port apparently didn't hear you, because the line count grew by nearly 50%, and I can post other similar comparisons with some other codebases and languages too.


I see about 1k lines of new tests, probably 500-600 lines of build system integration across various files, nearly 1k lines of cargo lock file information for dev dependencies and the Rust code appears to be more highly commented than the C code was.

Sounds to me like you already decided what your conclusion was and are just looking for data to back it up without actually analyzing it.


But this Rust port isn't idiomatic Rust, so it doesn't take much advantage of the improved idiom. Its authors call that out early.

Example: In C you're obliged to write a lot of counter loops, because the language does not have iterators, the idiomatic Rust is both smaller and easier to read because the counters weren't really for anything, they're just implementation details:

  for (k=0; k< size(geese); ++k) // We need this k counter in C to index geese

  for goose in geese // In Rust we can just have the geese themselves

 But if you do a non idiomatic port, you carry across that loop as it was written, plus you gain the extra conversion noise. So this is a much less useful metric.


That is of course true, but it's a pretty poor example since both languages need one line of code for the loop header.

The C line is more complex and less abstract, but that doesn't affect the lines-of-code metric that was being used in the discussion.


Fair, it was the first example of a verbose C idiom that came to mind, and it will spill onto multiple lines for complex cases easily (depending on your style rules) but it isn't a good example for this purpose.

I did also think about switch versus match, but in that case you're more or less obliged to do the extra lifting when translating to Rust and so I expect the breaks (which are extraneous in match) would be elided rather than translated.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: