Ugh, while I 100% agree that learning C (or similar lower level language) should be a prereq for any programming job, the use of the K&R C book is idiomatic of what is wrong with C. To many people pick up that book and try to emulate what they read. I firmly believe that book will teach you every bad habit you should never use in actual practice. 30 years ago, many of those "tricks" made sense given the compilers and…
Why Learn to Program in C?
81–90 of 123 posts
Re: Why Learn to Program in C?
#82Earlier quoted context omitted.
I have no idea what you're talking about. Are you interested in finding such a book? Do you try to refute any of my points? If so, which one?
I am not refuting. I was actually asking if there are CS books written in Lisp. Almost any CS book I've seen relies on C, C++ or something along those lines. > Are you interested in finding such a book? Yes.
Off the top of my head, only Structure and Interpretation of Computer Programs. But that's... different.
And Paradigms of Artificial Intelligence Programming.
Re: Why Learn to Program in C?
#83Earlier quoted context omitted.
I have no idea what you're talking about. Are you interested in finding such a book? Do you try to refute any of my points? If so, which one?
I am not refuting. I was actually asking if there are CS books written in Lisp. Almost any CS book I've seen relies on C, C++ or something along those lines. > Are you interested in finding such a book? Yes.
Google it -- it's freely available on-line, along with a video lecture series.
It's different, in that it doesn't teach Scheme (Lisp). It teaches computation (aka CS).
Go from there.
Re: Why Learn to Program in C?
#84Ugh, while I 100% agree that learning C (or similar lower level language) should be a prereq for any programming job, the use of the K&R C book is idiomatic of what is wrong with C. To many people pick up that book and try to emulate what they read. I firmly believe that book will teach you every bad habit you should never use in actual practice. 30 years ago, many of those "tricks" made sense given the compilers and…
Not sure exactly what you mean by the "hardware support" part, unless it is machine instruction support of some kind for C syntax. (But I thought that a basic level of support for that was present in most processors - things like base + offset addressing mode, indirect addressing via the value in a register, etc.)
But:
a[i] is equivalent to star(a + i) in C. (The K&R book says so somewhere, in either the original or the ANSI C edition.)
And star(a + i) is equivalent to star(i + a), by commutativity (a mathematical property) which is equivalent to i[a]. [1]
So you can write any of the above 4 expressions equivalently. I verified it by writing and compiling such code after reading this in the K&R book years ago; still remember being surprised until I saw the logic made sense.
[1] Or at least, it was so, some years ago, not sure about in C99 and such.
I used "star" instead of the asterisk symbol in code above because the actual asterisk turned following text to italics - HN markup.
Re: Why Learn to Program in C?
#85C is an abstraction. Assembly is an abstraction. Even physical transistors are abstractions. You can go down the ladder as deep as you wish, there is no bottom. (Sure, you can delude yourself you that X is the fundamental level of Y... as long as you define Y properly.) In this grand scheme of things, C is not better than Python. I don't mean the we should avoid going deeper. I mean that each level of abstraction has…
Ha ha, good one. I don't even know what the ZF set theory is. Not putting down theory either in general or in this case, of course.
Re: Why Learn to Program in C?
#86I'm surprised that people have managed to get through a CS program without learning C (or, at least, C++)! It seems to me that programming should be taught simultaneously in Haskell (or Lisp?) and C. - C teaches you how computers work. - Haskell teaches you how programming logic works.
> - C teaches you how computers work. Except it doesn't. If any language "teaches you how computers work", its assembly. While a lot of the quirks of C's design compared to more "pure" structured programming languages (e.g., Pascal) reflect a desire to provide more direct access to common low-level features of systems of the time when C was introduced, it doesn't really teach you how computers work except insofar as…
Re: Why Learn to Program in C?
#87Earlier quoted context omitted.
What language would you suggest is friendlier, and less rife with gotchas? I find the rules of C fairly reasonable, at least on the surface.
In no particular order any of the following as an introductory language. Ruby -- puts "Hello World" Python -- print "Hello World" Lua -- print("Hello World") Personally I wish every programmer would eventually learn C. Getting down to that low level and really understanding how things work is important, but if it is the first language I think we would end up with a whole lot less programmers as many would give up ear…
Python is written in C
Lua is written in C
Re: Why Learn to Program in C?
#88Earlier quoted context omitted.
Yes, but interpreted is slow, and garbage collection causes pauses at essentially random times. These things are fine for one off sorts of problems where it doesn't matter much if it takes a little longer. If you are writing an application that is meant to be run thousands or millions of times, I start to wonder why people don't care more about these trade-offs (the answer is, of course, they do . . . if they are, fo…
The main language at Amazon is Java. Lots of Java code is being run millions and millions of times there. Java isn't as slow as you think it is.
How is this relevant to the idea that C is an important and relevant language?
Re: Why Learn to Program in C?
#89Earlier quoted context omitted.
In no particular order any of the following as an introductory language. Ruby -- puts "Hello World" Python -- print "Hello World" Lua -- print("Hello World") Personally I wish every programmer would eventually learn C. Getting down to that low level and really understanding how things work is important, but if it is the first language I think we would end up with a whole lot less programmers as many would give up ear…
Ruby is written in C Python is written in C Lua is written in C
Ruby has also been implemented in Java (JRuby), Ruby (Rubinius), .NET (IronRuby), JavaScript (Opal).
Python in Java (Jython) and .NET (IronPython)
Lua has been implemented in too many language for me to list them all here (C, C++, Lua, JavaScript, Erlang, OCaml, Go, etc...)
It seems C itself was initially bootstrapped from B which was bootstrapped from BCPL. If we were to follow this to it's logical conclusion I'm guessing we end up at some version of Assembly. Are you suggesting we should start budding programmers on Assembly?
Re: Why Learn to Program in C?
#90Earlier quoted context omitted.
Ruby is written in C Python is written in C Lua is written in C
I'm not sure how that is pertinent. Programming languages as a general rule are initially implemented in some other programming language and then potentially later bootstrapped with their own language. Ruby has also been implemented in Java (JRuby), Ruby (Rubinius), .NET (IronRuby), JavaScript (Opal). Python in Java (Jython) and .NET (IronPython) Lua has been implemented in too many language for me to list them all h…