9 ms·
I think that all comp sci students should begin by learning to become competent in C. Aside from having the widest support across platforms, and being syntactic
by ajg1977 17y ago
I think that all comp sci students should begin by learning to become competent in C. Aside from having the widest support across platforms, and being syntactically similar to many other languages, it's the closest you can get to understanding how computers work at a low level without dropping into asm. Frankly, knowing these things will make you a better programmer.
That said there is definitely a benefit to exposing students to higher level languages, both for productivity in solving more complex problems and understanding what the syntax and expressions of these languages have to offer. And by higher language I don't mean C++ :)
- ynniv 17y agoEveryone says that C is as close as you can get to how computers work, but I can't agree with this anymore. C stack management and function calling requires work that is not part of a CPU. malloc and free do not map to anything at the hardware level, these are OS calls. The closest C gets you to the "computer" is pointer arithmetic and manual memory management. If you want to teach someone how basic hardware works, start with an arduino and assembly. If you want to learn how to program modern applications, use a modern language (Java, C#, JavaScript, python, ruby). I think that people talk about C as an important language because it is difficult to write programs in. To these people it is a badge of honor to write clean, correct C code. Here's the rub: C absolutely sucks at networking, and concurrency, security and readability. Every year that goes by, C becomes less useful. How is this a good language to teach students? (Edit: BTW, This is the Computer Science curriculum, which is separate from Computer Engineering. Georgia Tech's CS curriculum had no mandatory hands on hardware classes.)
- ajg1977 17y ago>> C stack management and function calling requires work that is not part of a CPU Well in C you tend not to manage the stack. As for function calls, what exactly do you think a CPU spends its time doing? >> malloc and free do not map to anything at the hardware level, these are OS calls So memory is just some non-physical property of the OS? Erm... >> I think that people talk about C as an important language because it is difficult to write programs in. There is a learning curve, but it's hardly difficult. However I think I know the reason for your confusing statements above.
- aaronblohowiak 17y agoI'm afraid you misinterpreted the parent. The parent is saying that C's function calls and stack management are not implemented in hardware. That there is, in effect, a C 'runtime' that implemented these behaviors. Further, malloc and free are not hardware calls. The physical property would be literal ram addresses (not virtual memory, though there is now hardware virtual memory so i digress.)
- anc2020 17y ago> it's the closest you can get to understanding how computers work at a low level without dropping into asm. Though your points are pretty valid, the parent wasn't arguing that C was at the lowest level. Plus surely you can provide your own low level implementation of malloc and free for the platform and you'll still be programming C.
- deleted 17y ago[deleted]
- halo 17y agoI believe the choice of C isn't really about "how computers work" as much as "how algorithms work", with C only providing a minimal toolkit of architecture-independent efficient high-level functions that allow for a simple mental model of how algorithms in higher-level languages work underneath, which is extremely useful in the real-world for getting a good overview of algorithm efficiency. Another good reason is that C is useful as a sort of mid-level psuedocode. This pseudocode is useful for providing a mental model that allows you to make the leap from a modern high-level language to C to an assembly language much more easily than making the straight cognitive leap from a high-level language to the specifics of an assembly language or architecture.
- wcarss 17y agoI think that any programmer worth their weight must disagree with the larger message you're giving here. C does _not_ suck at networking, concurrency, security, or readability. Most code you write in a 'modern language' like Java, Python, or something similar, is implemented on a very low level in C. So those nice, clean, safe networking functions Python pulls out of nowhere are just well written C code being presented to the user through layers of abstractions. The same goes with modern type-safety and security (that 'proofed' kernel from a few days ago was Haskell mapped into C). From a readability standpoint, C represents a tradeoff. The core C API can be kept in its entirety in a programmer's mind. Starting from scratch, you are able to know (essentially) every language feature C has, how to use it, and what side-effects it could cause. Compare this to Java, Python, or even C++, and you get into a scary world that's just too big to keep in mental RAM all at once - but a lot closer to english and more compact. There was an article which came out a few days ago talking about how C has been and will continue to be the top choice for software over C++ _and_ assembly in embedded projects over the past 12-15 years. Given that embedded systems make up something like 98% of the computer market and the number of computers grow with each passing year, the argument should flow the opposite way: Every year that goes by, C becomes more useful. In addition, it's an ideal language for teaching the notion of pointers, the reasons for security, the value of good program structure, and yes, it's difficult. If you teach people to be comfortable dealing with C, they'll feel like Python is pie. (or.. py :P) All that said, I cannot disagree with the value of functional, object oriented, or other paradigms being taught to students. Many people do not really learn to deal with recursion until they've learned a dialect of Lisp. Many people do not really learn the power of design patterns and the object model until they've written something in a high level language that uses it (take your pick). The fact that these are good things to be exposed to and to use does not in any way diminish the importance or usefulness of C for both career programmers or computer scientists. tl;dr: "C is still good too homg"
- defunkt 17y agoI took classes on C in school. I never really "got it." I then re-learned C after learning Python (and other higher level languages). I found it much easier to learn on the second try. On the first try I was learning about syntax, functions, loops, variables, and types as well as memory management, header files, and pointers. On the second try I was only learning about memory management, header files, and pointers - I already knew about the other stuff. On top of that, pointers were much easier to grasp because I had experience with 'references' in higher level languages. It's great to learn C, but I always recommend people learn to program by way of something like Python or Ruby. It's hard to beat print "hello" when you're just starting out.
- Goladus 17y agoAn OS call is a lot closer to "the way computers work" than a call to a managed runtime environment on a virtual machine running on top of the OS.
- smithjchris 17y agoErr malloc, free, pthreads are all abstractions and are not black box generally. You can look in them and find out what the hell is going on if you need to. C is great at networking (sockets), concurrency (pthreads), security (brain) and readability (brain). If you know what you are doing. The same is true with any language. You can write shitty C# and JavaScript.
- krying_krab 17y agoOur intro to computing class involves learning about gates, an academic architecture (LC-3), programming in bytecode, programming in assembler, learning how we assemble the bytecode into assembler, then learning C. Our final project is a basic compiler from C to ASM given an AST. I think it's a great way to learn about the way a machine works in one semester :)
- applicative 17y agoThis sounds great, you learn how a machine could be programmable, and how existing programmable machines operate; but the question mostly under dispute here is whether C brings out the nature of 'programmability' -- i.e. whether it brings out very clearly the purpose that all these strata serve, namely general programmability. --And thus whether a C-only environment is missing something essential. Myself I would think it does, and that for example Lisp and Haskell and ML help bring this out more clearly, and so, in another way, do the happening scripting languages. Your experience with with assembler seems to me more important than experience with C -- though of course everyone has to learn C. In my own case, for what it's worth -- I wouldn't think everyone else would need this -- it's only when I saw that a properly assemble machine could compile Haskell that I really grew to respect the machine...