Author Topic: C++ instead of C[not what you think]  (Read 13502 times)

0 Members and 1 Guest are viewing this topic.

Offline Uriah

  • Sir
  • ***
  • Posts: 454
  • Cookies: 42
  • άξονας
    • View Profile
Re: C++ instead of C[not what you think]
« Reply #15 on: March 28, 2013, 03:51:22 am »
IMO, the speed difference between c and C++ is vritually non existant.
OOP is merely a programing paradigm that is used, and while yes there are more abstractions used in using classes and objects, I think that programming style and algorithm development will affect your code optimization way the fuck more rather than if you are using a class versus a bunch of structures (c vs c++).

Using classes is really helpful for large projects that need to reuse a set of variables and certain methods to manipulate them over and over again. Its kinda like using functions, but instead you are combining functions and variables together.

WINAPI programming is mainly done in C and does not really use many things from c++, but you can always combine the two (for example you can design your own class using win32 api functions).

Once you start learning c++, you will learn c functions as well. A lot of things used in C++ are nearly identical to C. Basic things like loops, structures, variables, are identical to C and C++. Both languages use pointers (c++ includes references). The only main difference is that in c++ you have to learn how to use Classes and templates.

Not really a BIG difference there.

Even if you find yourself taking a C++ class, you will often stumble across C stuff because a lot of C functions are already there and are working, so why reinvent the wheel?

Saying that you want to learn C before C++ is like saying that you want to learn how to read before you write. Makes no sense. While you are learning to read, you are also learning how to write at the same time. In a typical C++ beginner book, the first 8 or so chapters deal with things that C and C++ share the same. The other half of the book is talking about Classes, inheritance, templates, namespaces, and C++ i/o stream. Loops, Variables, functions, and procedural programming paradigm are the things that each language shares in common (same with java, and many other languages as well.)

Makes no sense.

C++ is just C with classes. Not really a big difference.

"Also for writing server applications I highly recommend a language like Go or Javascript (Node.JS and others)."

I think you are getting confused. Javascript is a client side language, rendered and done through the browser. Server side applications are usually done in PHP.
Umm...node.js is built specifically for server stuff. It's server side. It's not really like traditional JS, even though its the same language afaik.
Also, i wouldn't really agree with c++ being just c with OOP.  Yeah, it has some similar stuff, but many languages are similar to c. Im not very familiar with the c's yet, but from what ive heard there are important differences beyond that, which is why people even take the time to learn both.
(http://www.hongkiat.com/blog/node-js-server-side-javascript/  First sentence.)
« Last Edit: March 28, 2013, 03:52:20 am by Uriah »

Offline Xires

  • Noob Eater
  • Administrator
  • Knight
  • *
  • Posts: 379
  • Cookies: 149
    • View Profile
    • Feed The Trolls - Xires
Re: C++ instead of C[not what you think]
« Reply #16 on: March 28, 2013, 04:33:20 am »
C++ is absolutely far more than "C with classes" or "C with OOP".  First, OOP is more technique.  As previously stated; a design paradigm.  C++ is not actually an OOPL.  It does, however, have features which help support object-oriented design.  Some of these features, which are contained within C++ and not C, include: streams, operator overloading, function overloading, templates, improved scope control(private, public, etc.), virtual functions, inheritance, etc.  There is, indeed, a HUGE difference between C & C++.  In learning 1 language, you learn part of the syntax of the other.  Fortunate for those who begin with C, you are more proficient in C++ with a knowledge of C than you would be in C with knowledge of C++.  Example: if you know how to use a map<char*, char*> in C++, you would have a difficult time reproducing such a thing in C whilst just learning.  Conversely, if you know how to C, a hashtable isn't a horrible thing to conceive and in learning C++, a map is just an added tool for your arsenal.
-Xires

Offline Satan911

  • VIP
  • Knight
  • *
  • Posts: 289
  • Cookies: 25
  • Retired god/admin
    • View Profile
Re: C++ instead of C[not what you think]
« Reply #17 on: March 28, 2013, 10:15:27 pm »
I think you are getting confused. Javascript is a client side language, rendered and done through the browser. Server side applications are usually done in PHP.

No.. NodeJS (http://nodejs.org/) is made for server-side applications in Javascript. So is Backbone.JS (http://backbonejs.org/), SpiderMonkey and some others. A lot of websites and web applications are moving away from PHP for these languages and other frameworks like Ruby on Rails, Django, etc.
Satan911
Evilzone Network Administrator

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Re: C++ instead of C[not what you think]
« Reply #18 on: March 28, 2013, 10:35:30 pm »


If I am to understand this... Do you see C++ as taking a 'skid' approach?  Perhaps because certain things may be easier in C++ than C?  If this is so, please don't confuse 'difficult' with 'better'.  Using Gentoo doesn't make one a more 'hardcore' Linux user(only, hopefully, a more patient one).  Just because something is easier doesn't mean that it's a shortcut or excuse or some cheap way out.


Not at all. I was saying that I want to stick with PHP/MySQL so I can gain a better understanding of websites and SQL injecting. The skid approach I was refering to is in just taking common SQL injections and attempting them on every website I come across, instead of gaining an actual understanding of the languages involved. I wasn't saying that learning C++ is a skid approach at all.

I was really hoping to take more of this approach: C -> ASM and then C++ at some other point in life. I would take the ASM -> C -> C++ approach because that sounds like a lot of fun, but if I 'm going to be taking C++ classes it seems to make sense to make the most out of those classes and really learn C++ and then later move on to C -> ASM.

That's just not really what I wanted to do though. If I weren't taking these classes I would go for C then ASM, or ASM -> C. I have never heard anyone recommend it that way until you Xires. That way sounds fun.
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python

Offline Stackprotector

  • Administrator
  • Titan
  • *
  • Posts: 2515
  • Cookies: 205
    • View Profile
Re: C++ instead of C[not what you think]
« Reply #19 on: March 28, 2013, 11:31:23 pm »
Not at all. I was saying that I want to stick with PHP/MySQL so I can gain a better understanding of websites and SQL injecting. The skid approach I was refering to is in just taking common SQL injections and attempting them on every website I come across, instead of gaining an actual understanding of the languages involved. I wasn't saying that learning C++ is a skid approach at all.

I was really hoping to take more of this approach: C -> ASM and then C++ at some other point in life. I would take the ASM -> C -> C++ approach because that sounds like a lot of fun, but if I 'm going to be taking C++ classes it seems to make sense to make the most out of those classes and really learn C++ and then later move on to C -> ASM.

That's just not really what I wanted to do though. If I weren't taking these classes I would go for C then ASM, or ASM -> C. I have never heard anyone recommend it that way until you Xires. That way sounds fun.
PHP is a good gateway to drugs :). Better than python and whatnot, (personal reasoning). When you get involved into PHP you will be almost forced to OOP practices in modern frameworks. Who will open a gate into the world of OOP C++ :) goodluck :D
~Factionwars

Offline Deque

  • P.I.N.N.
  • Global Moderator
  • Overlord
  • *
  • Posts: 1203
  • Cookies: 518
  • Programmer, Malware Analyst
    • View Profile
Re: C++ instead of C[not what you think]
« Reply #20 on: March 29, 2013, 11:56:53 am »
C is faster because in C++ the compiler has to account for OOP and other stuff and so on average C++ code will run slower.  As a general rule, the higher level you get in programming languages, the slower it will be.  Assembly is faster than C, C is faster than C++ and Obj-C, C++ and Obj-C are faster than Java, Java is faster than python, php, etc.  It isn't the libraries it is how the compiler can optimize one's code.  There are certain things it can do in C faster and better because it doesn't have to take into account things found in C++.

I quoted supermario, who said you can use most C code just like that in C++.
And my question was build upon that statement. If you can use C code in C++ why would the same code be slower compiled as C++ code than compiled as C code?
Your answer is based on the usage of OOP and other features C doesn't have. But that was not my question. The reason is, that if lucid wants to write fast running programs and has to learn C++, he can as well just NOT use OOP and other features that may result in a worse performance to write his speed critical code and still wouldn't have a disadvantage.

Also: It is much too simple to say that code on a higher abstraction level will result into a slowlier running program; or that more optimization leads to faster machine code. There are too many factors not taken into account.
I don't think this discussion belongs to lucids thread, though.

Edit:
Java as a reputation of being super slow for not reasons really. It certainly has a lot of bad stuff but speed isn't one of them.

The reason is that Java was indeed slow before they introduced just-in-time compilation. Some people stated that on the internet while it was still a valid complaint and every noob who wants to find some arguments against Java just rephrases these statements until now.
« Last Edit: March 29, 2013, 01:30:56 pm by Deque »

