Why is C always recommended on Jow Forums over other languages? I'm going to take Data Structures in a few weeks...

Why is C always recommended on Jow Forums over other languages? I'm going to take Data Structures in a few weeks, and I'm really considering running through the entire C programming book. Apparently it would be the best way to go to do really well in that class, but is that really the case? What are other benefits to learn C? Just for reference, the data structures class is in C++ which I'm not great at in all honesty. Is it true that to really "learn" programming, C is the best language for it? Because I don't see how what you learn in C transfers over to OOP

Attached: C-Programming.png (430x310, 22K)

Other urls found in this thread:

github.com/jameswalmsley/FreeRTOS/blob/master/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c
twitter.com/AnonBabble

It's a fun way to learn data structures since you have to constantly implement them yourself.

Everything in C89 (normally C99) has a purpose that is rarely duplicated, and it gives you a perfect level of control, just above assembly, but allowing you to create nice abstractions that don't end up a mess as fast as paradigms like OO.

OOP is just one paradigm. There are many ways to go about solving real world problems, and some may be more appropriate than others. What C does give you is insight into how the machine actually works, and it is valuable to understand this before you advance further. You might even be able to appreciate some things, such as how OOP doesn't come free and there are real performance costs associated with it (but perhaps that's fine for you if your main focus is just getting something out the door).

Keep learning, and don't focus too much yet on "when will I use this in the real world". If you're lucky, you'll have a good job where you can use everything at some point.

It's like learning the basics. C will require you to implement core data structures and algorithms rather than using someone else's library, which helps you understand them better. C will require you to manage memory, which will teach you about using it wisely and avoiding memory leaks, rather than relying on automatic garbage collection.

You don't have to program in C by any means, but if you're "into" programming, algorithms, etc. then you should probably learn it. It's like how /o/ will always recommend you drive manual and learn to work on your own car. You can drive without any of this, but if you're "into" cars then you probably want to understand how things work.

Not op or anything but I feel like I have some mental barrier going on with my understanding of this because I'm reading what you're saying and I know what all the words mean but I feel like a mouth breathing retard.
/blog

OP here, so basically C is the absolute best way to really learn data structures and algorithms? The main question I have is, once I do learn C and am able to write more complicated and bigger programs, will these skills transfer over to other languages?

OP here again, what complier should I use for C?

Don't be that kid who tries to use C when their class is based on C++. It's an extremely faggoty thing to do and you will fail.

C is great, but use it when it applies.

I definitely don't plan to do that. I really just want to "learn" data structures so that I have a leg up in the class, but really I want to stop being shit at programming in general too

If your class is using C++, just use C++.

The advantage of using C or C++ (either really) for data structures and algorithms is to force yourself to manage memory, pointers, etc. which reinforces the concepts in those classes (esp. data structures).

Is there an advantage to learning both? It seems like I could get through the C book a lot faster than my C++ book, but I don't want to waste time doing both since I only have three weeks

I'm using C# in class. Should I learn C or C++ to get a more thorough understanding?

You should drop the fuck out if you're using C# in your intro classes, as your school is terrible

I live in a small city. There's nowhere else to study.

Are they at least making you take a bunch of math courses? If not you're getting royally fucked

Nope. What should I learn in my own time to make up for it?

>your school is terrible if it teaches C# in intro courses
Lots of good schools like Princeton and Stanford teach Java to first years, which is very similar.

Not every school is Berkeley/Waterloo and teaches FP to first year students.

It forces you to learn how shit works on a lower level than most langs, also it is supported by literally any platform you could possibly be using, whether it be a tiny microcontroller or your desktop computer.

C is not 'close to metal', it does not give direct access to hardware. C is a legacy language from when there was not enough memory on computers to do garbage collection and so it had to be done manually. C is a good teaching language because its simple and it demonstrates what unrestrained pointers and container types can do. Its a good lesson on what a bad programming language is.

It gives you direct memory access. given that most processors implement hardware access through memory mapping, you do get access to most of the hardware features through pure C.
There are some exceptions that need to be handled through asm, but that's why inline assembly support exists in C compilers

>It gives you direct memory access.
it doesnt, if you honestly think that any C syntax gets directly translated to hardware locations youre in idiot, neither the CPU nor the OS will allow that, plus the code gets optimized to where instructions get thrown away and re

>given that most processors implement hardware access through memory mapping
they dont unless your still playing with PIC microcontrollers

>you do get access to most of the hardware features through pure C.
youre an idiot, you get access to zero hardware with C

>There are some exceptions that need to be handled through asm, but that's why inline assembly support exists in C compilers
nobody uses inline asm in C anymore, that was only done back in the days when C compilers spit out assembly code. If you put any assembly into C it is totally opaque to the C compiler and will most likely clash with the C machine code in anything mildly complex

>neither the CPU nor the OS will allow that,
Stopped reading here. If you think C can only be used in x86 and hosted environments, you are an idiot and don't know enough C to be spouting nonsense about C.
You can access any memory location like *(int *) 0x76a9087e0 = 12;

C is a good language, but people who swear by it religiously are idiots.

>You can access any memory location like *(int *) 0x76a9087e0 = 12;
youre a total fucking idiot to think that any compiled language will give you direct access to any memory. Sure ALL programming languages end up pointing to some hardware memory, but the memory itself is segmented and arbitrarilyl mapped by the compiler and in some cases the CPU and totally out of your control

I'm a noob that's reading along. Does that mean C doesn't have much benefit except for less bloat when developing things like desktop applications?

less bloat doenst mean much anything anymore. It meant a lot when computers had 4k of memory. There is really no good reason to be using C

No. YOU are the fucking idiot who doesn't know how computers work. You are trying to apply your basic knowledge of programming in userspace protected-mode to every other environment exists.
How the fuck do you think kernel software is written?

Just read the tour book after K&R
C++ is notorious for being massive though

There is a reason that a certain amount of code in an operating system like Linux has to be done in assembly. But with all the C code that gets generated there is no control on where the data machine instructions will end up. Compilers have to be highly optimized for something like an operating system, the idea that you could actually control where in hardware memory the code will effect in the code itself is silly

Nah mate. that's not how it works. If you don't believe me, just try it with your compiler. Ofcourse the OS won't let you to touch anywhere you don't have the access to. for that, you need to BE the OS. i.e. linux module
or just write some AVR code and see how something like *(int *) 0x76a9087e0 = 12; works

If you want to learn data structures don't use C. In fact avoid using C for any introductory stuff. If you what to learn data structures and algorithms focus on the data structures and algorithms. Learn the theory and thoughts behind it, the implementation comes second to that. That's why I do not recommend C, it forces you to focus on to many details that takes your mind away from the data structures themselves. You will spend to much time debugging some random pointer you forgot to put a & or * in front of. If you want to learn C (and you should), do it later.

Avoid C, focus on the ideas, less about implementation. So use a langue that lets you focus on the important stuff and takes care of the tedious details.

>OP here, so basically C is the absolute best way to really learn data structures and algorithms?
No
>The main question I have is, once I do learn C and am able to write more complicated and bigger programs, will these skills transfer over to other languages?
Somewhat, not that much. Will give you better insight. It won't help you get that much better at writing code in other languages.
You will know the benefits of using C compares to using something else. C has more control, and good speed. But these days something like Java is just as fast, but you lack the memory control, which can be crucial.

I'm entertained by how you're so condescending when there's an entire industry taking advantage of something you say C can't do (embedded).
Optimization is routinely disabled and we make the hardware related things volatile if we enable it.
Most of the stuff I've worked with for the last 13 years has been bare metal with no OS to contend with.
No inline asm anymore? Ha! Tell that to the aerospace guys.
And I haven't ever used a PIC in my work.

