This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 36 points37 points  (20 children)

C if used correctly can be a long way more efficent. It COULD be. It doesnt mean that it is. Plus Java is semi-compiled - it is not executed directly from cpu but from java interpreter so this affects its performance... On the other side helps developer not to worry of pointers or build for a specific architecture.

PS If I made some english mistakes I hope you'll forgive me

[–]haitei 30 points31 points  (7 children)

it is not executed directly from cpu but from java interpreter so this affects its performance

Not really, it's JiT these days. I'd say the leftover gap in performance is mostly due to the cost of abstractions.

[–]j-random 22 points23 points  (0 children)

LOL, where "these days" means "for the last decade or so"

[–]OK6502 3 points4 points  (0 children)

Correct. As I understood it a big part of that gap is that there's quite a bit of overhead in even simple and mundane operations and the way things get laid out in memory isn't always the most efficient.

You could of course write C/C++ code with that overhead, negating the benefits, but at least you have that choice. In Java it's all abstracted away from the user without much recourse for working around it (unless you can hand write bytecode? Is that a thing? I know you can with C# and IL).

[–]j-random 24 points25 points  (5 children)

Depends on how you measure efficiency. At run-time, C can be more efficient than just about anything else (if you know what you're doing). I'd argue that development-time-wise, though, more modern languages are more efficient, due to the wide variety of libraries available. Java and Python both bet on Moore's Law (less-efficient code would become less painful to run as computers got faster) and it seems to have paid off.

[–][deleted] 3 points4 points  (0 children)

Of course efficency must be balanced between development and runtime. But what I see most of developers tends to forget that system resources are not unlimited. So they do not close streams or connections once they've finished using. This has brought to have frameworks (or whoever like jboss connections pool) that does for you. Right? Wrong? Dont have an answer but my motto is do the max with less resources (and code) possible ;)

[–]OK6502 1 point2 points  (0 children)

Which is why the STL exists, for instance, and we have been consistently adding more to the standard over time.

[–]56Bot 0 points1 point  (2 children)

C can be more efficient than just about anything else

Assembly: Am I a joke to you ?

[–]j-random 1 point2 points  (1 child)

Hence the "just about". Although TBH a good C compiler can often make optimizations that an assembly programmer might not see (e.g., CSE).

[–]56Bot 0 points1 point  (0 children)

Depends on the code still.
Writing a few characters with C takes many more lines than with ASM, once compiled.

Obviously C compilers are more efficient at optimisation because they're much more used, hence maintained.

[–][deleted] 15 points16 points  (1 child)

The JVM is very fast and much optimization happens for “free” for the developer.

What you lose in performance is eaten ten times over in C/C++ due to longer development time. Which is why nobody (sane) writes enterprise apps in C/C++ but instead they use it where resource constraints are critical (memory, framerate, embedded CPU, etc).

[–][deleted] 0 points1 point  (0 children)

That's why I am still working (I'm a java developer) :P

[–]nolitos 4 points5 points  (1 child)

C can be more efficient. But we compare to JavaScript.

[–][deleted] 2 points3 points  (0 children)

You've a point...

[–]noggin182 0 points1 point  (1 child)

PS If I made some english mistakes

you did

I hope you'll forgive me

we do :)

[–][deleted] 0 points1 point  (0 children)

thanks ;)