News for hackers. Stuff that matters.
Re:The C language is purely functional by ajross on Wednesday May 20, 2009 @01:17PM (#618892)
Cute. There's actually a much more pedestrian point hidden in there, which is that cpp really is an extraordinarily expressive (if hideously clunky) environment, and you can do all sorts of good things with macros if you're willing to learn the tricks.

It's really sad that a bunch of people who never did learn the tricks ended up declaring macros as "bad" by fiat, to the extent that newer languages have had to invent less expressive versions (C++) or omit the facility entirely (Java). These days, it's almost a lost art.

Re:The C language is purely functional by russell on Wednesday May 20, 2009 @01:51PM (#618957)
Actually, it was a bunch of people who thought that the rest of us were not competent enough to use them without shooting ourselves in the foot, head, or other parts of our anatomy. (James Gosling are you listening?)

I used macros to great effect to create constant data structures for such things as keyword tables in parsers. The art of programming has advanced a long ways since the early days of C. I think the badness of macros is more a function of those times than inherent problems with macros themselves.

Re:The C language is purely functional by burke on Wednesday May 20, 2009 @06:37PM (#619463)
"...without shooting ourselves in the foot, head, or other parts of our anatomy."

I hear macros are useful for shooting yourself in the gun.

Re:The C language is purely functional by swolchok on Wednesday May 20, 2009 @01:22PM (#618901)
Well, cpp isn't Turing complete, assuming you only run it once: http://www.ioccc.org/2001/herrmann1.hint
Re:The C language is purely functional by eru on Wednesday May 20, 2009 @02:27PM (#619026)
And C++'s templates are Lambda-Calculus isomorph. (I.e. Turing complete for you imperative programmers. ;o)
Re:The C language is purely functional by jmillikin on Wednesday May 20, 2009 @08:06PM (#619575)
CPP can be used with Java, since it's completely independent of the "real" underlying language. There's also several native Java preprocessors available.
Re:The C language is purely functional by stcredzero on Wednesday May 20, 2009 @01:21PM (#618898)
Not that again! Someone comes up with some reason to say that C is really Functional about every one and a half years.
Re:The C language is purely functional by magv on Wednesday May 20, 2009 @05:41PM (#619395)
The article wasn't really about C at all.

The author was making a joke about how Haskell uses monads to remain pure.

"cpp" is Haskell, "C" is the way IO monad is used.

Re:The C language is purely functional by dagheti on Wednesday May 20, 2009 @11:55PM (#619851)
Isn't it important though how good CPP is at being Haskell, and how good IO is at being C?

This seems to come back to that original Scala-is-not-functional article, which seems to argue that it isn't features or purity that makes a language "functional" or not, it's how good the language is at working with that style.

Re:The C language is purely functional by conal on Wednesday May 20, 2009 @09:22PM (#619675)
Right. You got it.
Re:The C language is purely functional by jlouis on Thursday May 21, 2009 @05:28AM (#620135)
Corollary: There are no C and C++ programmers. Only CPP programmers using C and C++ for monadic computations :)
Re:The C language is purely functional by dimitar on Thursday May 21, 2009 @12:21AM (#619888)
Kernighan of K&R didn't invent C. Only the "R", Ritchie did. They wrote a good book together thought.