r/computerscience • • Mar 12 '24

Standard classifications for low level languages needed so we stop comparing their performance

I do not understand the performance comparisons people make when comparing languages like rust and c. It is all too common and it frankly doesn't make any sense. These languages truly do not inherently have any significant performance barriers. Can there be a simple classification we can give such languages so people can stop comparing their "performance"... It should convey that in this language, code written controls essentially every aspect of performance.

I consider compiler back-ends, optimizations as well as lang paradigms insignificant to the "performance" question.

4 Upvotes

39 comments sorted by

44

u/dontyougetsoupedyet Mar 12 '24

These languages truly do not inherently have any significant performance barriers.

I mean, sure they do. C has limitations on the optimizations that can be performed due to the nature of reference aliasing, Rust moves objects during initialization, so on and so forth. Almost every programming language is doing something silly in some corner case or another.

9

u/[deleted] Mar 12 '24

There will never be a way to effectively solve all corner cases. Often we just reduce the likelihood of their occurrence. My senior had to do this recently and me as well. Sometimes it just wont work out perfect. Tis the nature of running software.

8

u/alnyland Mar 12 '24

Haven’t you heard yet from OP? You have no idea what you’re talking about and are wrong, and using big words doesn’t make you right.

What a waste of a conversation this has been - I’d love for a sensible conversation in this topic to one day materialize here tbh.

-2

u/[deleted] Mar 12 '24

[removed] — view removed comment

6

u/nuclear_splines PhD, Data Science Mar 12 '24

Keep the conversation to computer science, and not personal attacks, or you'll be suspended from the subreddit. That goes for everyone in this conversation, but your comment is both most recent and most inappropriate.

-12

u/vEncrypted Mar 12 '24

Keyword significant. But I will add two things.

What are these limitations due to the nature of reference aliasing? Doesn’t the restrict keyword exist for this exact reason.

I will again say. I do not consider compiler optimizations in langs like rust and c significant enough of a difference to class one over the other in terms of control over performance. I say this as someone who prefers c by miles. Rust’s entire paradigm endorses patterns that may affect performance, but the language itself is not inherently limited by it.

How does rust move objects during initialization? I don’t doubt it, this is a genuine question.

25

u/alnyland Mar 12 '24

Then you understand and consider wrong. 

Code written controls essentially every aspect of performance - except for, y’know, memory management, IO, process management, optimizations, chip branch prediction and preemptive caching, instruction querying, etc. 

And speed performance isn’t the only consideration, energy consumption, storage sizes, build and dev pipelines, etc. 

-16

u/vEncrypted Mar 12 '24

Process management? Does every program embed an os inside?

Io? Does rust have some different syscalls I am not aware of?

Mem management? I don’t even know how you came up with this.

Optimizations are insignificant to this performance question. C uses gcc and llvm(which rust uses) but we do not speak of two different performance levels when it comes to c.

I think you have a lack of understanding here.

12

u/alnyland Mar 12 '24

I’m not downvoting you, just for the record. Most languages except C based ones have wrappers on syscalls but those shouldn’t add much overhead, unless they’re security oriented. 

Memory management is a common topic - don’t worry, you’ll learn about in sophomore year of a degree. 

LLVM can compile C - have you heard of macOS or Unix? There are far more than two optimization levels, the man page for gcc clearly specifies this. 

I clearly have a lack of understanding here. 

-11

u/vEncrypted Mar 12 '24

Memory management is program specific in c and rust. You have access to all the same syscalls, and you can implement them as you please, malloc for example.

What is your llvm(clang) point? macOS? Unix? What are you saying? I haven’t spoken of optimizations levels. I have simply stated we do not speak of c(gcc) and c(llvm) when c’s performance is in question. Hence why I do not consider compiler back-ends to be pertinent in the performance conversation for certain languages.

I will say it again, you have a lack of understanding of how this works. Throwing unrelated big words around means nothing, nor does a cs degree if that is what you wish to flaunt lol.

13

u/alnyland Mar 12 '24

