Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Which is Better C or C++?
Forum Updated to NodeBB v4.3 + New Features

Which is Better C or C++?

Scheduled Pinned Locked Moved Unsolved Language Bindings
c++
5 Posts 5 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mayankjain
    wrote on last edited by
    #1

    Hello All, I am start learning C programming language but till confused which programming language is good for my carrier? Which profile will make my carrier bright? Any suggest which one good C or C++

    K jsulmJ JonBJ 3 Replies Last reply
    0
    • M Mayankjain

      Hello All, I am start learning C programming language but till confused which programming language is good for my carrier? Which profile will make my carrier bright? Any suggest which one good C or C++

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @Mayankjain

      Hi and welcome to devnet forum

      This is not exactly a Qt related question.

      C is older and also the basis of C++. C++ is object oriented and has therefore more possibilities to improve your programming.

      This is a very rough statement. I suggest to google https://lmgtfy.com/?q=C+vs+C%2B%2B&s=g and check the responses. However, it is probably one of the longest fights which is better after C++ has been invented.

      If you plan to use a library like Qt. You need to understand C++. When you understand C++ you basically have also the knowledge of C.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      6
      • M Mayankjain

        Hello All, I am start learning C programming language but till confused which programming language is good for my carrier? Which profile will make my carrier bright? Any suggest which one good C or C++

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @Mayankjain said in Which is Better C or C++?:

        my carrier

        What would be your carrier? What kind of software are you going to develop? Because programming language depends on use case. For example: if you're going to contribute to Linux kernel then learn C, if you want to develop GUI applications learn C++, ...

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        4
        • T Offline
          T Offline
          techgeekbuzz
          wrote on last edited by
          #4

          According to me or all the deveoper, Both are better for the beginning.

          I always choose C++ because it is a superset of C. C++ contains all the features of C and in addition to that, it has Object-Oriented features. The new C++ specification(called as C++11) contains a lot more features like Threading, Synchronization, lighter version of garbage collection,..etc. If you choose C, then you have relied on the platform libraries(thread, win thread,..) for most of the works. But C++ provides a lot of utilities as part of its STL(Standard Template Library).

          C++ abstracts the functionalities and exposes it in a nicer way

          Consider a string operation,

          In C,

          const char* foo = "foo"; // char* is a language construct
          const char* bar = "bar";
          char* foo_bar = malloc(strlen(foo) + strlen(bar) + 1); //to concat foo and bar, you need to allocate a memory
          strcpy(foo_bar,foo);
          strcat(foo_bar, bar) 
          

          In C++

          std::string foo = "foo"; // std::string is a STL utility class.
          std::string bar = "bar"
          std::string foo_bar = foo + bar; // that's it :) + operator is overloaded in std:string
          // or
          std::string foo_bar = foo + "bar";
          

          See the C++ code, it nicely abstracts the functionalities even though it does all magics behind the seen.

          You can do the same functionality using both C and C++, but the significance is modularity and readability. C++ allows the programmer to concentrate on the real problem rather than diverting them.

          Edit1: (Adding some details about Object-Oriented and Abstraction)

          1. Object-Oriented
            It is a programming paradigm, allow the programmer to think about the problem in terms of Objects and Classes.

          1.1. Classes

          It is very similar to a real-world classification based on the properties and behavior.

          For example, Animal is a class. Human-being is a class. The vehicle is also a class.

          Why they are all classes? because all those defines the set of properties and behaviors to a classified group.

          In simple words, the class is a blueprint. (or Design time entity). Above example std:: string is a class.

          1.2 Object

          The object gives real shape to a class. I and You are Objects of Class Human-being. Dogs and Cats are Objects of Animals. I and You also Object of Animals. Cars and Bikes are Objects of Vehicle.

          In the above example, foo and bar are the Objects of Class std:: string.

          1.3. Abstraction

          Hiding the implementation details from the programmer. In the above string example, "+" operation abstracts the implementation details(memory allocation, string concat) from the programmer.

          Standard Temple Library

          It is C++ library which provides generic type-safe utility programs like string, list, vector, hashmap, automatic memory management(auto_ptr),..etc.

          For example, you can quickly create a list of students like below,

          std::list<Student> students;
          students.add(student1);
          students.add(student2);
          

          For more detailed comparison in performance of C vs C++.

          1 Reply Last reply
          2
          • M Mayankjain

            Hello All, I am start learning C programming language but till confused which programming language is good for my carrier? Which profile will make my carrier bright? Any suggest which one good C or C++

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @Mayankjain
            C is plain better (IMHO) :) But for your career, C++ is definitely more advisable!

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved