Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm not sure if this is what the previous poster was talking about, but clang has some APIs that let you get access to the AST pretty easily. It's been a really long time since I've looked at it, and at the time I don't think it was exposed as a library API for general consumption. But for example: https://github.com/bratsche/clang/blob/gtkrewriter/tools/cla...


What is his definition of better? It sounds like he thinks it's entirely objective, so he should be able to express it clearly and logically.

Does he think that it's technically more powerful? Again he should be able to prove that if that's the case.

Otherwise he's just giving a shitty opinion, and should say that.

I think the claim is nonsense because with inline assembler there is nothing that you cannot express in C that you can with LLVM. So the decision between the two is opinion.


>Does he think that it's technically more powerful? Again he should be able to prove that if that's the case. Otherwise he's just giving a shitty opinion, and should say that.

It's not like it's some controversial opinion what he said -- it's both self evident and common place. It's you who offers the more controversial opinion (and in a rude way, to top).

>I think the claim is nonsense because with inline assembler there is nothing that you cannot express in C that you can with LLVM. So the decision between the two is opinion.

It's not about "expression", and nobody argued that you can express more in LLVM.

This is missing the point by miles!

It's about having more structure and less of an ad-hoc pipeline, which helps with better tooling, error prevention, etc.

(Not only what you wrote is wrong, but even if the original argument was about expression, your opinion would still be wrong. Two things offering equivalent expressive power, does not mean that they are just as good to use in practice at all. Might as well ask "why invent new languages, when assembly can express everything").

The only benefit to using C for something like this is portability, which is something else altogether.


> It's not like it's some controversial opinion what he said -- it's both self evident and common place.

As someone who has written more than one compiler, I don't see how it is self-evident at all. It's also not at all that common-place compared to generating C or asm output textually.

> It's about having more structure and less of an ad-hoc pipeline, which helps with better tooling, error prevention, etc.

Those provide some benefits, sure. At the cost of massive amounts of complexity in the case of LLVM.

> The only benefit to using C for something like this is portability, which is something else altogether.

Now it is you who are wrong. Other people have already pointed out, for example, that C provides an easy-to-read intermediate format, and is simple to generate, as other benefits. Not having to deal with a massive C++ codebase is another.

You may disagree that these other benefits are worth it, but for me at least they are (just taking a break from a compiler that generates textual asm because I find even that preferable to dealing with LLVM).


Sure, I agree about this: "C provides an easy-to-read intermediate format, and is simple to generate, as other benefits. Not having to deal with a massive C++ codebase is another.".

So portability and less dependencies, plus easier.


I don't know what his definition of anything is. I happen to agree with you. The example I pasted above was just from my only experience working with a C AST. In that case I wanted to input C code and then write out a transformed version of it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: