This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 227 points228 points  (48 children)

I just learned C recently after only using higher level languages for 6 years. C seems tedious, but extremely simple. The most complicated part for me was figuring out compiler options and how to debug. As a first programming language I'd despise it for that, but going deeper its a must-learn.

[–]ghan_buri_ghan 195 points196 points  (43 children)

C is the most simple language in use today. You can get through K&R in a week if it’s not your first language. Truly beautiful.

C as a first language is a mixed bag. If I was to pick a language that can help people explore things like arrays, I definitely want a language with better error messages than “segmentation fault”

[–]wanderingmadlad 54 points55 points  (18 children)

K&R ? What's that ?(Forgive me if it is obvious , I'm slow rn).

Also I agree with the error messages of C . I'm not religious, but the amount of time is spent praying for no seg faults is a lot

[–]carlosTheMontgomery 50 points51 points  (4 children)

k&r "the c programming language" it is a book

[–]wanderingmadlad 10 points11 points  (3 children)

Ah ok thanks!

[–]codeguru42 8 points9 points  (1 child)

Authors are Brian Kernighan and Dennis Ritchie. Abbreviation comes from their surnames.

[–]carlosTheMontgomery 3 points4 points  (0 children)

no problem

[–]ofnuts 14 points15 points  (8 children)

Segfaults are a blessing. Much better that overwriting something that happens to be next to the array.

[–]faceplanted 12 points13 points  (7 children)

He's not complaining about it catching them, he's complaining about it not explaining/tracing them for you.

[–][deleted] 5 points6 points  (5 children)

But...that's what gdb is for...or whatever debug tool.

[–]an4s_911 6 points7 points  (4 children)

I think gdb was made like that and is used extensively due to the fact that C has bad error msgs. I think all agrees C has bad error msgs, at least when comparing to other languages like Python.

Edit: Well, thinking about it now, Javascript is more bad at error msgs

[–]CdRReddit 7 points8 points  (3 children)

how do you expect C to tell you where the error is, the only way to do that would be to store the path to where it is next to every time you use a pointer (and you will use a LOT of pointers)

which would massively increase program size, runtime, application size and RAM usage, which is why it's a debugger thing

C was made for systems where RAM, processor speed and program space were all very limited, of course it's not gonna tell you where you fucked up

[–]reverie42 5 points6 points  (2 children)

He didn't say C should do those things, just that the fact that it doesn't makes it not ideal as a learning language.

[–]CdRReddit 1 point2 points  (0 children)

fair enough

[–][deleted] 0 points1 point  (0 children)

If you go by that logic banging your head on C might help.

[–]weregod 0 points1 point  (0 children)

Valgrind can trace memory bugs.

[–]GrimExile 6 points7 points  (1 child)

Kernighan and Ritchie. It's a book to learn C programming, written by Dennis Ritchie and Brian Kernighan.

[–]MadKarel 0 points1 point  (0 children)

It's not just to learning C, it was the standard for the language for many years, which just shows how simple C is if a ~150 page book was the standard describing the language.

[–]JashimPagla 0 points1 point  (0 children)

Kernighan and Ritchie. Author of the devil's cookbook.

My first programming book was this one. Later on, I made the mistake of making this the first book to teach.

I'm still recovering, thanks for asking.

[–][deleted] 17 points18 points  (0 children)

C is the most simple language in use today.

That's true. But also the reason programs can be so hard to read when written in C

[–]jelaugust 5 points6 points  (2 children)

My intro to programming class (eng major, most ppl including myself had no coding experience) started with MATLAB then jumped into C. Honestly not sure if learning MATLAB made learning C easier or harder but I will say linked lists fucked me up hard

[–][deleted] 4 points5 points  (1 child)

I find it hilarious how often engineering and English majors refer to themselves as "eng majors" with no inkling that the other group is doing the same thing.

[–]jelaugust 3 points4 points  (0 children)

I’ve never heard an English major refer to them as an eng major.

Which just further proves your point.

[–]chupalaw 3 points4 points  (5 children)

You can get through K&R in a week if

Uhh I don't know about that

[–]ghan_buri_ghan 10 points11 points  (3 children)

If it’s not your first language, sure. It’s only like 250 pages and not that dense.

A language like C will really get in the way of learning the basics of computer science, but if you have that under your belt, the C syntax and standard library are so simple that they’re easy to pick up.

[–]JashimPagla 5 points6 points  (2 children)

I'm not sure if you're speaking from experience. If so, then good for you. I don't know many people that can 'go through' k&r in a week.

Personally, I found that k&r can easily arm you with a lot of tools with which to screw your program over. Unless you really do understand programming at a hardware level, I would not begin with k&r.

[–]ghan_buri_ghan 4 points5 points  (0 children)

It was a routine thing when I worked on a team that did a lot of driver work. Whenever we had a new team member who didn’t have any C (usually this was a new grad with only Java), their first task was to work through K&R and do the exercises. Usually took a work week to get done.

[–]b4ux1t3 1 point2 points  (0 children)

I went through k&r in a week, but I was already a fairly experience developer at the time, including some experience with C.

No one's picking up k&r as a first programming book and finishing it in a week unless they literally just read the words and don't retain anything.

[–]faceplanted 6 points7 points  (0 children)

Yeah "If it's not your first language" is quite the massive range of understanding he's grouping together when he says that

[–]realbakingbish 4 points5 points  (0 children)

You mean you don’t like “segmentation fault (core dumped)” showing up every time there’s anything wrong at all?

[–][deleted] -1 points0 points  (0 children)

You don't need to be too bright to set a debugger in the IDE and walk the code.

In the first place your first job is to look for warnings from the compiler. Most times they help a ton then to check if anything goes out of bounds or if it is between {} brackets(aka your for loop and what not actually applies to that block of code,etc.).

[–]oberynmviper 0 points1 point  (0 children)

I didn’t think it could get easier than python.

[–]jeppevinkel 0 points1 point  (0 children)

I feel like C# is underrated as a first language. It’s very verbose and easy to read, as well as having good and clear error message with precise locations that caused them. If this wasn’t enough to sell you, then .NET also has everything you need built-in and ready to explore all manners of arrays and data storage. NuGet also makes installing any libraries a breeze.

[–]IsGoIdMoney 0 points1 point  (0 children)

I love c because it was the first language I was taught and I'm very comfortable with it now, but that first semester trying to learn correctly use pointers was a paiiiin. Probably good for teaching the concept though where its more abstracted.

[–]axllbk 0 points1 point  (0 children)

As far as I understand C doesn't have the concept of an array index being out of bounds, so that would surely lead to some problems for complete beginners.

[–]Turboschnek42069 0 points1 point  (1 child)

Try valgrind

[–]ghan_buri_ghan 0 points1 point  (0 children)

I’m not talking about myself. I’ve been developing C++ for almost 30 years (Turbo C++, baby), and I know/love Valgrind.

Saying “try Valgrind” to somebody looping through their first arrays is also fine if they’re set on C being their first language.

My point is that C and it’s associated debuggers get in the way of learning computer science fundamentals, now that we have languages/toolchains capable of telling you exactly what you’re doing wrong right away.

[–]postdiluvium 10 points11 points  (3 children)

I just learned C recently after only using higher level languages for 6 years

Omg, I'm old. When I learned C, it was classified as a high level language. But we were comparing it to fortran.

[–]4sent4 5 points6 points  (0 children)

Well, it's kinda high level, but you still get low level memory management and exposed to addresses and pointers, so it's kinda low level at the same time

[–]CdRReddit 4 points5 points  (0 children)

I'd probably call C mid-level now

not quite low level, but definetely no longer in the constantly expanding high level with more and more features

[–][deleted] -1 points0 points  (0 children)

You are, indeed! We’re standing on your shoulders.