Author Topic: C vs. C++  (Read 2395 times)

0 Members and 1 Guest are viewing this topic.

Offline parad0x

  • VIP
  • Royal Highness
  • *
  • Posts: 638
  • Cookies: 118
    • View Profile
C vs. C++
« on: February 04, 2013, 02:58:04 pm »
I was thinking to take some steps back and learn C/++. I am a bit confused which should I chose C or C++. I know C++ is OOP whereas C is not. I was wondering what advantages/dis-advantages an OOP language has over a non-OOP and why there are new languages which are extremely OOP like Ruby, Python, Java, etc. I would really appreciate your help.

Offline proxx

  • Avatarception
  • Global Moderator
  • Titan
  • *
  • Posts: 2803
  • Cookies: 256
  • ФФФ
    • View Profile
Re: C vs. C++
« Reply #1 on: February 04, 2013, 03:57:01 pm »
OOP has the major advantage of being able to be applied in bigger projects.
Doing this the old fashioned way is painfull.

Im sure your familiar with the black-box concept?
When for example a team of devs is working on a project they can make changes in their own part of the code and not break the rest.
DATA >> BLACKBOX >> DATA
Whatever happens inside the black box is no ones business as long as the I and the O stays the same.

One of the major reasons being ... money.
Rewriting old bugged code is expensive.

So well a purley logical point of view would be to look in the future.
Which will be OOP.

C is faster than C++ but I dont think the difference is that interesting.

However C is still the language used for drivers, embedded devices, networking etc.
Its faster, for some fucking reason one of the oldest languages still alive and kicking.


« Last Edit: February 04, 2013, 03:58:07 pm by proxx »
Wtf where you thinking with that signature? - Phage.
This was another little experiment *evillaughter - Proxx.
Evilception... - Phage

Offline rasenove

  • Baron
  • ****
  • Posts: 950
  • Cookies: 53
  • ಠ_ಠ
    • View Profile
Re: C vs. C++
« Reply #2 on: February 04, 2013, 04:38:47 pm »
It all depends on what you want to do with it. As for the rest, proxx said well enough. And this should help you learning , www.evilzone.org/found-it-on-the-webs/suggested-c-book-list/msg46119/#msg46119
My secrets have secrets...

Offline Deque

  • P.I.N.N.
  • Global Moderator
  • Overlord
  • *
  • Posts: 1203
  • Cookies: 518
  • Programmer, Malware Analyst
    • View Profile
Re: C vs. C++
« Reply #3 on: February 04, 2013, 06:24:45 pm »
I was thinking to take some steps back and learn C/++. I am a bit confused which should I chose C or C++. I know C++ is OOP whereas C is not. I was wondering what advantages/dis-advantages an OOP language has over a non-OOP and why there are new languages which are extremely OOP like Ruby, Python, Java, etc. I would really appreciate your help.

Which one to take depends what you want to program.
Games? C++
System programming (operating systems, drivers, etc)? C
Desktop applications? C++
Interpreters for other languages? C
... ?

Code: [Select]
advantages/dis-advantages an OOP language has over a non-OOP
That really depends what programming paradigm the non-OOP languages has.

C++ vs C: see answer of proxx.

OOP vs functional (i.e. Java vs Haskell):

advantages OOP (compared to functional programming):
most people find it easier to understand and easier to read as objects represent instances of the real world
more often used than functional programming

advantages functional programming (compared to OOP):
better suited for mathematical problems
no boilerplate code
very concise
usually need mathematical knowledge to understand it

OOP vs logical programming: I can't tell you as I have not enough experience with logical programming.

Quote
C is faster than C++ but I dont think the difference is that interesting.

I find that hard to believe as most C programs run as well as C++ program. Maybe it is more the features that you use than the language itself.

Quote
So well a purley logical point of view would be to look in the future.
Which will be OOP.

I disagree. OOP is the present. The future needs concepts that are better suited for parallel programming tasks. The hardware is already set for this, but most languages are not really good to use for parallel programming which is why most programs are still serial.
The future will either be functional programming or more likely something completely different (a not yet discovered concept) that works well for these tasks.

Offline proxx

  • Avatarception
  • Global Moderator
  • Titan
  • *
  • Posts: 2803
  • Cookies: 256
  • ФФФ
    • View Profile
Re: C vs. C++
« Reply #4 on: February 04, 2013, 07:51:48 pm »
Quote
I disagree. OOP is the present. The future needs concepts that are better suited for parallel programming tasks. The hardware is already set for this, but most languages are not really good to use for parallel programming which is why most programs are still serial.
The future will either be functional programming or more likely something completely different (a not yet discovered concept) that works well for these tasks.
Yes I put that wrong, "present" would be more appropriate.

Wtf where you thinking with that signature? - Phage.
This was another little experiment *evillaughter - Proxx.
Evilception... - Phage

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: C vs. C++
« Reply #5 on: February 04, 2013, 09:36:40 pm »
A question has erected for me:
How do you people decide what language is better for what job when you know a few?

Offline Zesh

  • Royal Highness
  • ****
  • Posts: 699
  • Cookies: 42
    • View Profile
Re: C vs. C++
« Reply #6 on: February 05, 2013, 01:06:08 am »
A question has erected for me:
How do you people decide what language is better for what job when you know a few?

Because said languages have been proven to better at certain jobs than other languages?

Mike245

  • Guest
Re: C vs. C++
« Reply #7 on: February 05, 2013, 03:20:49 am »
Like other people have said here. What language you want to use really just depends on your goals overall.

