9 ms·
This is the eternal debate, but man, I wouldn’t start somebody off with a C programming course as #1. Especially if there’s a Python course coming up shorty any
by wrs 6y ago
This is the eternal debate, but man, I wouldn’t start somebody off with a C programming course as #1. Especially if there’s a Python course coming up shorty anyway. And then a C++ course to learn “OOP”, which is much easier to learn in Python. Ouch.
I suggest just starting with Python, learning C at some point because it’s universal, and never learning C++ without a specific reason.
- ArikBe 6y agoI think this depends on the student. I do not have a CS degree. I dabbled in Python, but the first programming course that I took was Harvard's CS50 MOOC. I really appreciated learning C because it taught me about the underlying system through concepts like memory management. I agree that Python is friendlier, but I feel like C trains a particular mindset. Python may be more suitable for those who want to get off the ground quickly.
- wrs 6y agoTotally agree you need to learn C before getting too far, but it can make intro programming more challenging than it needs to be. Since this is supposed to be an ML-targeted curriculum it seems like Python is a better start. However, as I said, it’s an eternal debate. At least we have choices!
- ant6n 6y agoyou learn Python to get the basics: what are variables, what are values, what is control flow, what are functions, what are modules, how does it fit together as code to perform tasks. Worrying about the memory and the underlying machine can come later. The biggest problem with Python as a beginning CS course is that it´s not a great language to learn about types (meaning it's more difficult to learn the cluster of related concepts expression, value, type, variable).
- ryandrake 6y agoI guess I have different thoughts about what the basics are. I would advocate to start with assembly, but I’m biased because I started with assembly. Things like what is memory? What is a register? What is the Program Counter? What (really) is the call stack and how does it work in memory? Fetch-decode-execute? Jumps, conditional branches, loops. Address modes. If you know these things, then you know how the computer actually works, and a lot of the mystery of C is behind you already. Then you can start introducing stuff that’s built on top of it all like types, if statements, pointers... build the building from foundation up, don’t start on the second floor and tell the student not to go downstairs yet.
- lostcolony 6y agoBottom up vs top down. A lot of people benefit from a top down approach, especially those who haven't already decided they want to heavily invest in the subject.
- esoterica 6y agoThat's not a good way to teach someone to code and there's a reason why absolutely no curriculum on the planet does it that way. If you're teaching someone how to operate a car you start by showing them which pedal is the gas and which is the brake, not by explaining to them how a differential works. The pedagogical basics and the lowest level system primitives are not the same thing.
- opportune 6y agoThe thing about languages like C is that they will teach students to do many things by rote that they aren’t equipped to understand until later. I’m talking about things like includes, using a compiler, << and other facets of basic I/O, defining a main function. Python allows students to hit the ground running much faster. Once they learn the very basics, then it can make sense to introduce something like C, but not require them to temporarily ignore magic incantations with the promise they’ll understand them later.
- znpy 6y agoit's really a big-endian vs little-endian matter, if you think about it. Starting with C means sitting down, thinking hard and taking the time to understand how the basic model of a computer works, along with all the issues and annoiances that come with it. Starting with python really means leaving out the details and just getting into programming and maybe one day you'll wonder ow stuff actually work underneat.
- rhapsodic 6y ago>Starting with C means sitting down, thinking hard and taking the time to understand how the basic model of a computer works, along with all the issues and annoiances that come with it. Then perhaps ASM would be an even better starting point?
- jcranmer 6y agoI TA'd an introductory computer architecture course (basically, start with a MOSFET transistor and end up with "here's how you write malloc/free"), which was students' first introduction to both assembly and C. That experience helps solidify that you really want to students' first experience with programming to be a high-level language. One of the problems with teaching is a phase-ordering problem: what order do you teach the concepts in? As GP notes, C starts you off with a lot of boilerplate that isn't going to become relevant until a month or two down the line. Concepts like functions, libraries, the insanity that is the C preprocessor are distractions when your first challenge is just getting people to understand the mental model of how a procedural program works (i.e., understanding what x = 5 really means!). On top of that, C imposes a mental burden of understanding the stack versus the heap and the relevant memory management concerns. And then you get into C's string handling... I suspect many of the people commenting here are in the class of people for whom programming was obvious and easy, and never struggled with any of the concepts. This class of people will do fine with any language being used to introduce the concepts, because they're not really learning the concepts. Where the language matters most is for those for whom programming is not obvious, and they need help identifying which parts of the material is more fundamental than others. Giving these people a language that is more forgiving of mistakes is going to go a longer way to democratizing CS education than insisting people start by learning how computers really work. That isn't to say that this isn't something that should be taught pretty early on: far from it, I think a computer architecture class should be the second or third class you take on the topic. Delaying the introduction of C until computer architecture means that you can use C as a vehicle to introduce all the other parts about computers that are important, such as 2's complement arithmetic, ASCII, what the stack and heap are, etc.
- MetalGuru 6y agoI wholeheartedly agree. But I think it’s just a matter of preference for top-down or bottom-up
- javchz 6y agoYeah, I think the same. If I started today, I would love to being with python or even Java/Kotlin as it's better to show the good things about OOP. C it's great to learn the barebones experience with memory, and as a lang that runs in everything. The modern use I could see for C++ it's usually too specific for a random learner. I would only recommended for people who like to work in game engines, simulations, networking, embedded systems or migration of legacy systems, and other edge cases. But for learning, I think it's better to learn with a modern lang, as you will be less distracted learning the quirks of vitange language, and use that time to learn in parallel a lot of concepts outside the lang, like algorithms, devops, soft skills with teams, prioritizing requirements, etc.
- harha 6y agoOut of curiosity, is there anything in particular that makes C++ preferable for simulations? I’ve been trying to get into the topic lately - for now I’ve stuck to python and Julia for the visualizations that are more familiar to me.
- HPsquared 6y agoPerformance, I'd assume. Simulations can take a lot of number-crunching.
- dgentile 6y agoC++ is really nice for low-level OOP, and compared with C it adds generics and classes. Compared to Python, C++ is lower-level and can have significant performance gains with a well written program. With regard to Julia, if you write your code in "the right way", it is also compiled and low-level.
- harha 6y agoMakes sense, I can see some benefits in having more control of what happens with the memory, rather than trying to fit the model I have in mind into the datatypes python. Found this post [0] fitting: > The best thing you can do when dealing with lower-level languages like C and C++ is understand that things like lists, strings, integers, floating point numbers, objects, etc. do not actually exist. They are simply abstractions. There are only the CPU and memory. [0]: https://news.ycombinator.com/item?id=8356400 https://news.ycombinator.com/item?id=8356400
- superbcarrot 6y agoI think the way Harvard's CS50 course approaches this is really good. It used to be entirely in C but in more recent years they start with C for the first few weeks and then move on to Python and expose you to a bunch of other tools as well.
- mekoka 6y agoUntil teachers understand that learning programming and learning a programming language can actually be done separately, the debate will go on. There's this mindset that by teaching c early on you expose students to a whole range of useful concepts. That may be true, but you also distract them with useless language idiosyncrasies that have nothing to do with programming, strictly speaking.
- deviantfero 6y agoI started with C, and if you don't dive to deep into it, you can get a pretty good concept of program structure, what a function is, what a pointer is and all sorts of concepts that extrapolate easily in other languages. I'm grateful to have learned on a strongly typed language first, the thing about students is that sometimes they're easily demotivated, my University switched to python after teaching C first, after learning python there were a lot of student complaints asking why C was so complicated and why did they need to have static typing, and it wasn't natural to them to think about compiling as a normal step in software development.
- griffinmb 6y agoYou probably know this, but correcting for anyone reading. C is generally considered statically but *weakly* typed.
- ghusbands 6y agoNo, it isn't. There isn't consensus on what weakly/strongly typed actually means, but C is strongly typed (with some unfortunate loopholes) by most definitions.
- warent 6y agoThis sounds like a survivorship bias. I'm willing to bet that if someone such as yourself (who is motivated to learn C) started with a weak/duck typed language, you would have maintained motivation, and later moved onto something like C, feeling grateful to be learning C. i.e. who you fundamentally are is not altered by the language you first start learning. Now take the reverse. If someone who is not motivated to learn C started out in Python, they're more likely to stay motivated, perhaps never learning strong typing. If you start them on C, they lose interest and the field loses a valuable addition. Not everybody has to learn C or static typing or pointers. It's okay for people to have a narrow programming/comp sci scope and still enjoy the field.
- ironman1478 6y agoWhy would they lose motivation with C? Its really not that difficult. At least not compared to something like haskell or even something like python at times (are dictionary comprehensions actually that easy from a syntax POV? What about how copying a dictionary isn't an element by element copy, but a reference/ptr copy?) Even with undefined behavior (which a newbie won't really have to care about at the beginning IMO) C is relatively simple from a flow and structural point of view. If you are saying you can do cooler things in python than C at the beginning, that's probably true, but its unclear how many people drop CS because the language they are using doesn't enable easily making cool things.
- unethical_ban 6y agoIt's the fundamental debate of "are you training to be a software engineer or a computer scientist?" SWE's can get away without understanding many underlying concepts if they are going to be writing "business code", that is, handling strings, ints and interacting with databases and APIs. Computer Scientists and those programming on embedded systems or designing systems/OS/theory themselves, need to delve into the math, algebra, and lower understandings of computers.
- chii 6y agoI think it's the other way around - computer scientists can get away without understanding the underlying hardware, and do their research based on a basic/abstract machine. Because they are doing research on computer science - how different algorithms can be improved or new data structures (or ML techniques etc). Software engineers are more likely to need to know the underlying machine and write code suitable for such - because they need to write working/production ready code. It's like applied science, vs pure research science.
- heleninboodler 6y agoI think C doesn't have to be the first language you learn but I do think it should come fairly early, because otherwise you don't have an appreciation for a lot of the things the computer is actually doing when you're writing your code. Try explaining the concept of "stack vs heap" to someone who's only done python programming, for example. My brother went through a coding bootcamp that focused on Python and JS and then he started to get into Golang on his own and one day he asked me what the point of pointers is. We ended down a rabbithole that kind of blew his mind. Stack vs heap, the structure of the call stack, manual memory management, etc.
- Koshkin 6y ago> Python The computer science classic of all time (by Knuth) uses an assembly language to teach analysis of algorithms. Using Python (or Scheme, for that matter, as is done in SICP) will only take you so far. C is a good middle ground.
- reustle 6y ago> will only take you so far Sure, and that distance is far enough for 95% of developers these days. If they feel the need to go even further, they could learn C at a later time. No need to scare possible developers away right off the bat.
- Koshkin 6y agoA programmer should not be scared by the (still) most popular programming language. What's there to be scared by, anyway? For learning, C is just like Algol, very straightforward. Well, there's pointers: very useful for linked lists and such.
- tpoacher 6y agoI always feel like people who suggest python over c as the de-facto thing to start with, are probably people who started with something like c over something like python themselves, but forget all about how all that experience and understanding helped them make sense of python in an instant, and thus consider the 'easy' language a no-brainer. To an absolute beginner, however, python is not only an incredibly complex system (except for extremely trivial things), but because it goes out of its way to hide its internals, it cripples users for years before they can figure out what's actually going on under the hood. I'm fully on the "start with c, move to python" camp. The lessons just need to not suck, which I concede may be easier to do with c ... but it should still be c.
- chii 6y ago> it cripples users for years before they can figure out what's actually going on under the hood. it doesn't - python hides the unimportant aspect of the computer; namely, it abstracts the memory allocation and resource process. You treat the computer, under python, as an abstract machine which has unlimited memory, and don't worry about its use. you focus on algorithmic understanding and fundamental data structures. Once you grasped the computer science fundamentals, then you tear open the box and learn the underlying impl. of a computer - such as memory allocation, and assembly, etc (ostensibly, by making your own operating system using C, and/or writing a compiler using C). you can replace python with haskell, which imho, does an even better job as a first language.
- Koshkin 6y ago> haskell Sure, sure - monads and all... I wonder if there is even a beginner programmer’s learning material that uses Haskell.
- jeffe 6y agoTo be fair, python has many robust features beyond gc. For example, dicts, which are bread and butter for python abstract away 1000s of lines of C, which leads to very confused students when they first see errors like 'unhashable type: list'. Encountering leaky abstractions always made me uncomfortable when I took my first classes, but for a very first class its still probably better than dealing with memory allocation in C depending on what one expects from an intro class.
- dgentile 6y agoI think starting with a language with static typing would be better. With Python or Javascript you still need to know how the types work otherwise you can run into unexpected "defined behavior". Something like Golang makes a fair compromise between C and Python: it is statically typed, compiled, and has a garbage collector.
- koolba 6y agoStart with assembly. And yes I’m absolutely serious. Not “real” assembly, a simplified one that operates directly on memory without registers.
- konjin 6y agoThat's C with pointers. Assembly without registers is absolutely pointless since the only thing that matters in any flavor of assembly is how to get data into registers when you need it and then remove it before you override it.
- koolba 6y agoThe point isn’t to learn assembly, it’s to learn that all programs are just a series of instructions, operating in order, transforming memory. The loading and storing of registers is an implementation detail that’s not relevant in this context. The advantage over C is having an even more limited instruction set and using descriptive names for each instruction.
- konjin 6y agoThey don't transform memory, they load memory into registers, transform the registers and (maybe) store the registers values back into the memory. The difference is profound and until you code in assembly you have no idea why (or that) string operations are so expensive.
- koolba 6y agoAgain, the point is not to have an real language for any efficient real world usage. The point is to have a simplified language that represents a series of commands operating on a bank of memory. Like this: SET 1 100 # Set memory[1] = 100 SET 2 500 # Set memory[2] = 500 ADD 3 1 2 # Set memory[3] = memory[1] + memory[2] It's easy to explain what each individual step is meant to do and you can build up to more complicated instructions. It allows children to see the persistent effects of running the program, mutating the state of the memory, eventually introducing the instruction counter itself as a state variable.