Live data from Hacker News

Learn C, Then Learn Computer Science

qrohlf.com

111–120 of 134 posts

Re: Learn C, Then Learn Computer Science

#111
post #61

I would argue C is a difficult first language. It's even a difficult 2nd or 3rd language. I would start people off programming at a higher level of abstraction and once they can do that dive into how things work. You could start the other way but it may be too theoretical and discouraging. Pascal used to be the language of choice and IMO can still work well. Things got more complicated when we got all those competing…

C is an excellent 2nd language. The language itself is obtuse, but the underlying model is fairly simple. C++ is a horrible one. These days, probably nobody should learn C++ and should probably pick up Go instead. As a teenager, I picked up a book on C++ having already learned BASIC, Pascal, and MS-DOS but never got proficient in it. I should have picked C. The "++" lead me to believe that it was a better language th…

> I didn't have any real programmers around to tell me otherwise.

I am a real programmer, with almost 20 years experience.

I'll take C++ over C without thinking twice about it.

Re: Learn C, Then Learn Computer Science

#112
post #4

Lean C when you need to grok how memory works in computing. Learn Scheme to grok the science of computing. Learn BSD when you want to understand operating systems and the network stack. Grok engineering when you write a scheme->c translator running on BSD.

Could you elaborate more or give some references on the second and third part? I am done with the first. I seriously need some profound knowledge on second and third, which a lot of people like you talk about. I need to put a plan to get there too. Scheme to C looks fun though :-) . Where should I start first with?

Do yourself a service and write the Scheme compiler in Scheme itself, doing direct assembly code generation.

http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf

Also a nice way to learn about bootstraping compilers.

Generating code code for another OS without Scheme support is just a matter of having your compiler cross-compile to the other OS. Then use the fresh backed compiler to re-compile your compiler in the new OS.

Re: Learn C, Then Learn Computer Science

#114

Personally I take a different view: learn a high-level language, use it to study computer science, and if you feel like writing some low-level code go ahead and learn C (though even then, you could probably do better by bootstrapping a compiler for your favorite high-level language and adding some extensions for low-level operations). C is not the best or even a particularly good language to try to learn abstract CS…

The thing that makes C a good candidate is that it's a very very small language. Yes there are plenty of strange quirks that the experts need to deal with but you can come up with an elegant and compact implementation of every standard data structure. High level languages tend to favor one data structure over another. Starting with those languages can give students the "hammer syndrome" w.r.t. that structure.

> The thing that makes C a good candidate is that it's a very very small language.

Modula-2 and Oberon are also quite small.

Re: Learn C, Then Learn Computer Science

#115
post #97
post #61

I would argue C is a difficult first language. It's even a difficult 2nd or 3rd language. I would start people off programming at a higher level of abstraction and once they can do that dive into how things work. You could start the other way but it may be too theoretical and discouraging. Pascal used to be the language of choice and IMO can still work well. Things got more complicated when we got all those competing…

IMO, C in a unix context is an excellent first language. It is useful in many contexts to learn to look for all the compiler warnings available :). Once you find them I don't think it is particularly hard. I agree about assembler, although I think just learning system calls and C is a good start. "See MIPS Run" is a great way to learn assembler IMO. I first learned Pascal and was very relieved to move to C. I don't t…

> I first learned Pascal and was very relieved to move to C.

It looks like you learned standard Pascal, instead of the many dialects that were way better than C.

Re: Learn C, Then Learn Computer Science

#116
post #70
post #65

Earlier quoted context omitted.

And how did that work? I'm just trying to imagine those first year students staring at those segmentation faults or trying to decipher some other non-intuitive C behaviour (promotion rules, = vs. ==, pointer arithmetics, various implicit rules). Talk about being thrown into the deep end of the pool to swim... When a language like Pascal is taught as a first language students can focus on the mechanics of their algori…

Can you elaborate what you mean by "= vs. =="? Since you mention Pascal I'm guessing that you'd say ":=" and "=" would be better, but since the general model of math is different from procedural code, I'm not sure that's an uncontested truth. I learned Pascal in high school and ":=" was confusing to more people than "==", even among first time programmers.

I find this paper [1] very interesting and elaborates on this issue -- "From experience it appears that there are three major semantic hurdles which trip up novice imperative programmers. In order they are: assignment and sequence, recursion/iteration and concurrency".

[1] http://www.eis.mdx.ac.uk/research/PhDArea/saeed/paper1.pdf

Re: Learn C, Then Learn Computer Science

#117
post #23

Earlier quoted context omitted.

C++ and C are completely different beasts. C is an elegant clean small language with few distracting elements, making it very suitable for a teaching language. C++ is a grotesquerie more suitable for a carnival horror show than something you want to introduce to new programmers. Unfortunately at some point, teaching OOP became all the rage in schools, and so C++ is chosen instead. That's a mistake, Java or C# should…

"C++ is a grotesquerie more suitable for a carnival horror show than something you want to introduce to new programmers." In my experience TAing an undergrad course that used C++, almost all of the things that left students scratching their heads were things that are present in C. No garbage collector, no built-in way to determine array sizes at runtime, no way to determine if a pointer has already been deallocated,…