>or just write some AVR code and see how something like *(int *) 0x76a9087e0 = 12; works
please show me an example anywhere of someone directly assigning a value to a hardware address, I'd honestly like to see it. You seem to have an extremely simplistic idea that all data in a program is sequencially laid out like an array is actually a sequence of hardware bytes. All you have to do is open any program binary in a hex editor and you will see that any high level language creates code that is there simply for how the binary standard it uses formats data, which means a lot of data is just part of the binary format itself and has nothing at all do with actual data memory

learn haskell

Because C provides you with understanding of basics like no other language can while still being easy to learn..
When people say "Learn C" they don't mean that you should master it, they mean 2 months and then move to language that you now should understand that you need.

>please show me an example anywhere of someone directly assigning a value to a hardware address, I'd honestly like to see it.
I am another guy, but I did that in my OS class. You can directly access the hardware with C, though not if you are running you C program on top of a modern OS.

>You can directly access the hardware with C
All programming languages directly access hardware memory, even in Python and Perl the data has to be stored somewhere in memory and so you could say you are accessing hardware memory with those languages. What I am saying you cant do is pick a random address in hardware memory and assign a value to it in C. You cant even do that in assembly as the assembler will randomize memory locations. The only way you can do it is to write out each machine instruction on your own in hex

Serious question: do you know what a datasheet is? There are very specific addresses to access specific types of hardware pins. If I want to turn on an LED, it can't go to any random place.

It's really not my job to educate a faggot like you. but ok.
Let's take a look at FreeRTOS implementation. shall we?

github.com/jameswalmsley/FreeRTOS/blob/master/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c
Line 124 defines a macro to a memory location:
#define portNVIC_SYSTICK_CURRENT_VALUE_REG ( * ( ( volatile uint32_t * ) 0xe000e018 ) )


line 581 accesses that memory location through macro:
portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;


Now fuck off.

Just use C++

most of Data structures is basically making the predefined classes you use in C++ already. Shit like making the class/functions for dynamic arrays, stacks, queues, creating your own malloc, making binary search trees, heaps, hash tables, etc. Most these functions are short, they just take a bit of understanding. Drawing out each step is the best way to understand imo. C isn't really going to help, just be comfortable with pointers and classes and the course isn't bad.

If you plan on taking operating systems course then a strong knowledge of C is pretty vital.

Yes I know, when you do embedded programming directly on hardware with a microcontroller you have to access specific areas of hardware memory. But were talking about a microcontroller, the assembler or C compiler is specifically designed to give you specific control of those areas in memory, keep in mind this is CPU memory, not RAM

>line 581 accesses that memory location through macro:
>Now fuck off.
see above dumbass

>What I am saying you cant do is pick a random address in hardware memory and assign a value to it in C. You cant even do that in assembly as the assembler will randomize memory locations.
Yes you can, I have literally done it. Write your own OS (or just a simple bootloader to set that it works) and you will see that it can be done.
If you have no virtual memory implemented and no access restrictions, then this is trivial to do.

>oh I was just pretending to be retarded

>What I am saying you cant do is pick a random address in hardware memory and assign a value to it in C.
t. never used an OS that has no HAL

Attached: Ms-dos_logo.jpg (250x295, 15K)

Can you please explain what you mean by the first part of your post?

I'm having a hard time wrapping my head around any of what you said. You say C doesn't give you hardware access except when you're dealing with hardware? What do you mean by CPU and not RAM memory? What kind of memory do microcontrollers use? Do modern operating systems use paging and memory management to make better use of available hardware and therefore obfuscate actual physical locations for userspace programs?

You're making a good case user (not hard to do when you're right and the other guy is so blatantly wrong) but you can probably give up. He's just too retarded. Hopefully your effort wasn't wasted for the sake of others in this thread who actually want to learn, and don't think they know everything after one year of C in high school.

How come no one mentioned Rust yet?

The mozilla shills are still asleep.

graph theory, it can be applied to a lot of things in CS even though it doesn't look like it. Plus it's pretty easy
Complexity calculation too but don't go too far with all the statistics and shit

C has zero advantage over C++ if you want to learn algorithms and data structures. C++ and python are both good choices.

