I'm learning C

whm1974

Diamond Member
Jul 24, 2016
9,460
1,570
96
Hi, a hours ago I found this book on Wikibooks.org and read part of it and done the intro exercise.
https://en.wikibooks.org/wiki/C_Programming
Looks easier then I thought it would be for someone who only done BASIC and long forgotten how.

And just to think, I was going to get started with Forth...
 

Chaotic42

Lifer
Jun 15, 2001
33,929
1,097
126
The big hurdle will probably be pointers. Don't feel bad if you get confused by them at first. I took a C++ class and pointers just wiped out a good 25% of the students.
 

whm1974

Diamond Member
Jul 24, 2016
9,460
1,570
96
I did thought about FreeBASIC but then started thinking I would be better off learning a real programming language at the start.
 

urvile

Golden Member
Aug 3, 2017
1,575
474
96
I would go with a language that has C like syntax and garbage collection so you don't have to worry about memory management to start off with. Also C is pretty much dead now anyway.* I did both C and C++ at uni but we learnt the basics in java first. When we did C we used a putty terminal, VI, Make, GCC and no debugger. :)

What's your general level of proficiency?

*I should clarify that this depends on what sort of programming you want to do but for me it's a dead language. I can use pointers in C# if I have to.
 

sao123

Lifer
May 27, 2002
12,648
201
106
yes, I agree with Urville... why start with C? Go with C#, then learn C or C++ if necessary.
 

urvile

Golden Member
Aug 3, 2017
1,575
474
96
I'm a Linux user.

In that case learn C. :) Or Java would be another option.

That's an interesting way to describe a language that's consistently among the most widely used and sought after in the world.

It is dead to me. I have used neither C or C++ since university and never will. However I have used windows C\C++ APIs (mainly wincrypt) professionally but I can write C code using C#. One of the reasons C isn't really used any more is because of the security flaws inherent in the language design.

EDIT: That just reminded me when I worked for (a very large) defence contractor they removed the java runtime from their network. Their cyber security people considered it to be so much of a risk it was safer just to remove it entirely.
 

Chaotic42

Lifer
Jun 15, 2001
33,929
1,097
126
OP, what are you trying to accomplish? If you're just programming for fun, there's no wrong language - do whatever you think will be fun.
 

whm1974

Diamond Member
Jul 24, 2016
9,460
1,570
96
That's an interesting way to describe a language that's consistently among the most widely used and sought after in the world.
I'm going to say, really? Most of Linux and the BSDs are still written in C.
 

whm1974

Diamond Member
Jul 24, 2016
9,460
1,570
96
OP, what are you trying to accomplish? If you're just programming for fun, there's no wrong language - do whatever you think will be fun.
Beside the fact I always wanted to learn programming anyway, the main reason is I have Major Depression and I have been having episodes off and on all year. Lately I am having trouble staying out of bed.

So I'm hoping putting some effort into doing something worthwhile will help bring me out of this.
 
  • Like
Reactions: Thebobo

Chaotic42

Lifer
Jun 15, 2001
33,929
1,097
126
Beside the fact I always wanted to learn programming anyway, the main reason is I have Major Depression and I have been having episodes off and on all year. Lately I am having trouble staying out of bed.

So I'm hoping putting some effort into doing something worthwhile will help bring me out of this.

If you have a GPU, check out CUDA/OpenCL programming. You can do some neat stuff once you get comfortable with C. If you like math, check out Project Euler: https://projecteuler.net/archives
 

urvile

Golden Member
Aug 3, 2017
1,575
474
96
I'm going to say, really? Most of Linux and the BSDs are still written in C.

And windows and apple OS. :) There is a lot of C code out there. There are a lot of kernels, services/daemons etc. Implemented in C. It's also one of the reasons OS's are so full of security holes. :)

Anyway I digress. You should definitely learn C if you are a Linux guy and have a look at Java as well. C is a much steeper learning curve than a garbage collected language. One thing you should learn is how not to overflow fixed length strings/buffers/arrays. ;)
 

BFG10K

Lifer
Aug 14, 2000
22,709
2,971
126
C is a simple (in terms of language features) and elegant language. What’s even more remarkable is that it hasn’t really changed much in 40 years, yet it continues to dominate language usage statistics.

Pretty much every operating system kernel and kernel mode device driver is written in C. Whatever you’re reading this on, it's almost certain some part of that chain was written in C. Also any language worth a damn can speak the C ABI.

One simply cannot understate how important this language has been. What the transistor did for hardware, C did for software.
 

whm1974

Diamond Member
Jul 24, 2016
9,460
1,570
96
C is a simple (in terms of language features) and elegant language. What’s even more remarkable is that it hasn’t really changed much in 40 years, yet it continues to dominate language usage statistics.

Pretty much every operating system kernel and kernel mode device driver is written in C. Whatever you’re reading this on, it's almost certain some part of that chain was written in C. Also any language worth a damn can speak the C ABI.

One simply cannot understate how important this language has been. What the transistor did for hardware, C did for software.
Actually I wish I gotten started back when I was using BeOS since that was bundled with the MetroWorks C++ IDE and the whole thing was built using the GNU toolchain.

Or Failing that, started learning C after I switched to Linux back in the early 2000's since everything I was reading at the time kept pointing out that every Linux distro comes bundled with all the tools needed and then some.
 

Gryz

Golden Member
Aug 28, 2010
1,551
203
106
That's an interesting way to describe a language that's consistently among the most widely used and sought after in the world.
Thanks for the heads-up. For a moment I thought I was a Zombie.
 

Gryz

