What computer science class should I take for my math degree? C or C++?

In summary, the conversation revolves around the question of which programming language would be most suitable for someone with a math background who needs to fulfill a computer science credit. The options discussed are intro to C and intro to C++, but there is also mention of potentially taking a class in MATLAB or Fortran if they meet the requirements. Some suggest taking both intro to C and C++, while others recommend taking only one or exploring other options like MATLAB. There is also a debate about which language is better for beginners, with some saying C++ is easier due to its higher level and focus on OOP, while others argue that C is more fundamental and therefore better for learning. Ultimately, the decision would depend on the individual's goals
  • #1
cragar
2,552
3
I need a computer science class for my math degree.
Should I take intro to C or intro to C++ . I know nothing about programming.
 
Physics news on Phys.org
  • #2
C. After an intro to C++ you'll barely be able to to anything with it, and it's too complex to even begin to understand. C is simple, and understanding pointers is something a math guy should handle easily.

And, just to be clear, it is unlikely that either one will have anything to do with computer science -- they will be programming classes. If you want to take a class that is actually about computer science, take an introduction to data structures and algorithms.
 
  • #3
He likely just needs a programming language, I'd honestly advise doing both, C then C++. You won't be that proficient after, but you'll be able to write code that may be beneficial to you. Does your college offer a Matlab out Fortran class by chance, and will those meet the requirements? Then I would advise one those for you instead. Like IGU says though, I wouldn't consider any of those classes real CS, I've done three languages now and still don't understand the behind the scenes of what's happening. After I build my code, run it, It's sort of like magic at that point.

Stacks, how the processor does what it does, ect are still a mystery to me
 
Last edited:
  • #4
I think we have a math class that uses matlab. should I take intro to c first then c++.
 
  • #5
cragar said:
I think we have a math class that uses matlab. should I take intro to c first then c++.

I would recommend it if at all possible with your class scheduling, you'll have a much better , perhaps useful, understanding.
 
  • #6
so take a class that uses matlab, but if that won't work take intro to c first.
 
  • #7
I question the advice of taking two 'intro' CS courses. The fundamentals for both should be about the same thing. If you're planning to go on to do programming in your life then either one are just a stepping stone and C and C++ should be fairly interchangeable for you at the level that you will be working in the near future. If you're not planning to go on to do more programming then taking to intro CS classes is a waste of time for even more obvious reasons.

I think C++ is better language to begin with, personally. Perhaps that's a matter of taste?

It's hard to recommend a class without seeing a syllabus. Also, all you've said is that you're fulfilling credit. If that's the case, then the choice is fairly inconsequential. In my experience people have an easier time with C++ than C.
 
Last edited:
  • #8
If you can take multiple of those courses, then C -> C++ would be the obvious answer. However, if your school offers MATLAB or you only want to take one course, then I would recommend MATLAB or C++.
 
  • #9
ChaseDuncan said:
I question the advice of taking two 'intro' CS courses. The fundamentals for both should be about the same thing. If you're planning to go on to do programming in your life then either one are just a stepping stone and C and C++ should be fairly interchangeable for you at the level that you will be working in the near future. If you're not planning to go on to do more programming then taking to intro CS classes is a waste of time for even more obvious reasons.

I think C++ is better language to begin with, personally. Perhaps that's a matter of taste?

It's hard to recommend a class without seeing a syllabus. Also, all you've said is that you're fulfilling credit. If that's the case, then the choice is fairly inconsequential. In my experience people have an easier time with C++ than C.

Why would people have an easier time with C++ then C? That makes no sense.

The fundamentals for each will be completely different, C will give you the syntax and introduce you to programming languages, an intro to C++ class should focus on classes and OOP.
 
  • #10
Student100 said:
Why would people have an easier time with C++ then C? That makes no sense.
Exactly. I would not recommend C++ as an introductory language. It's just too big. Python is just about perfect for a beginner language, but that apparently isn't an option.
 
  • #11
Student100 said:
Why would people have an easier time with C++ then C? That makes no sense.

The fundamentals for each will be completely different, C will give you the syntax and introduce you to programming languages, an intro to C++ class should focus on classes and OOP.