Offline Xires

  • Noob Eater
  • Administrator
  • Knight
  • *
  • Posts: 379
  • Cookies: 149
    • View Profile
    • Feed The Trolls - Xires
Re: C vs. C++
« Reply #8 on: February 05, 2013, 10:08:10 am »
There are some very decent replies here.  I just wanted to point out something that demands distinction(and that I will probably have to explain later):

C++ is NOT an OOPL(Object-Oriented Programming Language).  C++ provides features which may facilitate OOP.  C++ is not in its entirety, nor at its core, an OOPL.  Also, OOP can be done in C as well.  Granted, it is not as easy or even nice as with C++, but it is definitely a possibility.  C can reproduce pretty much every feature that C++ offers including objects, inheritance and even templates.  There are some things that may be relatively difficult, however, in C.  These include(but are not limited to) advanced scoping(things like 'public', 'private', 'protected', etc.), overloading, overriding(e.g. virtual functions) and try-catch syntax(though advanced error handling can certainly be used for similar effect).


-Xires

Offline Deque

  • P.I.N.N.
  • Global Moderator
  • Overlord
  • *
  • Posts: 1203
  • Cookies: 518
  • Programmer, Malware Analyst
    • View Profile
Re: C vs. C++
« Reply #9 on: February 05, 2013, 10:13:06 am »
A question has erected for me:
How do you people decide what language is better for what job when you know a few?

Good question that deserves a new thread imho.

Usually a language is good at the things it was initially designed for (unless the design is pretty bad, but in this case the language won't be good in other things as well). I am very interested in how languages where created, what the designers had in mind with it, what they tried to overcome, and how the language evolved over time. Sometimes a language also gets good in stuff, it wasn't made for.
But of course you have to look at the time it was created. Sometimes the initial purpose isn't valid anymore. Examples:

Perl was made for text processing.
Basic was made to teach programming.
FORTRAN was made to reduce costs in producing software. As it was the first high level language at all (everything was coded in assembly by then), that worked well. The real strengh it has up until now is performance, because the FORTRAN inventors had to convince the assembly programmers that a machine was able to write code, that is almost as fast as the human made code.

Next thing you can measure it are the usual applications this language is used for.
There are lots of games, game tutorials and game programming books written for C++.
There are lots of operating systems, interpreters and compilers written in C.
There are lots of libraries for web programming for JavaEE and they are used a lot for server side programming of business applications.
Haskell is most often used in universities and less in the world outside. The reasons for that show what it is good for: You can easily prove things written in Haskell, which is something that you need often when you do research for new algorithms etc. Implementing a formula is also pretty easy in Haskell compared to imperative languages.

Last but not least: Programming paradigms, the low or high-level ness and the typing discipline and the supported platforms of the common language implementation also tell what a language is good for.
Low level language: Good at writing drivers,good for system programming, good for every device thst has not much resources and where you need every tiny bit of performance
High level language: Faster and safer in producing software than low level ones
Functional programming: Good for parallel programming
...
« Last Edit: February 05, 2013, 11:01:08 am by Deque »

Offline Xires

  • Noob Eater
  • Administrator
  • Knight
  • *
  • Posts: 379
  • Cookies: 149
    • View Profile
    • Feed The Trolls - Xires
Re: C vs. C++
« Reply #10 on: February 05, 2013, 10:49:00 am »
I agree with Deque; it is a question which warrants its own thread.

Also, BASIC wasn't really a 'teaching' language.  It was born as a macro language for quick tasks that were simple enough in syntax for basic users to create.  Pascal was born as a 'teaching' language as it was designed, essentially, as a unified 'pseudocode' that could be applied to any language which students were already currently learning.  It was meant to allow instructors to explain programming paradigms that were pretty standard(like basic data structures).  It happened to be so well designed that a compiler was easily(well, I'm guessing it was easy..I don't know how much trouble they originally had) created which facilitated its adoption as a language that would continue on past the classroom.

FORTRAN is also really good at quickly handling complex math.  A story that I love telling; several jet fighters(even fairly modern ones) have primary systems coded in FORTRAN.  Once upon a time they wanted to switch to C...a simulator was created and much money was spent.  The pro test pilot taking the first test flight in the simulator reported that it performed quite admirably and superior in some ways to the FORTRAN based systems.  However, there was a major issue that could have proven fatal if it weren't a simulator.  During a test flight, the pilot was instructed to fly to some location below the equator.  The [simulated] plane, with its advanced C-based flight systems, flipped over and the controls became reversed.  Because the plane had flipped, safety systems locked the ejection controls.  Also, because the plane remained inverted for an extended period of time, the engines were cut and various alarms went off because the overall system believed that the plane had 'crashed' in an inverted position in the ocean.  The reason for this was actually fairly simple; there was a discrepancy between 'signed' and 'unsigned' values so flying into airspace where the lines of latitude provide negative values became a bit of an 'issue'(for lack of a more appropriate word).  Anywho..the financial damage was done and the program scrapped in favor of the existing FORTRAN systems which worked damned well already.

COBOL is also a language that could be considered nearly obsolete.  However, it is widely used in several systems that are vital to the USA.  Among these are certain major transportation systems, NASDAQ, several large banking systems, some core telco systems, some gas pipeline controller systems, several large power grids and quite a few scientific systems.

Just because a language seems obsolete doesn't mean it's not useful to learn.
-Xires