Live data from Hacker News

A Boggling Return to C

thraxil.org

41–50 of 88 posts

Re: A Boggling Return to C

#41
post #39
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.

In addition to K&R I always recommend "C Interfaces and Implementations: Techniques for Creating Reusable Software" to anyone who is picking up a long-term hobby or career in C. Someone on this forum recommended it to me. It's been invaluable assisting me in refactoring major portions of a legacy code base. In a way, it's helped me bring the DRY principle to our C application. I write in C every single day though and…

That's probably the book I need. I've wondered how I'm actually supposed to structure stuff in C so it's not too gross.

Re: A Boggling Return to C

#42
post #17

It's funny, because I recently tackled this exact same problem in Python as well. And guess what my first step was? Writing a prefix tree implementation, in order to use the exact same approach the author took in C. It never seriously occurred to me to do it any other way. It may be because I recently got into C as well after spending years with only Python, but honestly I think I would have done the same thing befor…

Well I didn't get back into C and last time I had to solve a similar problem typed:

  from Bio.trie import trie

Re: A Boggling Return to C

#43
post #16

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.

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 assume good chunks of Java are written in C, but I'm not sure.

We have "safer" languages but our systems and tools remain in C. Given the intense competition in software, there must be solid reasons C remains the foundation of computing.

Re: A Boggling Return to C

#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 ?

Re: A Boggling Return to C

#45
post #16

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.

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?

Re: A Boggling Return to C

#46
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…

I'm with you on the advantages of C, but this is not true:

"Skilled C programmers do not need profilers, bounds checkers and memory leak detectors."

Skilled programmers use profilers because the alternative (guessing) is a poor strategy for diagnosing poor performance. And no skilled programmer would spurn a useful tool like a bounds checker or memory leak detector, because nobody is perfect and these tools save immense amounts of time by pointing you straight to the problem.

Re: A Boggling Return to C

#47
post #22

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.

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.

Re: A Boggling Return to C

#48
post #25

"By way of comparison, the Python program takes 1.5 seconds to run, so that's about a 10X speedup." Only tenfold? Interesting. While Python is surely not the slowest interpreted language around, a result like that borders on the performance of Java. That seems unlikely, especially given the fact that Python version uses worse algorithm. I would think about how big is the portion of time eaten by I/O - that is, actual…

> a result like that borders on the performance of Java

I haven't seen the "Java is slow" chestnut in years.

Re: A Boggling Return to C

#49

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 has almost single handedly rescued C from the ashheap of history.

Re: A Boggling Return to C

#50
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…

Not need profilers? I haven't run into a C (or any other language) programmer so skilled that he's even usually correct at finding the bottleneck without a profiler.

Programmers who don't use profilers write slow programs (even though they spend many hours "optimizing" them).

Post reply on HN