Live data from Hacker News

A Boggling Return to C

thraxil.org

51–60 of 88 posts

Re: A Boggling Return to C

#51
post #31

Earlier quoted context omitted.

This is why Zed pushed it so hard in Learn C the Hard Way. Some people actually had the gall to complain about him ensuring the noobies learned to use valgrind before proceeding to write any real code. Ingrateful dipshits don't remember what the pre-valgrind/dtrace days were like.

Is Learn C the Hard Way a useful re-introduction? Like the article, I need to re-learn C. Last time I wrote anything in C was on Netware NLMs, and it has been long enough that I have mostly forgotten what I knew.

i was looking for a good book to bring me up-to-date on recent changes to c and the best suggestion i received was to get the latest edition of harbison and steel's book (which includes c99).

i don't know if you know the book - an older copy is on my desk and it use it regularly when working in c - but it's part introduction and part informed guide to the libraries. it's not a "friendly" book (it's not for "dummies"), but it's well written and surprisingly compact for all it contains (at least, the copy i have is; i am waiting for delivery of the latest version).

Re: A Boggling Return to C

#52
post #45
post #16

Earlier quoted context omitted.

Tools only created to solve the lack of safe constructs in C. C made lots of sense in the context it was developed, but the world would be better if we had safer systems programming languages. Valgrind, purify and friends are required to C, the same way Java requires IDEs, to improve language usability. Have said this, the new trend in having static analysis tools integrated in the development process, like Clang, Ec…

There is lots of great discussion going on in this thread. I particularly enjoyed the article, which took a "deliberately novice" approach, and was very Zen-like. Why attack C at all? Why not instead convince us of the merits of another language? There are great tools around. I agree with that. Which parts of Clang do you like best?

The static analyser, friendlier error messages and the plugin architecture that allows it to integrate easily in IDEs.

The re-factoring support and modules extensions are also a welcome additions.

Re: A Boggling Return to C

#53
post #16

Earlier quoted context omitted.

Tools only created to solve the lack of safe constructs in C. C made lots of sense in the context it was developed, but the world would be better if we had safer systems programming languages. Valgrind, purify and friends are required to C, the same way Java requires IDEs, to improve language usability. Have said this, the new trend in having static analysis tools integrated in the development process, like Clang, Ec…

C is popular, good enough, portable, and fast. Skilled C programmers do not need profilers, bounds checkers and memory leak detectors. They help some people, though, no doubt. When size and speed matters, as in Operating Systems, C has won and continues to win the survival of the fittest competition. Almost all the programs I use are C (and/or C++): bash, linux, perl, firefox, awk, sed, grep, apache, mysql, etc. I as…

> ... Skilled C programmers ...

Sadly you don't find many of them in the enterprise world, specially when dealing with off-shoring companies. :(

> ... Given the intense competition in software, there must be solid reasons C remains the foundation of computing.

Because it is dumb to code everything new, just because another language is cooler, nicer, safer, etc. So existing software keeps being coded in C.

Even if I expressed my opinion the way I did, I will surely pick C if it makes sense for the project at hand.

Re: A Boggling Return to C

#54

I'm a student who learns C#, Java, Php, javascript... at school. I bought "C: A Refence Manual" to learn this summer... Hope it will make me a better programmer.

I loved my Harbinson/Steele C book, a long time ago. Google says the last version came 2002 with additions on the web. Good memories, I'll buy a copy and read just for nostalgia. Thanks.

Re: A Boggling Return to C

#55
post #47
post #22

Earlier quoted context omitted.

If you want to learn C, K&R is the right way to do it. C: A Reference Manual is excellent and is probably the only other C book you need, but only if you are already a C programmer, and only for what the title implies: reference.

K&R is a book not suitable for beginner tutorial in C, especially modern C. As a reference type work, ok.

No, but it's perfect for an experienced programmer in other languages to pick up C.

Re: A Boggling Return to C

#56
post #47
post #22

Earlier quoted context omitted.

If you want to learn C, K&R is the right way to do it. C: A Reference Manual is excellent and is probably the only other C book you need, but only if you are already a C programmer, and only for what the title implies: reference.

K&R is a book not suitable for beginner tutorial in C, especially modern C. As a reference type work, ok.

I really would like an updated version of it, but I guess it will never be written.

Re: A Boggling Return to C

#57

maybe the biggest improvement in c programming over the last decade is valgrind, making purify-like debugging available to everyone. it's completely removed a whole class of annoyingly hard to fix bugs from my code.

valgrind, is only available for a few platforms/architectures. If you are unable to writer proper C programs without valgrind's help, please go home. :-)

The advantage of not feeling tied to valgrind is that you don't need to run your program under valgrind to get the benefit of whatever mechanisms are in place to detect scribbles, accesses to uninitialised data, and leaks.

(valgrind's lack of availability is a bit of a problem. I'm not complaining - I bet it is a bit fiddly to port it to a new system - but it's very easy to never have come across any system that can run it in your professional life. So being able to work without it is no waste of time.)

Uninitialised data and memory scribbles can be tricky to detect 100% reliably without valgrind, but if you code appropriately, you'll spot it. Leaks are very easy to find (fixing them, not always so much), and I don't really understand why one needs this monster program to discover them - but maybe one day I'll actually be in a position to use it, and I'll find out what I'm missing.

Re: A Boggling Return to C

#58
post #44

>> The C version is functional but will probably make more experienced C programmers cringe. Oh boy. This looks like the type of C code I write. Could some experienced C programmer please point out what parts are cringe inducing ?

Not being a experienced C programmer by any measure, but this doesn't look right to me: https://github.com/thraxil/boggle/blob/master/boggle.c#L92

    struct foo f() {
        struct foo f;
        return f;
    }
isn't returning a stack-allocated struct a bad idea?

Re: A Boggling Return to C

#59
post #7

Earlier quoted context omitted.

valgrind, is only available for a few platforms/architectures. If you are unable to writer proper C programs without valgrind's help, please go home. :-)

Depends what you mean by "proper". Any fool can get a C program to work, but ensuring there are no memory leaks etc is very hard without a tool like Valgrind. If you don't believe me, just run Valgrind on random sampling of C programs that didn't use such a tool - I reckon it will find issues with most of them.

Valgrind (and tools using its methodology) isn't the only way to solve these problems. Libumem finds memory leaks too, and without imposing an immense runtime cost. It also finds many types of memory corruption without the runtime overhead that often changes the program's behavior that you're trying to debug.

Re: A Boggling Return to C

#60
Writing a boggle solver was the first assignment in CS106X at Stanford, which was still taught in C when I took it in the fall of 1994.

The trie code as well as the display UI were provided - you only had to write the board-walking code.

Being as this was the first time I had ever written any program, I remember it being quite challenging but also really fun. It was great to see your own program utterly house you when you played against it.

I wonder if I still have that code somewhere ... it would be fun to look at / cringe.

Post reply on HN