Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

It's painful for the compiler too, it has to turn the parents imperative code into SSA (essentially A-normal form) so it can optimise it!


sort by: page size:

Wow, this is so sad, that compiler has to be extremely bad implemented

Having to change how you write your program is the worst case of suffering compiler shenanigans that I can think of.

Maybe not the language choice, but the codegen of this compiler is terrible because of the single-pass shortcuts (for example, it unconditionally loads the result of all assignment operations back to the stack just in case you want to write `a = b = 1`, even though 99% of the time that load is immediately thrown away.)

What kind of difficulties? I don't understand why this would make any difference from a compiler's perspective.

It's just so fiddly - can't trust the compiler, not a good sign for a language or its implementation.

> that doesn't take seconds to compile a single long-ish expression with floating point arithmetic

Or some complex Combine chains just hang forever and not compile at all with no indication what the problem is. Yet they keep adding language features that clearly the compiler can't deal with.


I love when people fail to understand the specification of the language and blame the compiler.

I agree with you on all points, but the parent sounded like he was relying on the compile-time checks to determine correctness. I was making the point that that is a bad idea.

The problem is this causes the compiler to correctly solve your recreational math problems, which isn't actually a much fun as solving them yourself!

>Also, unfortunately, current compilers are notoriously bad at generating code with special instructions (vectorized code).

Sounds like the downfall of the Itanium. They promised that the compilers would make it all usable, but the compilers never showed up.


you're right it must be really tricky to spot and work around it but just the tought of blaming the compiler not sloppy programming is amusing

I suppose this is one of those things where people’s experiences vary widely, but FWIW after 20 years of writing C/C++, I can count the number of times this has bitten me on one finger. And even then, I still think it was more likely just an optimizer bug in the god-awful compiler.

Especially if you compile without optimisations. The optimisations can introduce bugs (although most of the times are related to undefined behaviour in the code), but without it is rare…

Very helpful, thank you!

I guess another problem would be that people often complain about how slow these kinds of compilers can be, and if you keep around enough to reconstruct good error messages it would probably make it that much slower.


Have you seen decompiled code? That's all that compiler cares about, it is not pretty.

The problem with the compiler is that it implements a language whose rules, applied to the code I just wrote, yield a bug. That this language is consistent with the spec makes it no less a problem.

Yep. Hearing that solution to the problem was just beyond reason. Its like they didn't just set some compile flags and constants for the architecture, but decided that their code had to calculate it every time the variable is needed. The line about finding if /dev/null moved was also pretty scary.

It's alarming that such a high level difference has that much influence over code generation, in such a mature compiler.

"High level isn't really helping, it is giving the compiler room to either screw up or shine."

"It is ... frustrating if it screws up."

next

Legal | privacy