Because C++ is higher level which makes the code more readable and less cryptic.

I think the important thing to keep in mind here is that we're talking about 'intro' courses not mastery. On an introductory level, OOP is just easier for people to interface with.
 
  • #12
D H said:
Exactly. I would not recommend C++ as an introductory language. It's just too big. Python is just about perfect for a beginner language, but that apparently isn't an option.

I agree with you about Python or even Java but as you said, that's not an option. I'm not really sure about your 'big' statement, however. C is pretty darn big too for someone with no programming experience. I doubt the range of either them will be covered in a significant way in an intro class, thus I can't see how it matters much.

That being said, I'd like to see syllabi. I have strong doubts about classes that are about languages. I'm of the mind that a CS class should be about topics in CS. The language is sort of incidental.
 
Last edited:
  • #13
ChaseDuncan said:
Because C++ is higher level which makes the code more readable and less cryptic.

I think the important thing to keep in mind here is that we're talking about 'intro' courses not mastery. On an introductory level, OOP is just easier for people to interface with.

Errr, I would disagree with everything you wrote.
 
  • #14
ChaseDuncan said:
I agree with you about Python or even Java but as you said, that's not an option. I'm not really sure about your 'big' statement, however. C is pretty darn big too for someone with no programming experience. I doubt the range of either them will be covered in a significant way in an intro class, thus I can't see how it matters much.

That being said, I'd like to see syllabi. I have strong doubts about classes that are about languages. I'm of the mind that a CS class should be about topics in CS. The language is sort of incidental.

His "big" statement is perfectly accurate, even standardization committees take jabs at how large C++ is. C is tiny.

I'm seriously doubting you know what you're talking about at this point.
 
  • #15
Student100 said:
His "big" statement is perfectly accurate, even standardization committees take jabs at how large C++ is. C is tiny.

I'm seriously doubting you know what you're talking about at this point.

You've missed the point. The bigness of C++ relative to C is irrelevant in an introductory course. It's not as if you will explore the entire language -- or anything close to it. Of course, that irrelevance sort of runs both ways. Thus I don't think it matters much if this person takes an intro to C course or an intro to C++. What will matter is the topics that are covered in the course. The language is incidental, as I said. That's also the reason it's entirely pointless to take two intro courses.
 
Last edited:
  • #16
Student100 said:
Errr, I would disagree with everything you wrote.

As you are perfectly entitled to do. Still it is my experience and I believe that's what we're here to share, no?
 
  • #17
ChaseDuncan said:
You've missed the point. The bigness of C++ relative to C is irrelevant in an introductory course. It's not as if you will explore the entire language -- or anything close to it. Of course, that irrelevance sort of runs both ways. Thus I don't think it matters much if this person takes an intro to C course or an intro to C++. What will matter is the topics that are covered in the course. The language is incidental, as I said. That's also the reason it's entirely pointless to take two intro courses.

I'm not talking about the bigness of C++ relative to C. I'm saying C is a tiny language compared to just about any other language you might use. While C++ is a monster of a language compared to any language you might use. This is only relevant because of what you wrote in your past post which I found blatantly wrong.

Of course it matters, if the OP just wants to meet the requirement and C will do that for them, then wham bam you're done. If the OP wants to have a bit better grasp of different programing styles, then taking C++ after will prove useful to them. So I don't understand how you say it's useless to be exposed to procedural programming (C) and then OOP style (C++), just because they're two "intro" courses.
 
  • #18
Student100 said:
Errr, I would disagree with everything you wrote.

Im pretty sure higher level languages make for more readable code for humans. It is pretty much the point of a higher level language to be more readable for humans.
 
  • #19
ChaseDuncan said:
That being said, I'd like to see syllabi. I have strong doubts about classes that are about languages. I'm of the mind that a CS class should be about topics in CS. The language is sort of incidental.
I agree. An introductory CS class should teach how to program (in general) instead of teaching the ins and outs of one specific language. A language is needed to teach how to program, but teaching the language should be a secondary concern.

Since one of the core concepts of computer science is object oriented programming, this should be a part of the very first CS class. In my opinion, of course. Teaching OO techniques with a non-OO language such as C is beyond the scope of a introductory class.

A good introductory language is one that
  1. Is easy to use and easy learn.
  2. Offers a number of different programming paradigms.
  3. Contains a number of computer science data types, built in.
  4. Provides well-established defensive programming mechanisms, many dating back to the early 1960s.
  5. Doesn't carry a lot of arcane baggage.

C fails massively on items 2 and 3. C++ fails somewhat on item 1. Python fails massively on item 4. All have significant shortcomings with item #5. It's not so much a matter of which is better but which is worse.
 
  • #20
D H said:
I agree. An introductory CS class should teach how to program (in general) instead of teaching the ins and outs of one specific language. A language is needed to teach how to program, but teaching the language should be a secondary concern.

Since one of the core concepts of computer science is object oriented programming, this should be a part of the very first CS class. In my opinion, of course. Teaching OO techniques with a non-OO language such as C is beyond the scope of a introductory class.

A good introductory language is one that
  1. Is easy to use and easy learn.
  2. Offers a number of different programming paradigms.
  3. Contains a number of computer science data types, built in.
  4. Provides well-established defensive programming mechanisms, many dating back to the early 1960s.
  5. Doesn't carry a lot of arcane baggage.

C fails massively on items 2 and 3. C++ fails somewhat on item 1. Python fails massively on item 4. All have significant shortcomings with item #5. It's not so much a matter of which is better but which is worse.

C++ isn't too hard to learn with the right resources. Also, I am aware of no language in existence which meets your above criteria. At this point, all languages have there short-comings. An introductory, easy-to-learn language can not be expected to support OOP, imperative and functional programming for example.
 
  • #21
Because C++ is higher level which makes the code more readable and less cryptic.

I think the important thing to keep in mind here is that we're talking about 'intro' courses not mastery. On an introductory level, OOP is just easier for people to interface with.

jesse73 said:
Im pretty sure higher level languages make for more readable code for humans. It is pretty much the point of a higher level language to be more readable for humans.

And when did C become a low level language? C/C++ are both high level languages, it's just that C++ evolved from C by adding some levels of abstraction.

You can equally obfuscate both C and C++ to the point of non-readability, but that isn't the point now is it. Any intro level C code is just as readable as C++ code, if not more so. The whole point is the OP knows nothing about programming. Why throw in OO style when they don’t even understand syntax or what a complier is, or how to put together functioning code.

Learning C before C++ can only help you.

D H said:
I agree. An introductory CS class should teach how to program (in general) instead of teaching the ins and outs of one specific language. A language is needed to teach how to program, but teaching the language should be a secondary concern.

Since one of the core concepts of computer science is object oriented programming, this should be a part of the very first CS class. In my opinion, of course. Teaching OO techniques with a non-OO language such as C is beyond the scope of a introductory class.

A good introductory language is one that
  1. Is easy to use and easy learn.
  2. Offers a number of different programming paradigms.
  3. Contains a number of computer science data types, built in.
  4. Provides well-established defensive programming mechanisms, many dating back to the early 1960s.
  5. Doesn't carry a lot of arcane baggage.

C fails massively on items 2 and 3. C++ fails somewhat on item 1. Python fails massively on item 4. All have significant shortcomings with item #5. It's not so much a matter of which is better but which is worse.
What would you consider the short coming of someone learning procedural programming to get their feet wet before learning OOP?

You definitely shouldn't be trying to teach OOP in C, it's not the easiest thing to do, and C doesn't really support it.
 
Last edited:
  • #22
thanks for the responses, My classes will be intro to c, set theory, and English 101, quite a variety.
 
  • #23
Student, C++ and to some extent C are both considered relatively low-level languages. Learning any language can only help you, and this goes with C before C++ as well. The transition from C -> C++ wouldn't be too difficult. However, C++ can be learned without any background knowledge as well. Cragar, C is becoming more obsolete nowadays. For the most part, you should expect having to learn C++ or another language later in your life. I am not saying C is a bad language - C and C++ are my favorite languages - but the former is becoming less-used nowadays..
 
  • #24
Shivam3013 said:
Student, C++ and to some extent C are both considered relatively low-level languages.

Relatively low-level languages of the higher level languages – if we want to start ordering them –I'll agree, but they're not low level languages.(I would also consider C lower than C++, since C++ has added abstraction, but this ordering of high level languages is kind of silly, and you could ask 100 different computer scientist and you'd get a lot of different opinions.)
 
Last edited:
  • #25
Shivam3013 said:
The transition from C -> C++ wouldn't be too difficult.
I disagree. From my own experience working with others who have never been exposed to object oriented techniques, the transition from C to C++ is extremely difficult. Transitioning from python or smalltalk to C++ is going to be much easier than transitioning from C to C++. As a starter, understanding pointers is an essential part of understanding C. Well-written C++ code does *not* use pointers for the most part. Herb Sutter, the chair of the C++ standards committee, claims to have not used raw pointers (i.e., C-style pointers) for years. From what I can tell, he *hates* raw pointers.
 
  • #26
cragar said:
thanks for the responses, My classes will be intro to c, set theory, and English 101, quite a variety.

Little bit of everything. :approve:

If you can I'd still recommend you squeeze C++ in thereafter, and if you find you like programming and computer science, look into a class called data structures.

D H said:
I disagree. From my own experience working with others who have never been exposed to object oriented techniques, the transition from C to C++ is extremely difficult. Transitioning from python or smalltalk to C++ is going to be much easier than transitioning from C to C++. As a starter, understanding pointers is an essential part of understanding C. Well-written C++ code does *not* use pointers for the most part. Herb Sutter, the chair of the C++ standards committee, claims to have not used raw pointers (i.e., C-style pointers) for years. From what I can tell, he *hates* raw pointers.

I think I wouldn't have been as good in my C++ class without taking C first. I knew *nothing* about computer programming before C; like, I didn't know what an IDE was. It helped me, and the differences between C and C++ in the beginning are very subtle.

Subtle enough it allowed me time to focus on getting OOP.

Just my anecdotal experiences and logic behind it.
 
Last edited:
  • #27
Student100 said:
And when did C become a low level language? C/C++ are both high level languages, it's just that C++ evolved from C by adding some levels of abstraction.
Readability and whether a language is low level or high level language are not defined by binary functions. It is more of a continuous variable where you can rank things as how readable or low level they are.
 
  • #28
D H said:
I disagree. From my own experience working with others who have never been exposed to object oriented techniques, the transition from C to C++ is extremely difficult. Transitioning from python or smalltalk to C++ is going to be much easier than transitioning from C to C++. As a starter, understanding pointers is an essential part of understanding C. Well-written C++ code does *not* use pointers for the most part. Herb Sutter, the chair of the C++ standards committee, claims to have not used raw pointers (i.e., C-style pointers) for years. From what I can tell, he *hates* raw pointers.

The both have their uses but as Bjarne Stroustrup once said about C or C++:
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off.
 
  • #29
If you understand how state and flow-control works in different kind of computational environments, you will be able to understand a foreign language very quickly as opposed to not knowing the above.

All languages have their own take on the state and flow-control of a program and being able to define these attributes quickly will translate in being able to pick up a language quickly as well (which translates to writing code and getting results quickly).
 
  • #30
Student100 said:
And when did C become a low level language?

It never became one. it was one, right from day one. It was designed as something "better than assembler code", for writing system software and operating systems. For scientific computing, it isn't even as high level as Fortran IV.

C is inherently intertwined with the way computer hardware was designed and built in the 1970s. Specific example - how much of the world population uses a first human language where a sensible representation of a "character" is an 8-bit integer? Apart from the subset of Americans whose first language is not Spanish, of course :smile:

And even if you can squeeze a useful collection of accented western letters into 256 characters rather than 128, don't expect to get sensible results if you try to sort arrays of character strings...
 
  • #31
AlephZero said:
It never became one. it was one, right from day one. It was designed as something "better than assembler code", for writing system software and operating systems. For scientific computing, it isn't even as high level as Fortran IV.

C still meets the definition of a high level language, does it not? Or am I just totally lost here.
 
  • #32
The whole notion of high level and low level languages are relative.

Its a matter of opinion but and I hate quoting a wiki page but even the wiki page on "high level language" has

"The terms high-level and low-level are inherently relative. Some decades ago, the C language, and similar languages, were most often considered "high-level", as it supported concepts such as expression evaluation, parameterised recursive functions, and data types and structures, while assembly language was considered "low-level". Today, many programmers might refer to C as low-level, as it lacks a large runtime-system (no garbage collection, etc.), basically supports only scalar operations, and provides direct memory addressing. It, therefore, readily blends with assembly language and the machine level of CPUs and microcontrollers."

which has stood unedited despite the high visibility of a page for such a simple term which would make it susceptible to correction if it was a controversial statement.

High level language is a term not a mathematical theorem which means its only defined by humans and their majority opinion of the term.
 
  • #33
I agree with Student100; the level is calculated by it's level of abstraction and in that sense, C and C++ are not low level. Fully relative comparison lacks in accuracy.
 
  • #34
Crager,

The underlying implication here is what you want to do with the course, and if that's take it, ace it, and forget it, it doesn't really matter.

At the level of learning basic high level programming syntax the choice between C and C++ is superficial. You probably won't be exposed to the situations that emphasize the advantages of using one over the other. For simple, procedural programming, the syntax is mostly the same, barring some compiler overhead you won't get into until data structures anyway.

As someone who completed an Applied Mathematics degree and now works as a Software Engineer I advise choosing the class that gives the broadest focus in the subject. Choose the class that, while emphasizing procedural programming, exposes the student to binary math, basic data structures, basic memory management, and introductory search/sort algorithms. You won't learn the conceptual knowledge you need for awareness or debugging if the C++ class emphasizes Object-O over the aforementioned subjects. If the choice is purely between compiler extension (C or C++), I'd choose C. Less bloated code == greater awareness.

And for anyone who wants to learn more about programming and the extent of their technical knowledge ends with Ctrl-Alt-Del I'd recommend looking into the aforementioned content, and focus on a strongly-typed, compiled language like C first, move into a Object-O scripting language like Python next, spend some time on Data structures, and then consult texts on assembly or systems specific (API's for Linux/Unix/GNU, Cocoa, or Android) after getting your feet wet first.
 

What are the differences between C and C++?

C and C++ are both programming languages that are widely used in computer science and engineering. C is a procedural programming language, meaning it follows a step-by-step approach to solve a problem. C++ is an object-oriented programming language, meaning it focuses on creating objects and classes to solve a problem. C++ also has additional features such as inheritance and polymorphism that are not present in C.

Which language is better for a math degree?

Both C and C++ can be useful for a math degree, as they both have strong mathematical capabilities. However, C++ may be more beneficial in the long run as it has more advanced features and is widely used in scientific and mathematical applications.

What are the job prospects for C and C++ programmers?

Both C and C++ are popular programming languages and are used in a variety of industries, including technology, finance, and gaming. Programmers with knowledge of these languages can find job opportunities in various fields, including software development, data analysis, and research.

Which language is easier to learn?

This is subjective and depends on the individual's learning style and background. C is a simpler language with fewer features, making it easier to learn the basics. However, C++ has a steeper learning curve due to its more advanced features and concepts. Ultimately, the best language to learn would depend on the individual's goals and interests.

Can I learn both C and C++ simultaneously?

Yes, it is possible to learn both languages simultaneously. However, it may be more beneficial to focus on one language at a time to fully understand its concepts and syntax. Once you have a strong foundation in one language, it will be easier to learn the other as they have many similarities.

Similar threads

  • STEM Academic Advising
Replies
3
Views
825
  • STEM Academic Advising
Replies
8
Views
1K
  • STEM Academic Advising
Replies
9
Views
1K
  • STEM Academic Advising
Replies
6
Views
1K
  • STEM Academic Advising
Replies
14
Views
621
  • STEM Academic Advising
Replies
1
Views
457
  • STEM Academic Advising
Replies
9
Views
1K
  • STEM Academic Advising
Replies
6
Views
1K
  • STEM Academic Advising
Replies
16
Views
2K
Replies
19
Views
2K
Back
Top