Golden Member
Aug 28, 2010
1,551
203
106
It is dead to me. I have used neither C or C++ since university and never will.
Me and my few hunderd colleague programmers write in C.
If we go for anecdotal evidence, we win !

One of the reasons C isn't really used any more is because of the security flaws inherent in the language design.
There are tools to help with that.
C doesn't have very strong string-handling. Noob programmers will use gets() (which doesn't check the length of the input string. It's easy to get buffer overflows that way). But if the tools-guy(s) on a project set up the environment properly, and programmers are a bit disciplined, there is not much more to worry about than when you program in Java. In fact, I'd say Java is a bigger security risk than C.

The reason C is used less and less is because the benefits of C (control, performance, manage your own memory) aren't necessary for most of the simpler applications. And websites are built in other languages too. But when you need the benefits of C, C is still very popular. Operating Systems, embedded code, Networking Operating Systems, games, etc. Everything on the Internet that is critical is written in C (and some of it in C++).

BTW, OP, if you want to learn another language, and C is a bit too hardcore for you, you should look at Python. Python is a very populair language these days. Used in many environments. Has lots of libraries. And is easier to learn than C.
 
  • Like
Reactions: Ken g6

whm1974

Diamond Member
Jul 24, 2016
9,460
1,570
96
Me and my few hunderd colleague programmers write in C.
If we go for anecdotal evidence, we win !


There are tools to help with that.
C doesn't have very strong string-handling. Noob programmers will use gets() (which doesn't check the length of the input string. It's easy to get buffer overflows that way). But if the tools-guy(s) on a project set up the environment properly, and programmers are a bit disciplined, there is not much more to worry about than when you program in Java. In fact, I'd say Java is a bigger security risk than C.

The reason C is used less and less is because the benefits of C (control, performance, manage your own memory) aren't necessary for most of the simpler applications. And websites are built in other languages too. But when you need the benefits of C, C is still very popular. Operating Systems, embedded code, Networking Operating Systems, games, etc. Everything on the Internet that is critical is written in C (and some of it in C++).

BTW, OP, if you want to learn another language, and C is a bit too hardcore for you, you should look at Python. Python is a very populair language these days. Used in many environments. Has lots of libraries. And is easier to learn than C.
Thanks for the tip. However the main reason I'm waiting to learn C and later C++ is that I want to do Linux application development or at least be able to build and install software from source files so I can bring software over to Manjaro that I need or want that doesn't already have.

I also want learn C/C++ first because it is harder and I want to get the hard stuff out of the way.
 

Cogman

Lifer
Sep 19, 2000
10,277
125
106
Maybe consider rust? It is low level like C, requires pretty much the same level of knowledge, and yet it also forces you to do the right thing through compile time checks. I would say if you learn rust you learn C and more importantly, you learn what good C and C++ will look like.
 
  • Like
Reactions: Mike64

urvile

Golden Member
Aug 3, 2017
1,575
474
96
Me and my few hunderd colleague programmers write in C.
If we go for anecdotal evidence, we win !


There are tools to help with that.
C doesn't have very strong string-handling. Noob programmers will use gets() (which doesn't check the length of the input string. It's easy to get buffer overflows that way). But if the tools-guy(s) on a project set up the environment properly, and programmers are a bit disciplined, there is not much more to worry about than when you program in Java. In fact, I'd say Java is a bigger security risk than C.

The reason C is used less and less is because the benefits of C (control, performance, manage your own memory) aren't necessary for most of the simpler applications. And websites are built in other languages too. But when you need the benefits of C, C is still very popular. Operating Systems, embedded code, Networking Operating Systems, games, etc. Everything on the Internet that is critical is written in C (and some of it in C++).

BTW, OP, if you want to learn another language, and C is a bit too hardcore for you, you should look at Python. Python is a very populair language these days. Used in many environments. Has lots of libraries. And is easier to learn than C.

Yeah. I will admit perhaps a poor choice of words on my behalf. :) I do like C I had to write a device driver for a solid state compass (attached to a TI board) while I was at university. I had four hardware debug points and good times were had by all. In my version of reality it's better to eliminate risks and that can be one of reasons for not using C. Java (at least the runtime) is incredibly insecure as I mentioned above. .NET isn't though which is why it is deployed on secure networks and java is not. :) Flash isn't deployed on secure networks either both are considered to be gaping security holes.

This may scare people but a few years back the most common language used in enterprise was actually VB.NET :) with C# and Java rounding out the top 3.

EDIT: We had a RFID network and inside that network there was a node that could be moved around and calculate it's position in real time. We wanted to know what direction the node was facing as well so we got a solid state compass and attached it to the location node and I had to write a driver for it.

That was fun having to write the instruction out bit by bit to tell the compass to calculate what direction it was facing then wait a while. Then flip the direction of the pin and read the result (which was two bytes) bit by bit while keeping the clocks synchronised or I would lose the result.

We were doing it just before the device sent the packet with the location information so we just packed the compass data onto the end and modified the GUI on the receiving laptop so it could process the directional information as well. Good times.

Give me C# any day. :p
 
Last edited:

mv2devnull

Golden Member
Apr 13, 2010
1,498
144
106
... at least be able to build and install software from source files ...
That is more about the use of build tools that the sources have been prepared with.
The language of the sources ... C and C++ are common, but are not used in every software.

In ideal GNU world every software would install with:
Code:
./configure ; make ; make install
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
That's another nice thing about C and C++ -- there are decades worth of tutorials and sample code, and there are libraries out there to do anything you want.

I'm a Windows application developer and we use native C++ not C# at work. C# is quite popular though, especially for creating programs for internal use by corporations.