Live data from Hacker News

C, The Beautiful Language

tenaciousc.com

11–20 of 85 posts

Re: C, The Beautiful Language

#13
post #9

This is a nicely written tribute, but there are two generalisations that I feel are worth pointing out. Many parts of Linux kernel are really, really nice C code. Sadly, in my experience most C code is not especially nice. I don't know how this extends to the football metaphor, but certainly I wish most of the C code I have encountered (not to mention written) in my career to date was one tenth as neat. On balance, I…

What are some specific examples of beautiful C code in your view? Asking for a friend.

Re: C, The Beautiful Language

#14
post #10
post #5

Earlier quoted context omitted.

Of course this isn't a feature of the language -- but most implementations (e.g. gcc) technically allow this, if you really, really know what you're doing. For example: http://www.cesarbs.org/blog/2010/07/19/run-time-machine-code...

Yes, you can generate machine code yourself, but then you have to write machine code ... I'm suggesting a JIT compiler as a built-in language feature so that you could write code in a high-level language and have machine code generated that was specialized based on the program's dynamic state. It could be done as a library, but it would benefit from language integration so that you wouldn't have to write the code as…

Language integration would be nice, however dynamic code generation from a library has been about for some time now:

"With libtcc, you can use TCC as a backend for dynamic code generation." from http://bellard.org/tcc/

Re: C, The Beautiful Language

#15
post #7
post #4

> In other languages, the abstractions and sweet (if helpful) syntactic sugar that attend the code conceal the heartbeat. IMO, that means they're failed abstractions and syntactic sugar. Proper ones should result in better understanding due to simplification - you can learn it in levels, easily encapsulating the knowledge at each level so you know you can "trust" what it's doing without having to remember all of it.

As such, any abstraction or syntactic sugar that distances you from the flow of the program fail. Bu that's for programs that are procedural. Functional programming has no flow. Truth neither moves nor changes. To use an analogy, a procedural program is like music, where rhythm and motion of the instrument are the essence of what you are representing. Functional programming is more like sculpture, where you create an…

I haven't done functional programming really, I didn't think of that case.

Interesting that it still seems to apply, though. If your abstractions in functional programs obscure that flow, they still strike me as a failure. Though I'd be interested in if functional programmers would disagree, I obviously don't know functional design patterns.

Re: C, The Beautiful Language

#16
post #6

> we watch Ronaldo doing things on the pitch Hmmm... Lionel Messi does crazy things you never thought were possible. He's Lisp. Gareth Bale has few fancy tricks, but does what he does very well, and often relies on pure speed - C. Joey Barton is good, but has a bad reputation and a sordid history - Fortran? Etc :-)

I wonder which Ronaldo he meant. I can't quite get over the moody, cheating side of Cristiano Ronaldo to appreciate his abilities. Having a Cristiano Ronaldo as a developer would be a bloody nightmare. It'd be like having a co-worker who turned in some inspired code, but who lied, stole, picked fights and was generally a chore to be around.

I hope he meant Brazil's Ronaldo circa 2002 :)

Re: C, The Beautiful Language

#17
post #2

C is more a description of a Harvard machine than a von Neumann machine. In fact, a useful new language feature would be dynamic generation of machine code.

It's C++ and of course dependent on Unix/Windows memory mapping APIs, but you might like asmjit: http://code.google.com/p/asmjit/

Re: C, The Beautiful Language

#18
post #9

This is a nicely written tribute, but there are two generalisations that I feel are worth pointing out. Many parts of Linux kernel are really, really nice C code. Sadly, in my experience most C code is not especially nice. I don't know how this extends to the football metaphor, but certainly I wish most of the C code I have encountered (not to mention written) in my career to date was one tenth as neat. On balance, I…

As the old joke has it, you can write FORTRAN in any language.

Re: C, The Beautiful Language

#19
post #8

In my experience it is more 'fun' to write C code then to lay down yet another line of boiler-plate high level code. However, it seems to take longer to get things done and the resulting code is also much more error-prone (at least my code that is).

I feel C has more boiler-plate code than any other language I've used, including Java--especially when you consider header files, malloc/free, function call error code inspection, etc.

Re: C, The Beautiful Language

#20
post #9

This is a nicely written tribute, but there are two generalisations that I feel are worth pointing out. Many parts of Linux kernel are really, really nice C code. Sadly, in my experience most C code is not especially nice. I don't know how this extends to the football metaphor, but certainly I wish most of the C code I have encountered (not to mention written) in my career to date was one tenth as neat. On balance, I…

What are some specific examples of beautiful C code in your view? Asking for a friend.

After finding the documentation and guides for writing nginx modules woefully inadequate, I did a lot of poking around in the nginx internals to better understand how things worked.

The code is very readable, follows good style guidelines, and has its fair share of brilliant workings. I found that the source code served as much better documentation than a lot of _actual_ documentation that I've read.

Post reply on HN