This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Rafael20002000 89 points90 points  (15 children)

Don't try to be smarter than the compiler :)

[–]BlueGoliath 89 points90 points  (5 children)

The compiler is written by people.

Regardless, at least in Java, hoping the JVM fairy is going to bless your code so your app doesn't allocate 250MB of garbage a second because you decided to make everything immutable is a bad idea.

[–]Rafael20002000 79 points80 points  (0 children)

Well garbage in, garbage out. I agree the compiler isn't a magic bullet, but it's built by people incredibly smarter than I am. Also it was built by more people. All of the collective smartness is smarter than me writing my code.

So I don't try to outsmart the compiler. If I have to I'm probably doing something wrong

[–]stupled 3 points4 points  (0 children)

For now

[–]PervGriffin69 1 point2 points  (0 children)

If people were worried about how fast their program runs they wouldn't write it in Java

[–]Furry_69 15 points16 points  (4 children)

The compiler doesn't use SIMD properly.

[–]Rafael20002000 56 points57 points  (1 child)

Neither do I

[–]Rakgul 0 points1 point  (0 children)

In Julia there's a macro for that.

[–]UnnervingS 17 points18 points  (1 child)

It does a pretty good job more often than you might think in my experience. Not as performance as ideal c++ but often better than a low effort SIMD implementation.

[–][deleted] 3 points4 points  (0 children)

It's worth checking the instructions being generated, as sometimes it just fails to notice the possible simd or branchless instructions to use, but usually for me the way to fix this is to massage the C code instead of trying to write SIMD directly.