News for hackers. Stuff that matters.
Re:C0, an Imperative Programming Language for Novice Compute... by thecompilr on Wednesday October 18, 2017 @11:30AM (#15499954)
C language is as simple as it gets. The only concept people struggle with is pointers, but even that is a very simple concept. Teaching something that is simpler than C to computer scientists will breed very poor engineers.
Re:C0, an Imperative Programming Language for Novice Compute... by flafla2 on Wednesday October 18, 2017 @11:44AM (#15500083)
I am currently a TA for 15-122 at Carnegie Mellon, the class that C0 was originally made for. I would argue that C0 does an excellent job at breeding good programmers because of the following features:

1. Contracts in C0 bake preconditions, post conditions, and loop invariants right into the language. Contracts are only checked when in "dynamic recompilation" mode (basically debug mode). This allows you to check the correctness of your code more easily (and, importantly, in an easily gradable way).

2. The language is designed in such a way to introduce C to programmers that are used to other higher level languages. In the C0 phase of the course we introduce students to fundamental concepts like memory allocation, code reasoning and contracts, binary representations of numbers, and unit testing. Next we transition to C1 (included in the C0 install) which introduces typedefs and other features of C. At this point we focus on introducing data structures. Finally we make the final transition to C, where we talk about undefined behavior, gcc, stack vs heap, etc.

I've taken this course myself, and I would argue that this measured approach to learning C is far superior to throwing students (most of whom have no low-level programming experience) straight into C.

Re:C0, an Imperative Programming Language for Novice Compute... by grayhatter on Wednesday October 18, 2017 @12:08PM (#15500330)
I've replied here https://news.ycombinator.com/item?id=15500321 I think I mean to reply to you.
Re:C0, an Imperative Programming Language for Novice Compute... by networthless on Wednesday October 18, 2017 @03:18PM (#15502081)
Say hi to Isabella for me
Re:C0, an Imperative Programming Language for Novice Compute... by dasimon on Wednesday October 18, 2017 @11:49AM (#15500145)
While well-constructed C programs are as minimal and straightforward as programs come, the language is certainly full of pitfalls (just look at the underhanded C contest). Keep in mind that most computer science students in their first intro course have not yet developed the mental models that experienced programmers take for granted. Students will try doing all sorts of things which don't make much sense, and C is overly permissive of these things unless you introduce additional tooling, e.g. valgrind, which can become very overwhelming for intro-to-CS students who are still feeling lost.

I agree that C0 on its own is overly simplistic, but the way it is used at CMU is as 'C with training wheels' - strict type checking, no potentially-unsafe pointers to the stack, dynamic array bounds checking, etc. Then, two thirds into the semester, students transition to real C, and learn how to correctly manage those potential pitfalls.

This is how students at CMU have been learning C since 2010, and graduates don't seem to be any worse off for it.

Re:C0, an Imperative Programming Language for Novice Compute... by grayhatter on Wednesday October 18, 2017 @12:23PM (#15500460)
>... have been learning C since 2010, and graduates don't seem to be any worse off for it.

[Citation needed]

> C is overly permissive of these things unless you introduce additional tooling, e.g. valgrind, which can become very overwhelming for intro-to-CS students who are still feeling lost.

Sure, but isn't the the POINT of college? To push you into unfamiliar territory? To force you out of your comfort zone, and then hand you the tools to learn something new?

It may just be my arrogence speaking, having already taught myself C. But I taught myself C, when I had to fix a bug, I taught myself asan, and valgrind. None of that was very overwhelming. Complicated, very. Confusing, occasionally. But Once I learned them, they became easy, and intuitive, and helpful.

I think the problem I have with your argument, is; when you apply it to math, the argument becomes painful.

You don't want to learn algebra, it' too complicated; lets learn this subset of algebra, without irrational or imaginary numbers.

Re:C0, an Imperative Programming Language for Novice Compute... by ufo on Wednesday October 18, 2017 @12:49PM (#15500685)
I don't get the analogy. Every algebra course goes over the material in order of complexity. You don't go over real analysis until the students have mastered the basics.

The problem with c is that the advanced things get in the way of the basics. You get students asking why their if statements didn't work and to answer you need to teach them GDB and valgrind and different compiler flags and how the stack works. This is a recipe for students that don't end up learning either thing. And it slows everything down so in the end of the year you can't cover everything properly and end up with mediocre C programmers you would never trust near a real C codebase

---

Another thing to remember is that we should be very careful about that drill sergeant mentality that intro to CS should be hard and painful. This advantages students that had the opportunity to program before university and often ends up turning away women and other minorities from the field

Re:C0, an Imperative Programming Language for Novice Compute... by fpig on Wednesday October 18, 2017 @02:04PM (#15501376)
You actually managed to change my mind and I now agree C isn't a good first language. Mixing C with data structures / algorithms in the very first programming course is probably not a good idea for the reasons you mention.

Although I am kind of miffed by the last sentence, I admit I'm one of the people who programmed WAY before college but in my experience most CS majors who didn't simply didn't choose to do so, as opposed to having lacked the opportunity to do so; you're dismissing the thousands of hours spent coding as a child (more than most CS majors invest in programming during college...) without the internet or anyone to teach me anything as "opportunity"

Re:C0, an Imperative Programming Language for Novice Compute... by slavik81 on Thursday October 19, 2017 @06:23AM (#15506753)
Why stop expectations for self-study at the programming part of the degree program? Math textbooks are available from any library. Rather than continuing mathematics from where high school left off, we could skip past the beginner stuff. The students who really care about computer science will have already learned the basics of discrete math, linear algebra and theory of computation.
Re:C0, an Imperative Programming Language for Novice Compute... by fpig on Thursday October 19, 2017 @07:32AM (#15506986)
Where did you get the idea that I said we should skip anything or that there should be "expectations" for self-study?

I have an issue with someone dismissing thousands of hours of invested effort as "having an opportunity". And the same is of course true for someone who went to the library and learned first year math.

Re:C0, an Imperative Programming Language for Novice Compute... by slavik81 on Thursday October 19, 2017 @12:28PM (#15509312)
My apologies. I misunderstood you.
Re:C0, an Imperative Programming Language for Novice Compute... by fhood on Wednesday October 18, 2017 @04:59PM (#15503021)
I didn't "choose" to program before college because I didn't decide to major in CS until I applied to college. And I suspect that unless "WAY" means high-school, you programmed before college because of your parents.
Re:C0, an Imperative Programming Language for Novice Compute... by fpig on Wednesday October 18, 2017 @07:14PM (#15504102)
Nah my parents are barely computer-literate even today. I found QBASIC that came with DOS when I was like 10 which had the source code for 2 simple games and decided I wanted to learn how to make stuff like that. A few years later I read about Linux somewhere and found someone who baked and mailed me Slackware on CDs for a small fee so then I had gcc
Re:C0, an Imperative Programming Language for Novice Compute... by grayhatter on Thursday October 19, 2017 @01:26AM (#15505649)
If you're learning C, as a basic intro into programming concepts... you're gonna have a bad time. Try python. However, if you're learning C because you'll need it later for [any reason]. You should learn gdb, and valgrind (asan has replaced valgrind for most of my usage, valgrind is often my last ditch now) on day one... I guess I mean to say, if you have better things to teach than gdb, then C isn't the language you should be using.

I would gladly hand over some C code to someone who's really interested in programming, but has only ever written python. I can't say the same about someone who's only known Java. So experience with C, isn't really a good bar to judge programmers by, not by itself anyways. You don't need to know how the stack works for most issues in C, and after you can make you stuff compile, without asking questions, is the time to learn about compiler flags.

So if that's the only argument for using an obscure/broken version of C, then it's a crap argument. If you've been doing CTF for years, the school needs to offer you CBE, not force you into a class where you'll only break the curve, and still be bored.

Also, I'd gladly turn away women and minorities both. If you're handed a problem you know has a solution, and you give up because it's hard. Your skin color or sex is irrelevant, if you're the type that gives up when it's hard; you're worthless as a programmer. (But that might just be my obsessive need to solve any problem I don't understand, so I might not be the best judge)

Re:C0, an Imperative Programming Language for Novice Compute... by murph-almighty on Wednesday October 18, 2017 @09:47PM (#15504843)
>>... have been learning C since 2010, and graduates don't seem to be any worse off for it.

>[Citation needed]

https://www.cmu.edu/career/about-us/salaries_and_destination...

Re:C0, an Imperative Programming Language for Novice Compute... by zeroozero on Wednesday October 18, 2017 @01:04PM (#15500829)
I would agree the point of college is to push you into unfamiliar territory.

But, that's why we have dedicated classes that challenge you. This language is meant for a course to try to bring everyone to the same level. Some students enter the course having done CTF's since middle school and others just took the AP exam. C0 is used only for one course, and the course that follows it uses C in depth.

Re:C0, an Imperative Programming Language for Novice Compute... by grayhatter on Thursday October 19, 2017 @01:28AM (#15505654)
My reply here https://news.ycombinator.com/item?id=15505649 also kinda responds to you, and rather than rehash... I'm just gonna link you.
Re:C0, an Imperative Programming Language for Novice Compute... by SeanDav on Wednesday October 18, 2017 @02:00PM (#15501343)
> "The only concept people struggle with is pointers, but even that is a very simple concept. "

The concept of pointers is simple, but their implementation has all sorts of subtle layers:

- interactions and apparent fungibility between pointers, arrays and strings

- how about: ( * (void( * )())0)();

- what about: * (p++) vs ( * p)++ or "++ * p", "* p++" and "* ++p" (Quotes for display reasons only)

- & vs * and various combinations of these

- pointers to pointers

- pointers to arrays of strings

- pointers to allocated memory that is/are not in scope anymore.

- Null pointer

- Many others!

Re:C0, an Imperative Programming Language for Novice Compute... by fenwick67 on Wednesday October 18, 2017 @11:59AM (#15500250)
> C language is as simple as it gets

Two types of files, compiler directives, pointers, malloc and friends, are you really sure about that? Any non-trivial C program will use these, on TOP of the basic syntax that first timers have to learn.

There is a reason it is usually not taught as a first language, and Java, Python, C# or even Assembly are.

Re:C0, an Imperative Programming Language for Novice Compute... by grayhatter on Wednesday October 18, 2017 @12:12PM (#15500358)
Yes, if you look at it from a C coders point of view. You know exactly what your program is doing (excluding compiler optimizations).

Java is taught a lot, not because it's better. But because once you learn Java, all you know how to do, is teach Java. Python is taught early because it's fun/easy, not because it's the best.

No one teaches ASM first anymore, what did you mean by saying asm is one of the first taught languages. (Maybe in some embedded systems, but generally that's not first, not by any reasonable definition.)

Re:C0, an Imperative Programming Language for Novice Compute... by ufo on Wednesday October 18, 2017 @12:30PM (#15500519)
> You know exactly what your program is doing

I think thd more accurate sentence would be "know exactly what the computer is doing". Lots of languages have clear and simple semantics that let you understand what your program will do. This is not the case for C though. The only way to understand what a C program does is to have a very complete mental model of the low level computer architecture, memory layouts, call stack organization and so on (aka knowing what the computer does). That is actually lot to go through for a first introductory course (hence why they are making a restricted language to teach before jumping to full C)

Re:C0, an Imperative Programming Language for Novice Compute... by khedoros1 on Wednesday October 18, 2017 @06:10PM (#15503681)
Java was taught at my school because you don't need to learn much boilerplate to get started, the OOP parts of the language are relatively clean, memory management isn't manual,...and because they got a nice deal with Sun.

Python has similar arguments. It's a clean but powerful language that gets out of the way of learning basic programming, data structures, and such.

> But because once you learn Java, all you know how to do, is teach Java.

Why is that true for Java or Python, but not for other languages?

Re:C0, an Imperative Programming Language for Novice Compute... by grayhatter on Thursday October 19, 2017 @01:33AM (#15505673)
That was meant a joke about Java being a worthless language.

It's true about a lot of languages. But C isn't one of them. You can do a lot with C, you can do almost as much with with python and a lot faster as well. I can enumerate more, but those are the only two relevant ones.

With Java, you can get a job where job performance is measured in LOC.

Re:C0, an Imperative Programming Language for Novice Compute... by verall on Wednesday October 18, 2017 @03:06PM (#15501984)
The Computer Engineering program at UT Austin teaches assembly (and architecture basics) for an academic RISC machine, then ARM assembly, and then C, in that order. So it's not no one, even if it's not as common anymore. It definitely makes C make more sense as an abstraction of asm. I believe the CS school starts on Java.
Re:C0, an Imperative Programming Language for Novice Compute... by grayhatter on Thursday October 19, 2017 @01:37AM (#15505690)
Is this the program where you literally build a computer from scratch, starting with a transistor, and working your way up. If so, you're comparing a top down approach, to a bottom up. Each with a different end goal. My comments are only meant to apply to a intro to CS top down approach, with the goal of creating programmers, not complete system engineers.
Re:C0, an Imperative Programming Language for Novice Compute... by jackmott on Wednesday October 18, 2017 @05:24PM (#15503279)
malloc isn't part of the language and not necessary for typical intro course projects usually.
Re:C0, an Imperative Programming Language for Novice Compute... by khedoros1 on Wednesday October 18, 2017 @06:03PM (#15503627)
malloc is defined within the C1X standard document as part of the C standard library. If you mean that malloc isn't a language keyword, OK, sure. And there are cases where you'd write a non-trivial C program without any dynamic memory allocation. It seems misleading to say that it's not part of the language, though.
Re:C0, an Imperative Programming Language for Novice Compute... by CodesInChaos on Wednesday October 18, 2017 @11:35AM (#15500000)
C is a very tricky language, because a lot of constructs that work when naively translated to assembly (on common CPUs like x86 or ARM) are actually undefined behaviour.
Re:C0, an Imperative Programming Language for Novice Compute... by fpig on Wednesday October 18, 2017 @11:48AM (#15500136)
This is always brought up when "difficulty" of C for teaching is discussed but it will basically never be an issue in a programming college course. It is a problem that doesn't exist.
Re:C0, an Imperative Programming Language for Novice Compute... by camus2 on Wednesday October 18, 2017 @08:09PM (#15504406)
C is not simple, C is language with a limited syntax and constructs which is not quite the same. Being proeficient in C means learning correct manual memory management, macros, an obtuse std lib, a compilation tool chain and management tools like Make, autotools and co. This is absolutely not simple. And don't get me started on string management with C.
Re:C0, an Imperative Programming Language for Novice Compute... by eru on Wednesday October 18, 2017 @02:19PM (#15501546)
C only has a few parts, but their interaction is tricky. That relates also to C's lack of (non-leaking) abstractions.

At the very least, you want something with friendlier behavior in the face of errors than what C gives you.

Re:C0, an Imperative Programming Language for Novice Compute... by lou1306 on Wednesday October 18, 2017 @11:55AM (#15500210)
I believe it is "simpler" in terms of formal semantics. Formalizing standard C is way harder (see https://github.com/kframework/c-semantics).

In fact, C0 is explicitly targeted at computer scientists rather than engineers.

Re:C0, an Imperative Programming Language for Novice Compute... by ci5er on Wednesday October 18, 2017 @01:30PM (#15501062)
> The only concept people struggle with is pointers

Why is that?

I've tried to explain pointers to people who struggle with the very small number of pointer-related concepts, and I ... fail.

But I don't know why I am failing. These are not stupid people - and I speak the English language well enough - so those aren't the reasons...

Re:C0, an Imperative Programming Language for Novice Compute... by maxxxxx on Wednesday October 18, 2017 @07:40PM (#15504263)
Maybe my brain is weird but I read Kernighan/Ritchie and had no problem grasping pointers. It's actually one of the simpler concepts compared to concurrency and others. But I know a lot of smart people who don't get pointers. I wonder if it's the teaching.
Re:C0, an Imperative Programming Language for Novice Compute... by eru on Wednesday October 18, 2017 @02:21PM (#15501568)
> The only concept people struggle with is pointers, but even that is a very simple concept.

Recursion?