Thread: What can I do in c++, that I can't do in c?

  1. #1
    CIS and business major
    Join Date
    Aug 2002
    Posts
    287

    What can I do in c++, that I can't do in c?

    Hi, I'm trying to get back into c/c++ programming after a 13 year break. Over the past 13 years, I have done programming in other languages, but not c/c++. But what I have done in the past 13 years, is that I've studied a lot of mathematics and mathematical theory. Now, I've just started trying to learn java again, and object oriented programming seems very foreign to me.

    My question is this, with my extensive knowledge of mathematics that I've studied, would I be missing out on much if I simply ignored object oriented programming for the time being, and just stuck with c? I've found that c is very easy to relearn, as it is much more similar to mathematics than c++ and java, much of which, objects and classes I've completely forgotten.

    Could I make due with only programming in c, and not relearning object oriented programming again?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,914
    Why do you want to program in C or C++? After all, if you have an academic background, presumably you're looking into programming to support some kind of research, yet you also "have done programming in other languages", so is there something that you're looking for in a programming language to support your research such that you are looking into C and C++?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    CIS and business major
    Join Date
    Aug 2002
    Posts
    287
    My goal is to become a professional programmer again. I had learned c/c++/c# 13 years ago, before I started college, and I was fairly proficient in these languages, putting over 1000 hours of studying and coding in. But then I went back to college, and I never studied c/c++ again. Now I feel this is a mistake, as programming is my best skill set. But over that time, I studied a lot of mathematics, and I still continued to write code very occasionally. But I'm relearning coding now, starting with Java and c, and I was going to study c++, as I want to relearn powerful and versatile programming languages. But with my enhanced background in mathematics, I feel that the best programming language for me is c, because it is a relatively low level language, with syntax similar to much of what is found in algebra- functions, variables, arrays, which would make relearning c a fairly easy endeavor. Plus I feel c would provide me the best ability to use all of my skills to develop powerful applications in the future.
    Last edited by Terrance; 10-15-2016 at 03:36 AM.

  4. #4
    Nasal Demon Xupicor's Avatar
    Join Date
    Sep 2010
    Location
    Poland
    Posts
    179
    I have to say I'm rather confused. If you were fairly proficient with both C and C++ 13 years ago then where does this question come from? Also, if you were fairly proficient with C++ and C# 13 years ago - how come object oriented programming is very foreign to you?

    I can understand forgetting particulars of syntax used in this or that language after such a break - and seeing modern C++ today might feel like a brand new language altogether, but surely general ideas of OOP would stick, them being language agnostic and all?


    Anyway, technically you can achieve pretty much anything using assembly, but it's not very convenient. The question is very broad. Too broad, maybe. Do you want examples of syntax differences?

    it is a relatively low level language
    Which means it's "closer to the machine"*, not "closer to math".

    There's Mathematica, MATLAB/OCTAVE... I hear Maple is specifically designed to use mathematical notation. Maybe have a look at Python and its ecosystem - it has NumPy, SciPy, Sage and others... R might be a pretender if you're into statistics more. Haskell is purely functional so it may feel more like math than C does (I wouldn't know - I'm not a mathematician).
    Sure, you can do math in C or C++ - but I guess I'd go with these if I specifically wanted - well, more like really needed - to squeeze that raw performance. And even then - it's not necessarily a given that the boost will be that impressive.

    What in particular do you plan to do?


    __
    *) Tsk, I know, I know. "The machine" is indeed pretty abstract.

  5. #5
    CIS and business major
    Join Date
    Aug 2002
    Posts
    287
    Hi, 13 years ago is a long time, and I have forgotten object oriented programming over that time. When I first learned c/c/++/c#, I had not yet started college, so I took an intense boot camp on c/c++/windows programming, because I originally wanted to skip college and become a professional programmer. Although, without a degree, I was never able to find a job as a programmer, so I stopped coding and went back to school. I had learned all programming material taught in a computer science program before beginning college, thus I didn't major in computer science, though I did major in computer information systems at the undergraduate level, and I took a lot of mathematics courses, which have helped me in my logical thinking skills.

    But my goal is to again relearn programming in c/c++. I know visual Basic and SQL at the moment, and I would prefer not to learn Matlab, but I would consider R. I am a business analyst now, I have an MBA, but my work still entails considerable amounts of programming. In fact, I would consider going back into computer programming in the future.

    In terms of why I would like to relearn programming in c/c++, I would prefer to learn a complex language, that would allow me to maximize my value as a programmer over the long term. I also want to get as much value out of my mathematics training as well, and c is a great language to do that in. My goal is to work for a company like Microsoft, and use my programming and business knowledge in the best manner possible, or to get as high up the company ladder as possible.

    I'm not a people person, so I don't use sales methods or politics to improve my career prospects. Further, I want to relearn c because it was a versatile language, and one of the first languages I really learned, other than scripting languages.
    Last edited by Terrance; 10-15-2016 at 07:27 AM.

  6. #6
    CIS and business major
    Join Date
    Aug 2002
    Posts
    287
    And I do plan on relearning c, so not learning c again isn't an option. But I wonder if it is worthwhile for me to relearn c++ in the near future, or if I should just wait and see if I need to relearn it down the road.

    In other words, what benefit is there in learning c++ if I can remaster c again. Is there any? I realize c++ cuts down on programming time, with classes and additional built in libraries, etc. But since I'm relearning programming on my own terms, I don't mind the added complexity of using c, even if it is more difficult to use, since it is a low level programming language. I have started relearning Java again, and much of object oriented programming is not very intuitive from a mathematical perspective. But c is very intuitive from a mathematical (and economics) perspective, because it is based around the use of functions, pointers, decision making and memory allocation considerations. So c is far more intuitive for me at the moment given my education in business and mathematics.

    So again, what benefit is c++ over c, other than the reduced complexity of use and time saved?

    My current plan is simply to remaster c, and relearn c++ in the future when I have to. Also, I plan on reading the book The Art of Computer Programming, by Donald Knuth. This book is very mathematical, and goes in depth into describing programming algorithms and how they are structured. Knuth has a PhD from Cal Tech, and even Bill Gates said he had difficulty reading this book, and wants programmers who have read this book.
    Last edited by Terrance; 10-15-2016 at 07:48 AM.

  7. #7
    Registered User
    Join Date
    Jun 2015
    Posts
    1,643
    To answer your original question, there's nothing you can do in C++ that you can't do in C.

    And everyone here is aware of the classic Knuth books (and probably own their own copy).

  8. #8
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    C++ has a ton of language features and a ton of library stuff that makes it much, much less error prone and much, much faster to write your program. Unless you're going to work for within embedded systems, I would strongly encourage you to just learn C++ and roll with that. That is, this is if you're dead set on learning C or C++. The usage of C++ has declined a lot within these 13 years and the market typically wants Java or C# nowadays as far as I know.

    Thing is - even if you're using C++ as a better C, you will find that it has a lot of stuff to offer you, such as smart pointers and templates. It WILL make your life easier, and if you want to learn programming, I would strongly suggest you learn a language that you think will be beneficial to your knowledge, education or work, rather than taking the easy path and learning the language that looks the simplest to learn to you.

    The benefit of C++ is that you will write code that is more robust, secure and easier to read and maintain, as well as cutting down time to write and debug it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    CIS and business major
    Join Date
    Aug 2002
    Posts
    287
    Quote Originally Posted by algorism View Post
    To answer your original question, there's nothing you can do in C++ that you can't do in C.
    This answers my primary question. I'm looking to learn more about programming at the lowest level possible, without getting into writing assembler code. I realize that there are many benefits of using c++, but these benefits translate into business benefits more than mere intellectual benefits. Java and c# derive their benefits from usability issues, and this is why they are hot in the job market. These languages were designed for use by businesses, hence why they are easier to use than c (in terms of efficiency of use). But since I would like to relearn on my own, and I have an enhanced knowledge of mathematics since I first learned c, I would like to use this language to help me learn programming at a low level, so I can really grasp the granular aspects of programming, and enhance my understanding of programming over the long term.

    But yes, I agree that c++ (or better example, c# and java) was designed for complex usage, and is much less error prone than c, and better suited for business and commercial projects. Though, I am still leaning towards a short term focus, mostly in c for my learning endeavors.
    Last edited by Terrance; 10-15-2016 at 10:10 AM.

  10. #10
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Terrance View Post
    I'm looking to learn more about programming at the lowest level possible, without getting into writing assembler code.
    You can do that with C++ too, just so you know. The motto of C++ is essentially "don't pay for what you don't use" and it allows you to be as close to the metal as C. But neat thing is that you can accomplish close to the metal even with higher abstractions using C++. Many people think that using complex abstractions makes everything slow, but that's not always the case (just look at all those AAA games out there written in C++).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #11
    Registered User
    Join Date
    Apr 2013
    Posts
    1,656
    Quote Originally Posted by Terrance View Post
    Java and c# derive their benefits from usability issues, and this is why they are hot in the job market. These languages were designed for use by businesses.
    Java, C#, and java script are popular for specific aspects of businesses. For server / cloud applications, there are high end languages like Microsoft Azure, that handle aspects like multi-processing and load balancing automatically (the programmer doesn't have to worry about this). For banking type applciations, COBOL is still used. A lot of business stuff is implemented via database oriented languages. Some scientific stuff is still using Fortran due to legacy issues (too much code to convert).

    As far as math goes, my work involved multi-threaded embedded systems, and almost all of the math oriented stuff I did was related to Reed Solomon error correction codes, which is a very niche skill. Most of the code I've seen on the embedded systems I've worked with were implemented in C with some assembly for the operating system.

    You should consider what type of work you would be interested in and find out what languages are used in that field.
    Last edited by rcgldr; 10-15-2016 at 06:35 PM.

  12. #12
    CIS and business major
    Join Date
    Aug 2002
    Posts
    287
    And although I would say that I'm lying if I weren't at least tempted to skip some corners in relearning c. I will have to say that one benefit of only relearning c and not c++ is that I don't want to reread all of those long c++ books, and focus my relearning process on actually coding and doing exercises. With c, I won't have to read through tons of c books to relearn all of the syntax, which means I can focus more time on doing exercises to relearn c. This is because c is so mathematically intuitive, that I can learn all of c's syntax merely by reading the Kerninghan and Ritchie book, and most of it will be intuitive because of its mathematical nature. But with c++, I'm sure I would have to read a lot of books to relearn object oriented programming. Since I learned c/c++ in the past by coding and doing exercises, I will try to do the same now.
    Last edited by Terrance; 10-15-2016 at 06:28 PM.

  13. #13
    CIS and business major
    Join Date
    Aug 2002
    Posts
    287
    Quote Originally Posted by rcgldr View Post

    You should consider what type of work you would be interested in and find out what languages are used in that field.
    This is what I'm looking to avoid, programming for the sheer purpose of becoming more marketable to businesses. The problem with focusing on increasing your job market value is that the real world expects you to code in a manner that is most cost-effective for the business. Thus, a business will want you to code in COBOL if that is best for the business, or vb.net if it makes reusing the code in the future easier, or focusing on something that would make you a better team player, etc.

    While I like c due to its mathematical intuitiveness, I feel I would get a lot out of doing low level programming problems in c, like building link lists and reverse link lists again, and not focusing on what employers want or what I would need to do in the future to secure such and such a job. I simply want to get the most out of my prior experience in c combined with my mathematical education, combined with learning programming at a low level.
    Last edited by Terrance; 10-15-2016 at 06:41 PM.

  14. #14
    Registered User
    Join Date
    Apr 2013
    Posts
    1,656
    The syntax for C / C++ is essentially the same. Quite often, you can rename a .c file to a .cpp file and it will compile just find. I find formatted output via printf is simpler than the <iomanip> stuff used for std::cout, but you can use printf in a C++ program. If you're goal is to implement algorithms as a learning experience, then you probably don't need to use C++ tutorials, most of which would be C++ specific.

    Regarding math, matlab is popular among engineers, at least for just getting answers to problems, where maximum efficiency isn't needed as most of the time it's a one time effort to get a solution to a problem. C and C++ lack of a exponentiation operator makes it cumbersome to implement mathematical formulas. My coworkers that used Visual Basic mostly used it for it's drag and drop design for a user interface that included graphs and charts, where Visual Basic would generate the user interface code, and the engineers would just have to add the code to gather inputs and perform the related math.

    You still haven't mentioned what type of jobs you would be interested in. You may not be interested in COBOL type environments, but you might like something like multi-threaded embedded systems (since most of this is done in C).
    Last edited by rcgldr; 10-15-2016 at 06:46 PM.

  15. #15
    CIS and business major
    Join Date
    Aug 2002
    Posts
    287
    While c code can be compiled in a c++ compiler, indicating similar syntax, the actual usage of c++ programming becomes much different, from what I remember (although I haven't done heavy duty c++ coding in 13 years). For the c++ boot camp I took, the course was designed by a master programmer, with a phd, although I don't think his phd was computer related. But irregardless, actually coding in c++ becomes a very different endeavor from coding in c, from what I remember (if you push c++ to its capabilities, and don't use a lot of c syntax). Further, c# is basically vb.net using c/c++-like syntax as the base language, so c# is mostly useful for a Windows programming from what I remember.

    In terms of what types of programs I would like to write professionally in the future, I would like to write code for business to business applications. I have also always wanted to develop a video game, but my lack of a background in physics would probably disallow me from ever creating a good game, and I probably wouldn't take the time to code a full blown game just for fun.
    Last edited by Terrance; 10-15-2016 at 07:09 PM.

Popular pages Recent additions subscribe to a feed

Tags for this Thread