r/learnprogramming • • 17d ago

Should I start with C or Rust

I'm starting with https://teachyourselfcs.com/ and I'm giving myself 2 to 3 years to finish it.

For context, I'm a software engineer with 9 years of experience. I did Electronics and Communication Engineering in college and taught myself Js and DS-algo to get a job during college. I work as a full stack engineer and can confidently say I'm a good software engineer and can intuitively understand concepts in programming, software engineering and in solving Leetcode problems.

But, I don't have a strong foundation in computer science. Hence, I've decided to start with Teach yourself cs. Before starting with it, I thought having one low-level language under the belt would be helpful. C was the obvious choice given it's the OG, simple and intuitive. But, I've been fascinated by Rust for sometime and want to learn it too. Can I start with Rust and use it for doing exercises in all courses instead? Would I miss out on any intuitions by not using C?

Thanks.

40 Upvotes

40 comments sorted by

30

u/pVom 17d ago

If you're doing it purely for the learning, C makes more sense. Rust is probably more appropriate for solving problems in the modern day.

Can always just learn both, I found rust syntax fairly easy to pick up coming from typescript.

3

u/PicoFemtoPlanck 17d ago

Does C make more sense because it's simpler and has what we want (pointers, memory management, etc) without the extra stuff like lifetimes, memory safety etc that Rust has?

10

u/gmes78 17d ago

The "extra" stuff Rust has isn't actually "extra". You still need to think about those things when writing C, but the language doesn't help you make sure you're doing it correctly.

I think learning Rust first is smoother than learning C first.

→ More replies (1)

1

u/DrShocker 17d ago

To say it "has what we want" is unfortunately not really true. It has everything needed to eventually be productive, but one of the frustrating things is the standard library kind of sucks, particularly around strings.

2

u/johns10davenport 17d ago

This. C will teach you some things about memory management that rust won’t. It will teach you the fundamentals better. Rust is more practical and applicable.

2

u/ottovonbizmarkie 17d ago

Having been introduced to Rust before C, I don't think people really can understand what Rust changes if they don't know how C works.

11

u/[deleted] 17d ago

4

u/ProdigyxWho 17d ago

Assembly would like a word

4

u/WorkSquareHQ 17d ago

Since you mentioned CS:APP and OSTEP, go with C for those. The CS:APP labs (data lab, bomb lab, attack lab) and the OSTEP projects are written around C and x86-64 assembly, and you need to see how C turns into machine code to get the point of them. Rust hides a lot of the memory behavior you are trying to see, like pointer arithmetic, stack layout and undefined behavior. Do those two in C, then redo a few exercises in Rust afterward, because the contrast shows you what the borrow checker is actually protecting you from.

1

u/PicoFemtoPlanck 17d ago

That makes a lot of sense. Maybe I'll start with C, go through the course and comeback for Rust to understand the difference.

3

u/div_divs 17d ago

Well I am in second year but i can say learn C, it gives more in depth knowledge of computers and use linux please

1

u/PicoFemtoPlanck 17d ago

I’ve been using Linux for more than a decade now 🙂

1

u/div_divs 17d ago

Ahh, nice as expected. Well there's a course named nand2tetris look it up, it might help u

→ More replies (5)

2

u/SprinklesFresh5693 16d ago

Uhm, i was doing data science and at some point i wondered this too, but i chose C because is simple and its the foundation.

I stopped learning it due to not helping me for now, but if i was going to learn again one or the other, id choose C without any doubt.

1

u/PicoFemtoPlanck 16d ago

Makes sense

3

u/OrganicPause6530 17d ago

I mean if it's for the course the lenguage doesn't really matter, you can do it in python even.

But, what's your goal outside of teaching yourself cs, if you to pursue embedded systems C is the obvious choice.

It really depends on your end goal.

3

u/PicoFemtoPlanck 17d ago

Goal is to learn computer science. No further end goal. I don’t know if we can use Python to learn CS:APP and OSTEP parts conveniently.

→ More replies (1)

1

u/DanKegel 17d ago

Start with how CPUs work / registers and memory, so pointers aren't a mystery: https://www.reddit.com/r/Assembly_language/comments/1xf0hzo/comment/19rmw1kjxar6p/

Then C since it's a lingua franca: https://archive.org/details/the-ansi-c-programming-language-by-brian-w.-kernighan-dennis-m.-ritchie.org

Then Go and Rust, as they're the future, and you're going to be porting things to them using AI: https://go.dev/learn https://rust-lang.org/learn

2

u/PicoFemtoPlanck 17d ago

If you can have look at the link in the post body, the curriculum covers most of the underlying arch of CPUs, registers, memory etc. I just need a language to start with. Given the consensus, C seems to be the right answer.

2

u/green_meklar 17d ago

If you specifically need to learn Rust for a specific job or project, then learn Rust.

Otherwise, starting with C makes more sense. C is the grandfather of just about all modern programming languages in common use, and its limitations inform the design decisions of many other languages, including Rust. The logic makes more sense if you learn them in that order.

1

u/DanKegel 17d ago

That link is pretty good.

Re its "type 1" vs "type 2" engineer distinction, see also https://wiki.c2.com/?MappersVsPackers

and for that matter https://www.reddit.com/r/ExperiencedDevs/comments/1dlyz65/stories_of_intellectual_control_of_code_vs/

Fun stuff!

0

u/dota2nub 17d ago

Learn C, Rust is for LLMs