Bump

Because Jow Forums doesn't get shit done. It's good to learn sure, but don't use it for anything big.

t. implemented generic datastructures in C with macros before I realized this

>zero advantage
C is aids-free.

explain

C++ gives you std

Why would you bring up Rust in a thread about programming on the bare metal on a variety of different architectures with a language that's out of beta?

>Why is C always recommended on Jow Forums over other languages?
Because Jow Forums is populated by people who've never moved out of their parent's basement.

To be clear - you MUST be able to read and write C to be called a Programmer. However, 99% of programming jobs will be in a different, better language.

microcontrollers have specific areas of memory in hardware to handle certain I/O tasks. where that memory is depends on the complexity of the microcontroller, in ARM boards it would be dedicated parts of RAM

I'm learning C right now and I think it's helped me have a great grasp on what's happening when programming.

so python

But has it helped you learn data structures?

C is a great language if you'r goal is to stay unemployed and outdated.

We're talking strictly in terms of educational, not once has anyone talked about employment. In that case all C#, Java and HTML are the best languages in your world

ctrl + F "embedded"

At least someone is talking about it.

c ya later

Is there any reason to not use either C or Ada in embedded development?

last bump

C is like that knife that you take to the woods. And you build a hatchet with it then a loghouse. No need to pack a house in your backpack.

>Why is C always recommended on Jow Forums over other languages
Because C is simple and offers very few abstractions.

>Because I don't see how what you learn in C transfers over to OOP
You don't learn C to learn OOP. You learn it to learn programming in general, and systems programming in specific. In some aspects, it's a franca lingua, particularly when you need to talk about how things look in memory.

Use C++ instead

learn c++ templates you terd

Real men usse COBOL.

>old men use COBOL
fixed

top kek, mayybe python + numpy + pandas

I didn't read the rest of this thread, but I will just add my opinion anyways. C is unironically a pretty good language to use for a Data Structures and Algorithms class, because it helps to give you a reasonable understanding of what is actually happening at the hardware level that is often abstracted away in higher-level languages.
That said, C is an awful language to learn to program in for a beginner. It is also useless and counterproductive to use in about 85% of the daily, general-purpose programming performed by 85% of programmers.
Jow Forums constantly recommends it because autists feverently love it due to obessive control issues, and also contrarian trolling.

Because Jow Forums is a bunch of neet posers who have an autistic obsession with speed and memory footprint. Since they've never worked on a large project they don't understand the importance of readable and correct code and since they're unemployed they don't understand how much more valuable programmer time is than CPU cycles.

What do you consider as "beginner"? As in someone who knows zero programming? I do know "programming" in the sense of how classes and structures work and how to build programs, but I've never actually did anything interesting

>What do you consider as "beginner"? As in someone who knows zero programming?
Yes, basically. Someone who is learning their first programming language. C is pretty damn bad for that.

Why do you say that? I started with C++, but most of what I learned was actually C starting off. It makes programming a lot easier to understand.

I think it's probably the best programming language to learn as a beginner, because you want to actually understand computer science concepts, that get abstracted the higher level you go.

After C, you can move on to C++, or Java, or Python, but at least learn C to an intermediate level. Hell, you could make you own extensions for other languages with C if you wanted, that could be interesting.

What if I'm already trying to learn Python? Should I just start learning C++ once I reach an ''intermediate'' level, or go back to C?

Not in HolyC

What?

If you are absolutely new to writing code, then a language like Python will help you get used to writing it, and facilitate your readiness to learn Computer Science concepts.

If you want to be a programmer, you learn C. If you want to be a python developer, you learn Python. A programmer can easily learn Python, but a python developer will struggle learning C. Why? Because the programmer understands how programs work, a Python developer only understands how Python interprets your code to create a functioning program.

You should not touch C++ at all until you know C, because C++ is just C with enhancements.

Anyway, this is all subjective, just do what is fun to you, but if you are serious at being a good programmer, please understand how things work at the low-level.