Malloc isn’t a syscall, it’s a library call - again, that’s clearly stated on the man page. It wraps around break, usually sbrk, which is a syscall. Like I said, access to a syscall isn’t the same as simply calling it. C and Unix were built together so they are more coupled than other languages.

I’ve used llvm on Linux, and gcc on Mac, even tho that’s not how it’s supposed to be done. You were the one who brought up optimization... The usual differences between those two compilers isn’t their performance but it can be, they have different executable sizes.

Yes, I obviously don’t understand how this works. You might want to re-read your original post if you don’t know what I’m talking about. Again, I haven’t downvoted you (take the hint).

-7

u/vEncrypted Mar 12 '24

I didn’t say it was a syscall. I say you can implement syscalls as you please, malloc for example which uses mmap.

I have reread my post. I stated optimizations as insignificant because again, we do not speak of c(gcc) and c(llvm) performance. It is all about choices made in code.

-12

u/vEncrypted Mar 12 '24

Most of what you said is plain untrue. Essentially everything you mentioned is not language specific… But please, enlighten me on how they are according to you.

14

u/alnyland Mar 12 '24

Glad to hear it. Yes, everything I said is language agnostic. Some languages, especially some you mentioned, don’t have garbage collection but still need to manage memory. 

-8

u/vEncrypted Mar 12 '24

Exactly… they do not have garbage collection. You can manage memory as you please in both languages. So where is the performance difference? Do you not understand the post?

13

u/alnyland Mar 12 '24

Rust does have memory management, whether or not it’s not runtime. It’s still work to do. This is clearly stated in any post about this topic on stackoverflow or any blog that wants clicks. 

8

u/[deleted] Mar 12 '24

What post has generated this commentary, OP? I need context. Rust devs love to poke C++ devs. Is this some targeted reply?

1

u/vEncrypted Mar 12 '24

No, it isn’t a targeted reply. I read the Lighthouse README, (lighthouse is the ethereum consensus client built in rust) and it stated:

“Built in Rust, a modern language providing unique safety guarantees and excellent performance (comparable to C++).”

It simply got me thinking about the amount of times I’ve heard or seen people compare language performance (c/cpp and rust mainly). But it makes no sense at all at that level. The performance is essentially fully dictated by the code you write in such cases.

I feel like entertaining such conversations really just hurts people’s understanding of programming languages in general I believe. There is no targeting of a community.

11

u/Blothorn Mar 12 '24

Are you taking that as “comparable to” or “compared to”? I don’t think it’s unreasonable to emphasize that Rust’s performance is in the C++ ballpark rather than the Python ballpark to someone not familiar with it.

-3

u/vEncrypted Mar 13 '24

Yes I agree. I don’t disagree with the statement they made. It is a simple way of explaining rust at the highest level to someone who might be familiar with cpp. It simply made me think of the conversations I’ve seen around language “performance” and the countless comparisons of programs being used to benchmark the languages as a whole.

-3

u/vEncrypted Mar 12 '24

I personally like c better than cpp and rust. But performance can never be my argument as to why it is better.

7

u/[deleted] Mar 12 '24

freshman?

0

u/vEncrypted Mar 12 '24

I am not in cs. I taught myself to program. I feel like I may be in the wrong subreddit lol.

14

u/Warguy387 Mar 12 '24

Yeah your responses to comments above may show that lack of knowledge, the things you dismissed as trivial definitely do affect performance

-1

u/vEncrypted Mar 13 '24

https://www.reddit.com/r/C_Programming/s/z8FD86MfND

This comment explains it very clearly.

6

u/twnbay76 Mar 13 '24

Dude... Did you ever read it?

"Fortran is often cited as being faster than C in specific usecases (i.e heavy maths)."

There are conditions that make Fortran faster than C. There are inherent conditions that make certain low level languages faster than others. There is no possibly way for you to dispute this.

If you are instead trying to argue "what's the point", then you're probably right. The performance comparison between low level languages doesn't matter for the vast majority of planet earth.

-8

u/vEncrypted Mar 13 '24

DUdE… diD YOu eVEr sEE Me meNTIOn FoRTan?

