Welcome, Guest. Please login or register.

Author Topic: C vs C++ ... or whatever language  (Read 20941 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline psxphill

Re: C vs C++ ... or whatever language
« on: February 07, 2018, 11:25:34 AM »
Quote from: bbond007;835862
Sometimes in c you are using a bunch of functions that all operate on the same struct and in c++ you can refactor that into a single object with methods.

I think its  how you approach c++

You don't have to use all of it at once.

I have written in assembly, C & C++. I still use all 3 to varying degrees.

Converting a C function & struct to a C++ class might be how most people start with C++ but it's not the most effective way to highlight the benefits. If you have a negative view on C++ then it will just be a waste of time.

One C++ project I did just had main() but used vector<>, lambda & enum class. No classes, just a few struct. It started in C, but I took the opportunity to throw in some C++ features where it made the code simpler. Then I ended up switching wholesale.
« Last Edit: February 07, 2018, 11:27:37 AM by psxphill »
 

Offline psxphill

Re: C vs C++ ... or whatever language
« Reply #1 on: February 08, 2018, 10:03:18 AM »
Quote from: Plaz;835885
On the other hand what I still find evil is when people code their projects with no comments. C++ can be buried in layers of abstraction if the coder so chooses, Trying to unravel what they've written can be soul killing.

I always find it better to architect the structure better than spend time trying to document it. Writing the documentation and updating it when the bad code changes is soul killing as is having to map what the documentation says to the bad code.

If a developer can't choose descriptive class/variable/method names and lay the structure out in a sane way, then any documentation they write is going to be worse. If you've got good documentation, then it's likely the person isn't a developer at all and you might as well throw the code away.

The only time documentation is useful is for libraries, where you don't necessarily have the source to hand or an example of how you're supposed to call it.
« Last Edit: February 08, 2018, 10:06:47 AM by psxphill »
 

Offline psxphill

Re: C vs C++ ... or whatever language
« Reply #2 on: February 09, 2018, 06:55:58 PM »
Quote from: Thomas Richter;835912
Well, I wouldn't be that critical. Good documentation is great. Code that requires good documentation is bad.

Back in the old days when manuals were printed and cost money then there was some good documentation.

You can't learn language features without documentation, but for everything else if you have the source code then you don't need documentation and shouldn't trust any that you find.

Quote from: asrael22;835919
And the views of this guy on C language, interesting:
https://www.youtube.com/watch?v=443UNeGrFoM

There are pros and cons to C, I watched some of the video and he doesn't seem to be objective enough. To me he sounds like he is in denial.

There was a C project I worked on for many years and it was stuck because it needed to be built for some 8 bit platforms too and we only had a C compiler for those. By the time those disappeared there was no justifiable reason to convert it to C++, but looking back I wish I'd done it. There were some places that would have benefited from C++, but due to my own denial it never got done.
« Last Edit: February 09, 2018, 07:03:24 PM by psxphill »
 

Offline psxphill

Re: C vs C++ ... or whatever language
« Reply #3 on: February 16, 2018, 12:21:34 PM »
Quote from: SamuraiCrow;836178
Arguably, C++ is not for beginners either.


It depends on how long you want to stay a beginner. If you're after instant gratification then c++ is not ideal.

There is no reason a beginner couldn't go straight for assembly language.
 

Offline psxphill

Re: C vs C++ ... or whatever language
« Reply #4 on: February 16, 2018, 10:04:10 PM »
Quote from: Thomas Richter;836183
C++ does not force you into a particular programming style. While this property of the language is certainly helpful for advanced programmers, it makes it unecessary hard for beginners to develop a good style.

But taking a detour via another language isn't going to develop a good style either.

Your argument is like saying: Chinese is hard to learn, so instead of learning it when you are a child you should learn another language first and speak that for a while and then learn chinese when you're in your 30's.

Developing a good style is an innate skill. If you struggle then you're probably not cut out for development.
« Last Edit: February 16, 2018, 10:06:31 PM by psxphill »