How Languages Compare?

Started by
36 comments, last by ApochPiQ 10 years, 4 months ago

struct DeadPlayer {
Player player;
Point deathLocation;
}

Now, you write methods that take a DeadPlayer* as their first argument (and observe, you can pass DeadPlayer pointers to all methods that expect a Player).


Nice example.
Usually a fairly junior C# or Java developer will jeer at C because they don't realize or understand how this works. This is how Gtk+ (and many object-orientated C libraries) does it and demonstrates that C is pretty darn flexible.
http://tinyurl.com/shewonyay - Thanks so much for those who voted on my GF's Competition Cosplay Entry for Cosplayzine. She won! I owe you all beers :)

Mutiny - Open-source C++ Unity re-implementation.
Defile of Eden 2 - FreeBSD and OpenBSD binaries of our latest game.
Advertisement

Automatic enforcement of initialising stuff is good in C++ though (in C, you don't want to forget to call an init/deconstruct method).

But most things you can do in C++ you can do in C, although C's version of templates via macros is not good ;)

C makes you write a lot of boilerplate code and get it right which C++ shields you from.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
Almost any piece of high level C code can be improved by applying C++ techniques. References, generic algorithms, lambdas, constexpr, smart pointers, move semantics etc. are all really nice. You don't need to write object oriented code to benefit from C++.

Just the fact that C++ has a good assortment of standard containers is a huge leg up on C. If you are working in C, you'll be using containers from some 3rd party library, or have rolled your own from scratch with great time expenditure and possible quality issues, or you are effectively hamstrung by lack of appropriate tools.


Almost any piece of high level C code can be improved by applying C++ techniques. References, generic algorithms, lambdas, constexpr, smart pointers, move semantics etc. are all really nice. You don't need to write object oriented code to benefit from C++.

I hate to nit-pick (ok, I actually love to, it seems very effective in terms of learning), but isn't it a bit misleading to refer to genetic algorithms and lambdas as being C++ techniques? Correct me if I misunderstood what you were saying but the statement seems to associate those techniques with C++, while I am pretty sure the two I mentioned existed before it did. I could not say about the others, as I am less familiar with them, and I am not very familiar with those two in the first place.

Lambdas were LISP (acronym for: Lots of Irrelevant Superfluous Parentheses <- j/k) originally I think.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

A lot of you guys say that with C you can do all the stuff that you can with C++. Its true, but than you could say with assem or binary you can do the same things that you can do with C++. So how much time would it take to build something ? I think C++ saves you a lot of time.

What I am really taking out of this is that it is a "toolbox" type issue. Everything has strengths, everything has weaknesses. I certainly did not ask the question with the goal of trying to crown the king of languages. I wanted to know what are some positive points of the two, unfortunately I used some questionable wording. I have found a lot of these posts to be quite informative. I am guessing that no matter who you ask, they are always going to have a personal preference (a very strong one in some sometimes, probably), and I can see a bit more why I was warned by Winfield that such a question can incite a holy war. Thanks everyone, for maintaining civility on such a topic, since there was some pretty good information to be had.

The current view I am going to go forward with is that based on responses, and on other threads that I have read as well, my best bet is probably just choosing and sticking to a language for the time being (that one seems to have been reiterated in numerous places). Not that I was really questioning that it was the best thing to do, nor trying to get help choosing. Just wanted to try and learn a bit more about the two, and I would say that goal was achieved.

Although everything that I stated above is meant sincerely, I feel a bit too much "after-school special" seeping into it.....the cynic in me feels quite ill, but thanks for the information, again.

A lot of you guys say that with C you can do all the stuff that you can with C++. Its true, but than you could say with assem or binary you can do the same things that you can do with C++. So how much time would it take to build something ? I think C++ saves you a lot of time.

You know what? Who gives a damn about the language. A programming language doesn't automatically make a specific programmer more or less productive because he/she now has access to language feature 'X' or 'Y'. Software development is about the approach *you* take to ensuring that your code is stable, maintainable, and efficient (where necessary), and in this, fundamentally C++ doesn't save you any time over C/C#/Python/Lisp/ASM/Whatever (I say this as someone who actually uses C++ for most things, and C#/python/lua/mel script/max script for the rest).

I could write a code generator in 5000 lines of lua that spits out 5 million lines of C. That would make me significantly more productive than a programmer who spends 3 months writing 3 million lines of bug ridden C++. Programming is about the thought process you go through to solve a particular problem. A programmer who claims 'language feature X makes you more productive', is in my experience, the kind of programmer who will turn to face their goal, and then run a marathon to get there. Walking barefoot to the taxi rank round the corner, is normally a better solution than debating which pair of running shoes is faster.

Almost any piece of high level C code can be improved by applying C++ techniques. References, generic algorithms, lambdas, constexpr, smart pointers, move semantics etc. are all really nice. You don't need to write object oriented code to benefit from C++.

Complete and total bullshit. If I have a working piece of C code, it sodding works! Changing the interface (cos references, lambdas, and smart pointers, are cool lolz!), just forces you to:

Change the documentation
Modify the unit tests

Modify every place where that code is used.

Fix up any bugs which you *will* have added.

Verify that those languages features work as intended on every single target platform

It's a fool's errand. Work smarter, not harder.

Almost any piece of high level C code can be improved by applying C++ techniques. References, generic algorithms, lambdas, constexpr, smart pointers, move semantics etc. are all really nice. You don't need to write object oriented code to benefit from C++.

I hate to nit-pick (ok, I actually love to, it seems very effective in terms of learning), but isn't it a bit misleading to refer to genetic algorithms and lambdas as being C++ techniques? Correct me if I misunderstood what you were saying but the statement seems to associate those techniques with C++, while I am pretty sure the two I mentioned existed before it did. I could not say about the others, as I am less familiar with them, and I am not very familiar with those two in the first place.

They aren't C++ inventions, but I wasn't calling them as such. According to the topic of the thread, I was comparing C++ to C. C++ has language support for the things mentioned, while C does not.

Also, it's "generic algorithms", not "genetic algorithms".

A programming language doesn't automatically make a specific programmer more or less productive because he/she now has access to language feature 'X' or 'Y'. Software development is about the approach *you* take to ensuring that your code is stable, maintainable, and efficient (where necessary), and in this, fundamentally C++ doesn't save you any time over C/C#/Python/Lisp/ASM/Whatever (I say this as someone who actually uses C++ for most things, and C#/python/lua/mel script/max script for the rest).

I could write a code generator in 5000 lines of lua that spits out 5 million lines of C. That would make me significantly more productive than a programmer who spends 3 months writing 3 million lines of bug ridden C++.

This example has nothing to do with your (faulty) assertion that languages do not matter. You'd be far more productive when writing your code generator in Lua than when writing it in assembler. That's because in comparison to assembler, Lua has many more features that help you get the job done. It boggles my mind that you'd even try to claim otherwise.

Complete and total bullshit. If I have a working piece of C code, it sodding works! Changing the interface (cos references, lambdas, and smart pointers, are cool lolz!), just forces you to:

Seriously weird strawman argument. If you have 100% perfect, 100% efficient C code that never needs to be changed again, then sure, you don't want to go in and change it for any reason. But I didn't tell anyone to do that. Rather, I'm saying there are benefits from writing the code in C++ in the first place, even if the code is not object oriented, and even if it mostly looks like C.

This topic is closed to new replies.

Advertisement