Is C the Best Language for Beginners and Which Book Should I Buy?

  • Thread starter jbmiller
  • Start date
  • Tags
    Choice
In summary: It's close enough though for bare metal since only with the exception of device drivers, super-optimized routines for particular chipset types or extensions, it's good enough for the kind of micromanagement required for fast software and with a good compiler, nowadays the results are good enough performance-wise.The only problem with C is that it teaches "bad habits" in the world of Object-oriented programming.Object-oriented programming? Could you please explain what you mean.Object-oriented programming? Could you please explain what you mean.
  • #1
jbmiller
122
0
Hey everyone.

I recently decided which language I wanted to start programming with, C, and I also bought a book for guidance/referece. https://www.amazon.com/gp/product/0672326663/?tag=pfamazon01-20

I have never programmed before and after doing an extrenious amount of research I have concluded that C would be the best language to start with. Also that the book would be the best to have bought for a guidance/reference.

I was wondering if I had made the right choice on starting out with C and buying that book.

Thanks in advance!
 
Technology news on Phys.org
  • #2
The book looks okay from what amazon allows to skim through and C is definitely a good language to know. Note though, that when you're learning C, you will need to know more about the internal details than you would in, say Java. It can be a pain, unless you enjoy it.
 
  • #3
I'm not too worried wether or not its a pain. I've done a little with Python and I've found that I really enjoy programming.

Once I become really good with C what would I be capable of doing? As in how will it benefit me and what exactly is the point of doing it?
 
  • #4
You can do ANYTHING with C, and from my limited experience (I'm still at uni), learning C makes learning everything else easier. It's close to the metal, if you are processing a string you will know about every character in that sucker, you'll terminate it yourself and you'll manually allocate and free the memory it uses. I like to think you learn some good practises coding in C. Good luck!

If you get stuck for something interesting to code, look up Project Euler, or do some text processing (encryption, HTML parsing, compression). Graphics is fun too, but you'll need to learn some extra libraries for that (OpenGL or something).
 
  • #5
Adyssa said:
You can do ANYTHING with C, and from my limited experience (I'm still at uni), learning C makes learning everything else easier. It's close to the metal, if you are processing a string you will know about every character in that sucker, you'll terminate it yourself and you'll manually allocate and free the memory it uses. I like to think you learn some good practises coding in C. Good luck!

If you get stuck for something interesting to code, look up Project Euler, or do some text processing (encryption, HTML parsing, compression). Graphics is fun too, but you'll need to learn some extra libraries for that (OpenGL or something).

Not quite everything unless you include inline assembler or link to libraries that have assembler routines like communicating with I/O directly.

It's close enough though for bare metal since only with the exception of device drivers, super-optimized routines for particular chipset types or extensions, it's good enough for the kind of micromanagement required for fast software and with a good compiler, nowadays the results are good enough performance-wise.
 
  • #6
The only problem with C is that it teaches "bad habits" in the world of Object-oriented programming.
 
  • #7
Object-oriented programming? Could you please explain what you mean.
 
  • #8
jbmiller said:
Object-oriented programming? Could you please explain what you mean.

Wait. Didn't you just say you had done a lot of research and concluded that C would be the best language to start with? I think, my friend, that your research might have been somewhat incomplete.

Also, Google is your friend.
 
  • #9
Depends on what you want to do.

C is closer to the metal, yadda yadda, but you lose some functionality and don't gain much over the equally fast but object oriented c++. Before anyone corrects me by saying c is more basic and therefore faster than c++, remember that c++ is so popular, and a lot of money and effort has gone into optimizing it, while c optimization has been pretty stagnant.

To answer your question about object oriented programming, or OOP, first of all c is procedural i guess, and c++ is OOP. In C++ you can create a class, say a triangle class, and create different instances of triangle. These are all part of the triangle class, but operations on triangle_1 don't effect triangle_2 don't effect... The class also defines methods or operations you can do on the triangles, like if you wanted to stretch triangle_4, or access what the base of triangle_6 is or whatever. You're modifiyng and accessing "instance variables" of the different "instances" of the "class". Each triangle is an instance of the triangle class.

Basically OOP creates a more pretty way to keep track of many "objects", and their separate instance variables. Otherwise you might have to do some ugly multidimmensional arrays or something, but those have there purpose, don't get me wrong.

Most video games are written in c++ btw.

If I'm trying to throw together a quick program, python is still great for simple scripts, to even modeling, and it's really easy.

If I was writing an intense physics engine with 3d visualization, I'd pick c++.

If I was writing code for a microcontroller, I'd probably use C.
 
  • #10
All that said, you can do anything with C :) It's just a matter (how long it takes to program) vs (how important is performance) for a task by task basis. You can't go wrong with learning C
 
  • #11
LorenzAtrctr said:
C is procedural i guess, and C++ is OOP.
C++ is an extension of C. Object oriented programs have been written in C, and procedural programs in C++. Even in the case of OOP, member functions of an object end up being procedural, so the innermost code of most well designed programs doesn't end up that much different.

jbmiller said:
Once I become really good with C what would I be capable of doing? As in how will it benefit me and what exactly is the point of doing it?
Unless you plan to be a programmer, or your studies or a future job involves programming, I'm not sure what the point is, but the same applies to a lot of subjects you learn in school, some of which are more for academic purposes as opposed to having a practical purpose.

You didn't mention what your plans are that might involve programming.

jbmiller said:
Did I make the right choice?
There's no reason that C can't be the first programming language you learn. If your studies or a future job involves programming you should find out what language is being used and perhaps start with that language, or switching to that language after spending enough time with C to get an idea of how to write programs.
 
  • #12
rcgldr said:
Unless you plan to be a programmer, or your studies or a future job involves programming, I'm not sure what the point is, but the same applies to a lot of subjects you learn in school, some of which are more for academic purposes as opposed to having a practical purpose.

You didn't mention what your plans are that might involve programming.


This may sound a little far-fetched, but I've heard from a couple of peolpe that you can do something with physics equations that involves programming? I'm not completely sure, but I found myself to be interested in what they were telling me so I decided I would give it a shot. I'm really interested in physics and by the time I start my physics course next year I was hoping I would be pretty good at programming. I am studying physics this summer, so no rush. I just think that it would be really cool, and why not pursue my interest?
 
Last edited by a moderator:
  • #13
jbmiller said:
This may sound a little far-fetched, but I've heard from a couple of peolpe that you can do something with physics equations that involves programming?
For physics or engineering, you might find a very high level language like Matlab, which is more of a mathematical tool than a programming language, to be useful. There's no reason you couldn't learn both C and Matlab.
 
  • #14
Oh ok, thanks.

I've been so lost on deciding which language to learn first. Everyone tells me something different... I will probably learn C then Matlab.

Thanks for the help!
 
  • #15
Python has some nifty Matlab modules.
 
  • #16
jbmiller said:
I've been so lost on deciding which language to learn first. Everyone tells me something different... I will probably learn C then Matlab.

Since you mentioned you were in it mostly because it'd be useful in physics, I recommend staying away from C. Matlab is a good choice, but I would still recommend (as I do to practically all beginners) to learn Python. It's a real programming language (somewhat unlike Matlab), and it's powerful yet easy (unlike C, which requires you to do all the nasty memory allocations by hand).

This is not to say that you should never learn C or Matlab (you will most likely learn the latter in college anyway), but *starting* with Python is highly recommended.
 
  • #17
Hobin said:
Since you mentioned you were in it mostly because it'd be useful in physics, I recommend staying away from C. Matlab is a good choice, but I would still recommend (as I do to practically all beginners) to learn Python. It's a real programming language (somewhat unlike Matlab), and it's powerful yet easy (unlike C, which requires you to do all the nasty memory allocations by hand).

This is not to say that you should never learn C or Matlab (you will most likely learn the latter in college anyway), but *starting* with Python is highly recommended.

Too late, the book just arived. And I'm really interested in C, and I've done a little of Python. Would you reccomend learning C, then Python, then Matlab?
 
  • #18
jbmiller said:
Too late, the book just arived. And I'm really interested in C, and I've done a little of Python. Would you reccomend learning C, then Python, then Matlab?

No. I'd go for Python (which can easily be learned by using tutorials on the internet), then C (since you already bought the book), then Matlab (since Matlab is awesome).
 
  • #19
Hobin said:
No. I'd go for Python (which can easily be learned by using tutorials on the internet), then C (since you already bought the book), then Matlab (since Matlab is awesome).

Alright, how long do you think it would take me to learn Python and C pretty thoroughly if I spent about an hour aday 7 days a week?
 
  • #20
jbmiller said:
Alright, how long do you think it would take me to learn Python and C pretty thoroughly if I spent about an hour aday 7 days a week?

It depends on what you call thorough.

One thing that you should keep in mind is that a lot of what is learned in programming has to do with debugging code and this takes a long time to do when you start off. As you get better though, the time needed will decrease though, but you will be working with larger repositories which means the problems get more complicated.

I think you will need at least a few years minimum for this amount, probably a lot more. Again it depends on how thorough you want to be.

You could probably learn the actual language components a lot quicker, but if you want a thorough understanding you will have to apply your programming to a number of different situations and applications to reinforce it all.

Don't be discouraged though because you'll find that even if you have been doing stuff for a while (like say ten years), there is always stuff you don't know and that's a good thing IMO.
 
  • #21
chiro said:
You could probably learn the actual language components a lot quicker, but if you want a thorough understanding you will have to apply your programming to a number of different situations and applications to reinforce it all.

Don't be discouraged though because you'll find that even if you have been doing stuff for a while (like say ten years), there is always stuff you don't know and that's a good thing IMO.

Well I actually wouldn't learn it that thoroughly, I'm mainly starting programming so I can do certain things invloving mathematical/physics equations for my classes next year. They wouldn't be that complex, it's just high school physics and pre-calc. I'm a freshman so I was hoping I could start to learn a lot over this summer and get more advanced my next 3 years of high school.

As to which I understand one must use Matlab for that sort of thing, not for sure though. I really never planned on spending that much time with C, same with Python if I choose to learn it as my first language or even learn it at all. Then again I don't even really know what I could "do" with Python or C. If you could, could you please explain some of these things to me?

Thanks.
 
  • #22
jbmiller said:
Well I actually wouldn't learn it that thoroughly, I'm mainly starting programming so I can do certain things invloving mathematical/physics equations for my classes next year. They wouldn't be that complex, it's just high school physics and pre-calc. I'm a freshman so I was hoping I could start to learn a lot over this summer and get more advanced my next 3 years of high school.

As to which I understand one must use Matlab for that sort of thing, not for sure though. I really never planned on spending that much time with C, same with Python if I choose to learn it as my first language or even learn it at all. Then again I don't even really know what I could "do" with Python or C. If you could, could you please explain some of these things to me?

Thanks.

If its mainly computation for science/engineering/computational kinds of things like that then MATLAB would definitely be the platform that you should learn since you don't really have to worry about the stuff that takes away from what you need done.

This is what software developers have to do anyway since projects are so complex. Usually they get some kind of library and then they just call one or two routines to do something complex that they don't have to worry about.

I don't know about Python, but if you can include libraries and call outside DLL's then you can pretty much do anything in Python that you can do in C. The big difference is that it won't be as fast as it could potentially be in C and that you probably won't know how everything works in detail in Python.

It isn't a bad thing though especially if you starting out. Getting stuff running quickly is important and if that means using Python over C (especially when starting out), then OK that's what you need to do.

So with regard to what you can "do", it depends on a) the language features and the environment features, b) the libararies that come with python (and that other people make) and c) whether you can include custom DLL's (to do say Operating System things or functionality which is not included in the Python dev environment).

I think Python allows all three which means that you can pretty much do everything in Python that you can in C and with the speed of computers nowadays, unless you need really really optimized code for something then just use something like Python.
 
  • #23
Alright, thanks for the help!

One last thing, how long will it take me to learn the componets of C? I need to make a schedule of how to study C so I can move onto Matlab in optimized timing.
 
  • #24
jbmiller said:
Alright, thanks for the help!

One last thing, how long will it take me to learn the componets of C? I need to make a schedule of how to study C so I can move onto Matlab in optimized timing.

I have a couple of points for your question.

The first one is that C is a procedural language and has procedural constructs. The constructs for procedural languages include a standard flow-control which itself includes loops, branching, and function calls and it's own flow-control. Within function-calls you get concepts including recursion which is an important thing to use (and is used quite extensively).

The next common thing is state-control. The state-control concerns things like data operators and how data is both read in, transformed and written back somewhere. You have arithmetic (including addition, subtraction, multiplication, division and modulus) for integers as well as for floating point numbers of different precision (but you don't have modulus functions for floating point unless you want to define it yourself).

Apart from arithmetic operations, you have bitwise operations (AND,OR,XOR,NOT), shift and rotate operators (again bitwise) as well operators that deal with reading and writing memory. In C you won't have to tell the CPU this: you just declare variables in the right way and the compiler will sort out this kind of thing.

Branching also includes comparison operators that include bitwise, normal numeric comparison (like less than, greater than, equal to etc). Comparison bitwise operators are not the same as normal bitwise operators.

You also have to learn things to do with memory which includes allocating and deallocating memory, pointers, structs, and how things look in memory in terms of pointers. Things like MATLAB allow you to get away without having to know this kind of thing in a deep way.

Then along with all the above, you have specializations of these concepts as well as issues related to the syntax and its use in the C language. Syntax is something you will learn a lot more when you have to write code, and ultimately compile. There's no real shortcut for this: you write code, compile and see what happens.

This is a really short answer to your question, but I hope it will still be useful.
 
  • #25
It does, thanks for the help!
 
  • #26
I would just like to add that there is a possibility you will really like programming, and want to go on to developing stuff. Maybe you will one day want to model something related to your research, or develop tools.

C is a good choice for these types of things. First of all, C or C++ are high performance. You also have technologies like CUDA, and OpenCL, which allow you to tap into your video card to crunch numbers, which could be helpful if you want to model something. You can actually use these with python as well, but if your going for high performance, you might as well be using C.

For audio, most professional apps, or processing tools are written in c or c++. There are a lot of third party libraries for C or C++ to handle audio, and there are allot of people to ask questions to about that type of thing in the C or C++ community. This is more an Electrical Engineering thing than a Physics thing but.

Check out DSP.stackexchange.com.
 
  • #27
jreelawg said:
I would just like to add that there is a possibility you will really like programming, and want to go on to developing stuff. Maybe you will one day want to model something related to your research, or develop tools.

C is a good choice for these types of things. First of all, C or C++ are high performance. You also have technologies like CUDA, and OpenCL, which allow you to tap into your video card to crunch numbers, which could be helpful if you want to model something. You can actually use these with python as well, but if your going for high performance, you might as well be using C.

For audio, most professional apps, or processing tools are written in c or c++. There are a lot of third party libraries for C or C++ to handle audio, and there are allot of people to ask questions to about that type of thing in the C or C++ community. This is more an Electrical Engineering thing than a Physics thing but.

Check out DSP.stackexchange.com.

Oh ok, I will probably just start with C. No need for Python when C seems to be seemingly better.

Thanks for the help/website!
 
  • #28
I'm more of a C fan than a Python fan, but here's the other side of the story.

While C does have support for structs, it isn't object-oriented. It doesn't have support for, say, inheritance. Python does. Python also tends to be a little more intuitive, and C has no support for strings ("blocks" of text, if you will.), or rather, it does, but there's no data type you can use to store them. You have to declare an array of characters to hold what's effectively a string.
 
  • #29
jbmiller said:
Oh ok, I will probably just start with C. No need for Python when C seems to be seemingly better.

Thanks for the help/website!

Well I wouldn't say better, just different. My computer science teacher loves python, and uses it constantly. I've also browsed job listings at Nvidia, and noticed that for some of their job offers knowing python is a preference.

So it's definitely not a waste of time to learn python. Learning python, c/c++ and MATLAB would be a good combination. But if your only going to learn one language I would choose c or c++.
 

1. How do I know if I made the right choice?

It can be difficult to determine if you made the right choice as it depends on individual circumstances and perspectives. It may help to reflect on your values and priorities, seek advice from trusted individuals, and consider potential outcomes of your decision.

2. What if I regret my decision later on?

It is natural to have doubts and regrets about decisions, but it is important to remember that all choices come with consequences and it is impossible to predict the future. Instead of dwelling on regrets, focus on learning from the experience and moving forward.

3. Should I base my decision on logic or emotions?

Both logic and emotions can play a role in decision-making. It is important to consider both aspects and find a balance between them. Logic can provide a rational and objective perspective, while emotions can reflect your personal values and desires.

4. How can I make a decision without any regrets?

Making a decision without any regrets is not always possible. However, you can increase the chances of feeling satisfied with your choice by gathering information, considering potential outcomes, and listening to your intuition. It is also important to accept that some level of uncertainty and regret may be a natural part of the decision-making process.

5. Can I change my decision if I realize it was wrong?

In most cases, it is possible to change your decision if you realize it was wrong. However, this may come with consequences and require additional effort. It is important to carefully consider the potential implications before changing your decision and to communicate openly with those who may be affected by the change.

Similar threads

  • Programming and Computer Science
12
Replies
397
Views
13K
  • Programming and Computer Science
Replies
15
Views
1K
  • Programming and Computer Science
2
Replies
69
Views
4K
  • Programming and Computer Science
Replies
16
Views
2K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
7
Views
659
  • Programming and Computer Science
Replies
11
Views
1K
  • Programming and Computer Science
Replies
9
Views
1K
  • Programming and Computer Science
Replies
10
Views
2K
  • Programming and Computer Science
Replies
1
Views
890
Back
Top