Live data from Hacker News

Block rewriting with Clang

techtalk.intersec.com

21–23 of 23 posts

Re: Block rewriting with Clang

#21
post #17
post #10

Earlier quoted context omitted.

D? why does everybody hate/ignore D?

Interesting question. I'm not intimately familiar with D, but it does seem like it's designed as a saner alternative to C++. How many C++ alternatives are out there? From my memory D seemed like one of the first major attempts to get away from C++. Maybe they didn't go far enough to meet peoples expectations. Or maybe they were too far ahead of their time. Anyway, when you said that the first thing that popped into m…

You are overthinking it.

D had a "version two" new compiler issue, and a "let's rewrite basic libraries" issue that split the user base.

They are also bad at marketing (and no match for Google's visibility -- they don't even have a maskot, IIRC)

And they still lack some basic things to this day, including a way to go from download to compiling your code in a minute.

Re: Block rewriting with Clang

#22
post #16

I don't get it, they are interested in closure and have a codebase in C, why not simply using C++11 with lambda? This would make the code portable to GCC/MSVC... Arguably they started before C++11 was officially released, but clang and gcc supported lambda before the official release, and also since then they could have used a rewriter to transform their blocks into lambda to help for the conversion.

Three main reasons for this.

First, we originally chose the C language because it is much much simpler. One can master the language without too much pain, and you end up having much more control on what you are actually doing (there's little chance a line of code does not do what you read from it... while in C++ you may have hidden behavior behind even the simpler operation such a + or *).

Secondly, and this is probably a matter of taste, C++11's lambdas are just awfully designed. Their syntax overloads, with a totally different meaning, some tokens such as []. As in many situations, C++ design committee tends to chose the most complicate possible design, without taking readability into account (maybe conciseness is the main goal of their syntax choices?). On the other, the blocks syntax makes is very clear you are dealing with a function-like object with very similar syntax. The choice was made to have a clean and readable syntax.

Third point, C++11 just didn't exist in 2009. There were drafts but support from compilers was just nascent. RHEL in 2009 was at version 6 (very young release) which ships with GCC 4.4 (and GCC 4.7 as an experimental toolchain). The most common RHEL was version 5 with GCC 4.1. RHEL officially supports C++11 since RHEL 7 which ships with GCC 4.8 and was release on June 2014.

Re: Block rewriting with Clang

#23
post #2

While kudos to getting this to work, seems like a huge amount of effort and voodoo when instead one could have used a different language in the first place.

I'm not sure why you're getting downvoted. Your opinion seems valid to me. Many of the benefits to writing C go away if you use extensions like this.

Extensions are how new features come to an established language... C11 standard mostly standardised stuff that was already supported as extension by most compilers. Most of the time, extensions are created because features are missing from the language (alignement requirement for example), compiler could do a better job at optimising the code with better hints (noreturn, restrict, strict-aliasing, ...), or we could simply make the job of the developper a bit simpler/safer (nested functions, _Generic, blocks, ...).

IMHO, the main benefit lost by using bleeding-edge extensions is portability, which may or may not be an issue.

Post reply on HN