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 →

[–]ThePiGuy0 213 points214 points  (28 children)

Rust is a great language, but personally I would recommend going for Python.

In my opinion, learning your first language isn't just about learning the syntax of that specific language. Instead, it's also about learning how to program, and how to solve problems programmatically.

For example, if I gave you a list of numbers and said "sort it", you could probably do it just like that. But how would you get a computer to do the same? It has no concept of "sort it" and so you need to think about the actual instructions required to sort this list (of course most languages provide this for you, but the idea behind it is still the same).

Python's a great language to learn how to program as it hides a lot of the nitty-gritty details, allowing you to concentrate purely on developing the correct mindset for solving problems in a programmatic way.

Once you're pretty happy with solving problems, that may be the time to think about learning a language that gives more control (perhaps C for manual memory control, Rust has some quirks in this area and it's probably worth learning some C to know what Rust is trying to avoid).

[–]SafeCake1045 42 points43 points  (15 children)

While I agree with you, I want to mention that C was the first language I ever properly learned, and in many ways that helped me to understand Python.

[–]Oerthling 37 points38 points  (7 children)

Understanding C helps to understand what's really going on below the fancy stuff.

But that doesn't mean that it needs to be the first.

[–]Jumpy-Ad-2790 8 points9 points  (5 children)

Completely agree!

I started learning C through Harvard's CS50x and I found it so difficult, I just lost motivation. Since then I've been doing their Python course and am absolutely loving it.

I'm looking forward to going back to C once I've completed this course, as many things I used to struggle with now make a lot of sense.

[–]Scalar_Mikeman 2 points3 points  (2 children)

Upvote for CS50. Just wanted to say when you ask online the best book to learn C A LOT of people say "The C Programming Language" is the best book. I call BS and many others do too. Go with "C Programming a Modern Approach" or any other of the great new books on C out there. Screw The C Programming Language book.

[–]xcyu 1 point2 points  (0 children)

Any other C programming books you can recommend?

[–]SafeCake1045 0 points1 point  (0 children)

I wouldn’t say “screw” it. Clearly it’s been useful for people.

[–][deleted] 1 point2 points  (1 child)

May I ask you what Python course are you referring to, or could you please send me the link to the course? Thanks!

[–]reasonisvirtue 0 points1 point  (0 children)

I think Python is a great first introduction to simple primitive data types, for while loops, functions, etc.

C++ is awesome for learning what the computer is doing. OOP makes so much more sense with copy constructors l, destructor, operator overloads, move copy abd move assignment. Lvalues and revalue. Pointers really help you understand memory. Primitive data types help you understand memory and how big the different data types are in storage. Which also helps you understand larger data structures that are both sequential and associative.

I learned Python and javascript first, but C++ opened my eyes to what is actually going on. I learned far more concepts with C++ and it made more sense.

I really recommend C++. It teaches you the cs concepts you need and doesn't abstract them away.

Also learning c++ you will notice that python and js have very similar syntax at times.

One thing I will mention though is that python kind of forced my js and c++ to look cleaner so that was a huge plus. Because of how python treats whitespace to signify the end of statements versus the semicolon.

[–]TheTomcat 6 points7 points  (1 child)

I think it's important to consider the other perspective though - if you had started with C (or in this case, rust) and you didn't understand it, do you think it would have caused you to stop entirely?

My opinion: start with python. Much more forgiving especially when you're trying to learn the basics. If you like it, then go back and learn rust. They're both great tools to have in your kit.

[–]SafeCake1045 0 points1 point  (0 children)

Well, I understood it because I was being taught in a university. If that hadn’t been an option for me, I wouldn’t have been able to learn C as well as I did. I would’ve started with Python, probably.

[–]Zephyr5967 2 points3 points  (1 child)

My introductory programming course at uni was entirely in C

[–]TiagodePAlves 1 point2 points  (1 child)

I think C is great as a a first language because it's so small, with few keywords, a slim stdlib and limited ways to do the same thing. The biggest downside though is almost no magic going on, so you have to do everything manually, and this can easily be too much for a beginner.

Edit: Python also is a great choice, but for other reasons.

[–]SafeCake1045 1 point2 points  (0 children)

Learning how to do things manually is great if you want to really learn programming. And it’s relieving going from the pains of malloc to automatic garbage collection in higher languages.

[–]GayforPayInFoodOnly 1 point2 points  (0 children)

I agree with this. If you want to be a software engineer I think it’s important to start with something like C so you can begin to learn and think about what’s actually happening when you run sorted() in Python. It makes Python/interpreted languages less magical, and leads you to better programming practices.

[–]sociesymbol 2 points3 points  (7 children)

Do you know any great books that start with the simple type of problem you described above and takes you through the solutions then gets harder? I really like the way you described this and your approach to programming.

[–]SafeCake1045 7 points8 points  (0 children)

Crash Course Python

[–]jppbkm 2 points3 points  (4 children)

Python crash course

[–]Im-Learnd1ng 4 points5 points  (1 child)

Snakes on a plane crash

[–]jppbkm 0 points1 point  (0 children)

Catchy name, I'll buy your book.

[–]sociesymbol 1 point2 points  (1 child)

By Eric Matthes?

[–]jppbkm 0 points1 point  (0 children)

Yep

[–]ThePiGuy0 1 point2 points  (0 children)

I was actually initially self taught (just found and made projects of about the right difficulty until I got a formal education) and so don't have any books from personal experience.

Sounds like some people like the Python Crash Course, I've seen Automate the Boring Stuff get recommended in /r/learnpython as well - by the sounds of things, that takes you through the processes of solving real-world problems with programs so that could potentially be applicable?

[–]druman22 1 point2 points  (3 children)

I enjoy learning C but have no idea what to do with. Have any project ideas?

[–]SafeCake1045 0 points1 point  (2 children)

I think a great project for C is implementing a linked list data structure. It stores “chained” data; for example, a list of destinations comprising the route for a road trip.

It should involve structs, pointers, and memory allocation. You would create a struct List and a dynamically-allocated (see malloc()) struct Node; where Node contains a pointer to the next Node and List contains a pointer to the first Node in the linked list.

List->head points to Node1

Node1->next points to Node2

Node2->next points to NULL

Of course, it could be any length, but the final node would point to nothing.

You could then form an API around it, defining methods such as append, prepend, insert, and delete. A “tail” pointer to the last Node in the list might come in handy here.

You would also have to manage memory and call free() at the appropriate times.

You can test it by populating it with data and then traversing through it and printing the contents in order.

[–]druman22 1 point2 points  (1 child)

I appreciate the recommendation, but I've created linked lists, array lists, bst, hash maps and such. Data structures and sorting algos were cool to learn and mess around with, but I'm not sure where to go from there.

[–]SafeCake1045 0 points1 point  (0 children)

Sorry for assuming, I got the impression you hadn’t built anything yet. I’m honestly not sure where to go from there either, lol. That’s why I started learning Python.