no requirement that non-void functions actually return a value on all control paths, etc. The worst thing C++ does is to amplify these problems (particularly that last one -- yes, I know, use -Wall, but someone who is just starting to use a language would not know that, and having to teach compiler flags is an even worse distraction from the subject matter of the course).

Use clang ?

  root@iwfvm02086 ~/temp/c_test # cat test.c
  #include 
  
  int a_func(int a_bool)
  {
   if( a_bool )
      {
        printf("Passed variable was true\n");
      }
    else
      {
        printf("Passed variable was false\n");
        return 0;
      }
  }

  int main()
  {
    int num = a_func(0);
    printf("In main : num = %d\n",num);
  }
  root@iwfvm02086 ~/temp/c_test # g++ test.c -o test
  root@iwfvm02086 ~/temp/c_test # ./test
  Passed variable was false
  In main : num = 0
  root@iwfvm02086 ~/temp/c_test # clang++ test.c -o test
  clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated
  test.c:14:1: warning: control may reach end of non-void function [-Wreturn-type]
  }
  ^
  1 warning generated.
  root@iwfvm02086 ~/temp/c_test # g++ --version
  g++ (GCC) 4.4.6 20110731 (Red Hat 4.4.6-3)
  Copyright (C) 2010 Free Software Foundation, Inc.
  This is free software; see the source for copying conditions.  There is NO
  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  root@iwfvm02086 ~/temp/c_test # clang++ --version
  clang version 2.8 (branches/release_28)
  Target: x86_64-redhat-linux-gnu
  Thread model: posix
Really, the fact that real-world C programmers have to pick a subset of the language and enforce various style standards and coding conventions speaks volumes about the suitability of C for beginners

I am confused; all languages used in real world need this. Can you elaborate which languages are used in real-world that does not require coding standards ?

No garbage collector, no built-in way to determine array sizes at runtime, no way to determine if a pointer has already been deallocated

These are also side-effects for having the advantages you have teaching C for a Computer Science and Engineering course. Once you understand the fetch-decode-execute model of how a computer essentially works, it is a simple step from there to C.

I agree that, higher level concepts like Algorithms, Neural Networks are better taught with a higher level language.

Re: Learn C, Then Learn Computer Science

#118
post #111

Earlier quoted context omitted.

C is an excellent 2nd language. The language itself is obtuse, but the underlying model is fairly simple. C++ is a horrible one. These days, probably nobody should learn C++ and should probably pick up Go instead. As a teenager, I picked up a book on C++ having already learned BASIC, Pascal, and MS-DOS but never got proficient in it. I should have picked C. The "++" lead me to believe that it was a better language th…

> I didn't have any real programmers around to tell me otherwise. I am a real programmer, with almost 20 years experience. I'll take C++ over C without thinking twice about it.

I can count twenty (now) too, and I still won't touch it. By the time I was a teenager with that C++ book, I'd already been programming, whenever I could find hardware, and reading about programming for five or so years. I was kinda obsessed.

Re: Learn C, Then Learn Computer Science

#119

Earlier quoted context omitted.

yes, and a significant portion of our famous scientists studied philosophy and then laid the foundations across multiple disciplines some of which many graduate students still don't understand even though they studied them. i know a whole bunch of people are going to argue pro specialization, but i think we need to rethink the way we teach. we've built efficient workhorse factories which we call universities, and som…

> yes, but the question is, do you need university to tell you that? Of course not, anyone can tell you that. But knowing who told you what you know, sometimes helps a third party evaluate your statements of knowledge :-)

i can't believe anyone actually learned this stuff in school. i can't believe there is any debate about it. all the truly good programmers/engineers/computer_scientists/whatever_the_fuck_you_want_to_call_us learn the vast majority of what we know on our own (even if some of us did go to school for it). We do so because of curiosity and determination to make ground-breaking stuff, which we intrinsically know comes from understanding every single damn thing about computers from the metal up to javascript. CS in schools, at least past required k-12 education, is for people not sure of what they want to do--so we should frame the conversation about how to make CS courses to hook them or something. To me it's just a lame topic. I mean it's a valid one, but the idea of passionate programmers from hacker news in any way, like, looking up to school as any sort of answer is just some bitch ass shit. If you're sure you want to be a developer, get to work son, and zone out on your computer. That's the appropriate stance. Stop looking to institutions for answers.

Re: Learn C, Then Learn Computer Science

#120
post #103

Earlier quoted context omitted.

C is an excellent 2nd language. The language itself is obtuse, but the underlying model is fairly simple. C++ is a horrible one. These days, probably nobody should learn C++ and should probably pick up Go instead. As a teenager, I picked up a book on C++ having already learned BASIC, Pascal, and MS-DOS but never got proficient in it. I should have picked C. The "++" lead me to believe that it was a better language th…

Go is not even close to being any kind of replacement for C++. Also, not all "real programmers" think that C is a better language than C++.

Go was very much designed with the intent of being a better C-replacement than C++[1]. As to whether it's an actual viable replacement or not, well, that really depends on how dependent you are on libraries.

Back when I was getting into 'serious' coding, anybody with experience in both C and C++, whether they liked one or the other better, could have told me enough to make me realize I was better off learning C first.

[1] http://www.drdobbs.com/open-source/interview-with-ken-thomps...

Post reply on HN