Did you really just see downvotes and get excited to join the winning team as you see it? Have you read the bottom of that paragraph? It clearly states my point. All of these languages have the capability to produce what are essentially identical instructions. There aren’t hard limitations to these languages.

So many rust programs link against c libs yet these programs are used to benchmark the language as a whole against c... Does this make any sense to you? This is only part of the point. The bigger picture is, people fail to understand the final product of code is grouped instructions and we are doing nothing but interfacing with compilers that mostly all do the same thing in a different manor.

But it all doesn’t matter in the end because I am obviously very wrong because of these downvotes everywhere.

This will be my last reply, any further and I will likely get banned lol.

-2

u/vEncrypted Mar 13 '24

I have not said they do not affect performance. I have simply stated I don’t see them as significant to measuring languages like rust and c.

I am genuinely asking this. Can you explain what I said that is wrong and demonstrates a lack of knowledge. I am not the most well versed in reference aliasing. But what have I indicated that was false?

I have just happened to stumble upon a conversation in c_programming that speaks of nearly the same thing. Will link shortly.

1

u/PurifyingProteins Mar 13 '24

Upvote for self awareness but feel free to post in whatever sub you want, just be ready to accept being wrong (not saying you are or aren’t) and bandwagon downvoted for being confrontational.

9

u/Seismicsentinel Mar 13 '24

You've been given plenty of examples in this thread of performance differences. You either attempt to refute other commenters' examples as incorrect or insignificant, which is fair enough... but then you belittle them over it, which is super out of pocket. You should come up with these classifications yourself since you know so much about all of this, and since everyone else is wrong. And then, you should shove those classifications up your ass - because clearly folks will not care or agree with you, when you tell them about your programming language classifications. Or maybe you can find another forum, with users who have all achieved enlightenment, and everyone will agree with you over there. You're pretty smart, I'm sure you can pull it off.

-1

u/[deleted] Mar 13 '24

[removed] — view removed comment

1

u/SexyMuon Mar 13 '24

Unfortunately, your post has been removed for violation of Rule 2: "Be civil".

If you believe this to be an error, please contact the moderators.

1

u/ABN_ALSRAG May 21 '24

You have a good point there but you seem to lack a lot of knowledge or you are very bad at communicating with other human beings the point is performance is implementation specific not language specific c is not inherently faster than js but when you compare c with gcc and js with node and conclude that c is faster you are wrong c isn't faster but gcc is faster than node languages are a specification for plain text and plain text have no performance but the implementation that converts it to executable could be faster or slower c with tinyc maybe slower than c with clang because the speed isn't derived from c but the implementation

1

u/vEncrypted May 21 '24

Not a good communicator I’ll second that.

I don’t understand what you are saying at all. Comparing a compiler(gcc) and a runtime(node)? Interpreted languages don’t fit in the argument I was making.

1

u/ABN_ALSRAG May 21 '24

I am comparing implementations. You could write an interpreter for c it would be slower than gcc you could write a compiler for js it could be faster than gcc my point is that there is no performance difference between languages

1

u/vEncrypted May 21 '24

You are describing “anything is possible”. A scratch compiler can somehow be made that allows for unbound performance… sure.

I still dont get what you are trying to say. Faster than gcc? In terms of compilation speeds? With c you can generate any machine code, performance is essentially without limit. Hence my whole argument. It isn’t about x is faster than y at a certain level, it can all compile to the same machine code.

2

u/iEliteTester Mar 13 '24

We call them low level languages, but until someone actually makes benchmarks to prove they have similar performance to other low level languages, we can't assume they are performant. It's especially important for languages that don't quite fit the "low level" language criteria like go.

1

u/_ohmu_ Mar 13 '24

I think this really depends what area you are working in. I work with web development, and for most things any of the popular languages will do (performance-wise), and it's mostly about what frameworks and libraries you need etc. but I can see the difference in performance really matter to someone working with embedded systems or with limited or very specialized hardware. Context is important.

1

u/[deleted] Mar 23 '24

Because it’s important to know how fast and optimal your language is when picking one for your project. C++ is wayyyy faster than python. But if I were building an AI I would use python bc of it’s libraries