Hacker News new | ask | show | jobs
by v8dev123 1868 days ago
What's with the people who still use the term C/C++?

C++ and C are separate languages. I'd be grateful for the author to reflect it in the Readme.

Further, Bragging about LoC is bad. LoC is a poor measure of both quality and functionality.

"C/C++ - a mythical language referred to by people who cannot or do not want to recognize the magnitude of differences between the facilities offered by C and C++" -- Stroustrup

4 comments

Concretely, rr uses both C and C++, so the term is perfectly valid, given that the two languages interoperate just fine.
> Further, Bragging about LoC is bad. LoC is a poor measure of both quality and functionality.

It is not a measure of quality but rather size of the project.

Was he bragging about it? I think it was more about the amount of work accomplished. It’s not a 1k LOC project.
It's not the size of the project, it's how you use it.
There aren't many pairs of mainstream languages that really interoperate well together. C and C++ do, which can blur the lines a bit. Not sure if this is what the author meant.

With rust growing in popularity and good interoperability, I suspect we'll see the rise of projects written in C/Rust and C++/Rust, and maybe even C/C++/Rust. The line will obviously be more clear because of dramatically different syntax, packaging, build system, etc.

My issue was "/" and I'd be fine if he had used "C, C++" or "C & C++"
Does "/" have a concrete meaning? I vaguely think it means "with" or "and" or "or", but it seems more ambiguous.
It's ambiguous and not clear to reader!
> C++ and C are separate languages. I'd be grateful for the author to reflect it in the Readme.

I agree, but we could honestly be as granular as we want here. We could ask the author to delineate between C99 and C11, but it ultimately doesn't really matter. The point of referring to "C/C++" is to cast a blanket statement over the traditional compiled mainstays and use them as a point of reference. While they are indeed different, they're more alike then they are dissimilar. I think the author is perfectly justified here.

> Further, Bragging about LoC is bad. LoC is a poor measure of both quality and functionality.

Rust is a language that is extremely verbose, and properly formatted Rust code often uses more lines than necessary to improve readability (expanding match arms, removing inlined if-statements, etc.). Hell, if you look at the repo, it looks almost identical to a default Rust project: src is clearly exposed at the root, and everything else is pretty well organized into distinct folders. I disagree with the first part of your statement ("Bragging about LoC is bad") but agree with the second part ("LoC is a poor measure of both quality and functionality.")

Honestly, I think LoC-shaming originated in languages like Java and Python, where more lines of code almost guaranteed more complexity. Rust's focus on zero cost abstraction ultimately means that even massive programs can run with minimal overhead. I'm not here to parade Rust's achievements in front of you, but I figured it was worth pointing out at least here.

> Honestly, I think LoC-shaming originated in languages like Java and Python, where more lines of code almost guaranteed more complexity. Rust's focus on zero cost abstraction ultimately means that even massive programs can run with minimal overhead.

Zero-cost abstractions are meant to be zero physical cost, not zero mental cost. LoC still translate to mental overhead and "LoC shaming" is appropriate for any language, not just verbose like Java or Python.

C++ also happen to use the term zero-cost abstractions along with RAII since 2011 but

Chandler Carruth “There Are No Zero-cost Abstractions”

You can watch and see what they really are. I bet this is true for Rust as-well.

Well... the only language with true zero-cost abstractions is Lisp (assuming you call it a language, which it strictly isn't, but let's not go there right now).

The reason Lisp is zero cost is because what you write as data structure (the program IS a data structure) can be interpreted however you decide it to be interpreted. You can design any kind of abstraction you like and then separately completely control how that code is translated to binary.

For example, when you write a function call like printf("%d", 7) in C (forgetting built in optimization for printf...), the resulting binary has no other choice than to call printf function, parse "%d" and then conditionally read in argument and create a string.

On the other hand if C was Lisp it could, at the time of compilation, translate this code to invocation of putc('7') so that during normal execution the parsing of "%d" would never happen.

In C this requires compiler support. In Lisp you are compiler -- you decide what code is going to be generated.

"Zero cost abstraction, for some definition of cost" :-)
Well, yes. In that case every abstraction costs because at the very least you need to develop it and it costs.

I think there are two major contributors to cost of abstraction.

#1 is performance. Does it add stuff that is not strictly necessary but is just side effect of abstraction mechanism? Does it affect memory layout to be less than ideal? Does it prevent generated code to be ideal?

#2 is leaks. Leaks are cost. Leak is when the user of abstraction needs to be aware of more details than just the official abstraction. For example, regular expression is a leaky abstraction because, except for simple regexes, you need to know a lot about actual implementation of the regex so that you understand how to write so that it does not require infinite memory and finishes before heat death of the Universe.

Traditionally, "zero-cost" refers to #1 and I think this is very useful definition.

It is difficult to impossible to prevent #2. Using #1 as definition of zero-cost describes tools with which you can use to create your solution without hampering your performance (significantly). These tools do not need to be simple or even intuitive (and Rust is neither).

Maybe I am just dumb, but was python considered verbose?