Offline pllaybuoy

  • Peasant
  • *
  • Posts: 70
  • Cookies: -3
    • View Profile
Re: C++ instead of C[not what you think]
« Reply #21 on: April 03, 2013, 08:37:29 pm »
C++ is like a superset of C . And for sockets programming C is better , but hey ? C++ is C too ! The winsocks was made for C . C++ is better , C is considered by most as closer to hardware than C++ ( I don't know why though). C++ is C with additional features like OOP , and OOP should be preferred over procedural for neater , lesser and sleeker code . Overall I would rate C++ 10/10 while C 8/10 (no offense) . Additional features do matter . You can learn either C or C++ and then learn the other one because it is not really different .(Also you get to learn C# at the same time , which is like the easiest version of C++-thats right , we don't have pointers in C#)
I've learned C++ myself(self learned) and I never found a reason for downgrading to C . For the sockets programming it is not really different because C++ ==Superset.Of.C.

"Monsters are real , ghosts are real too . They live inside us and sometimes they win"

Offline Uriah

  • Sir
  • ***
  • Posts: 454
  • Cookies: 42
  • άξονας
    • View Profile
Re: C++ instead of C[not what you think]
« Reply #22 on: April 04, 2013, 05:20:34 am »
C++ is like a superset of C . And for sockets programming C is better , but hey ? C++ is C too ! The winsocks was made for C . C++ is better , C is considered by most as closer to hardware than C++ ( I don't know why though). C++ is C with additional features like OOP , and OOP should be preferred over procedural for neater , lesser and sleeker code . Overall I would rate C++ 10/10 while C 8/10 (no offense) . Additional features do matter . You can learn either C or C++ and then learn the other one because it is not really different .(Also you get to learn C# at the same time , which is like the easiest version of C++-thats right , we don't have pointers in C#)
I've learned C++ myself(self learned) and I never found a reason for downgrading to C . For the sockets programming it is not really different because C++ ==Superset.Of.C.
Wow...I can't believe i just read that.
« Last Edit: April 04, 2013, 05:20:55 am by Uriah »

Offline Zesh

  • Royal Highness
  • ****
  • Posts: 699
  • Cookies: 42
    • View Profile
Re: C++ instead of C[not what you think]
« Reply #23 on: April 04, 2013, 05:27:50 am »
Wow...I can't believe i just read that.

Exactly! .... xD It was extremely stupid but a little funny at the same time.

Offline techb

  • Soy Sauce Feeler
  • Global Moderator
  • King
  • *
  • Posts: 2350
  • Cookies: 345
  • Aliens do in fact wear hats.
    • View Profile
    • github
Re: C++ instead of C[not what you think]
« Reply #24 on: April 04, 2013, 06:02:05 am »
As for the 'closer to the hardware' issue here is a link:
 http://electronics.stackexchange.com/questions/3027/is-c-suitable-for-embedded-systems

It mostly boils down to dynamic memory and abstraction from hardware. C++ tries to get you away from the hardware, which is why it was kinda made in the first place.

Classes, inheritance, dynamic memory management, etc.. are pushed by C++ to make coding simpler. This is strictly for software developers. Embedded system developers and people working with bare metal not so much. Sure you can go ASM but that is CPU specific, but C is not. C lets the compiler handle it. C is closest you get to universal before ASM, minus all the crappy that's going to Bork your project. This topic can go way off coarse quickly with both sides of the argument. Just making things a bit more clear.

Compile firmware for an 8bit AVR in C then in C++ and see where ya get quicker.
« Last Edit: April 04, 2013, 06:03:18 am by techb »
>>>import this
-----------------------------

Offline pllaybuoy

  • Peasant
  • *
  • Posts: 70
  • Cookies: -3
    • View Profile
Re: C++ instead of C[not what you think]
« Reply #25 on: April 04, 2013, 10:18:54 am »
Exactly! .... xD It was extremely stupid but a little funny at the same time.
Why ? All I said was what I've learned .Can you let me know which part of this is stupid ?(I will correct myself , sorry)
"Monsters are real , ghosts are real too . They live inside us and sometimes they win"

Offline Zesh

  • Royal Highness
  • ****
  • Posts: 699
  • Cookies: 42
    • View Profile
Re: C++ instead of C[not what you think]
« Reply #26 on: April 04, 2013, 12:01:08 pm »
Why ? All I said was what I've learned .Can you let me know which part of this is stupid ?(I will correct myself , sorry)

Well, first of all, it's a jumbled up mess of a post. Then you go on to mention 'winsocks was made for C ." mind explaining this?

"Overall I would rate C++ 10/10 while C 8/10 (no offense)" lulwut?

"Also you get to learn C# at the same time , which is like the easiest version of C++-thats right , we don't have pointers in C#" This is just stupid. What? Can't you understand pointers?

And the whole post is just stupid. If you're going to say one language is better than another then please, write a clear and coherent post, and detail your reasons.

Offline Stackprotector

  • Administrator
  • Titan
  • *
  • Posts: 2515
  • Cookies: 205
    • View Profile
Re: C++ instead of C[not what you think]
« Reply #27 on: April 04, 2013, 12:26:59 pm »
Well, first of all, it's a jumbled up mess of a post. Then you go on to mention 'winsocks was made for C ." mind explaining this?

"Overall I would rate C++ 10/10 while C 8/10 (no offense)" lulwut?

"Also you get to learn C# at the same time , which is like the easiest version of C++-thats right , we don't have pointers in C#" This is just stupid. What? Can't you understand pointers?

And the whole post is just stupid. If you're going to say one language is better than another then please, write a clear and coherent post, and detail your reasons.
It's just his explaination. Everyone has their own. Back on topic.
~Factionwars

Offline pllaybuoy

  • Peasant
  • *
  • Posts: 70
  • Cookies: -3
    • View Profile
Re: C++ instead of C[not what you think]
« Reply #28 on: April 04, 2013, 02:28:31 pm »
Well, first of all, it's a jumbled up mess of a post. Then you go on to mention 'winsocks was made for C ." mind explaining this?

"Overall I would rate C++ 10/10 while C 8/10 (no offense)" lulwut?

"Also you get to learn C# at the same time , which is like the easiest version of C++-thats right , we don't have pointers in C#" This is just stupid. What? Can't you understand pointers?

And the whole post is just stupid. If you're going to say one language is better than another then please, write a clear and coherent post, and detail your reasons.

I am not saying one is better than other . I said OOP approach was better than procedural and that is what makes c++ 'more' useful because it lets you have neater and sleeker code . Also for winsocks , isn't the sockets library of windows winsocks.h or winsockets.h was for C coders and that c++ coder might have to learn a little different syntax for that ?
And I never said C# is better either , all I said is that it is quiet easier than C++ and C . It has no pointers which saves you a lot of hustle , plus it was made for microsoft windows and windows GUI programming is pretty easy with it (than c++ and C) . I haven't used C# myself but my c# coder friend says it has that form elements which windows use as widgets and layouts built in and you don't really need a 3rd party GUI library to code windows programs with it (note here I am saying you don't need a 3rd party library not that you 'can't') . Also  I am not saying  I don't understand pointers ,  Being a c++ coder I do .
Again ,I am a newbie and willing to correct myself if you(or anybody) corrects me here rather than telling me how stupid I am :)
« Last Edit: April 04, 2013, 02:32:36 pm by pllaybuoy »
"Monsters are real , ghosts are real too . They live inside us and sometimes they win"

Offline Stackprotector

  • Administrator
  • Titan
  • *
  • Posts: 2515
  • Cookies: 205
    • View Profile
Re: C++ instead of C[not what you think]
« Reply #29 on: April 04, 2013, 02:34:07 pm »
I am not saying one is better than other . I said OOP approach was better than procedural and that is what makes c++ 'more' useful because it lets you have neater and sleeker code . Also for winsocks , isn't the sockets library of windows winsocks.h or winsockets.h was for C coders and that c++ coder might have to learn a little different syntax for that ?
And I never said C# is better either , all I said is that it is quiet easier than C++ and C . It has no pointers which saves you a lot of hustle , plus it was made for microsoft windows and windows GUI programming is pretty easy with it (than c++ and C) . I haven't used C# myself but my c# coder friend says it has that form elements which windows use as widgets and layouts built in and you don't really need a 3rd party GUI library to code windows programs with it (note here I am saying you don't need a 3rd party library not that you 'can't') . Also  I am not saying  I don't understand pointers ,  Being a c++ coder I do .
Again ,I am a newbie and willing to correct myself if you(or anybody) corrects me here rather than telling me how stupid I am :)

That's C#.net, there is also c++.net VC++
« Last Edit: April 04, 2013, 02:34:32 pm by Factionwars »
~Factionwars