[codecraft] Anti-IF Campaign
Michael Bar-Sinai
mich.barsinai at icloud.com
Sat Aug 29 16:40:37 EDT 2015
I think JIT and dynamic recompilers (such as HotSpot on the JVM) offer best of both worlds, inlining when possible and needed, while letting developers divide the functionality as they see fit. Note that inlining does not mean performance - too much of it creates large binaries that saturate the processor's instructions caches, actually deteriorating performance. That's a common complaint about over using C++'s templates (a.k.a "template bloat"). This is also true about Scala macros and such other compile time auto-code creators.
> On Aug 23, 2015, at 03:45, Zakariyya Mughal <zaki.mughal at gmail.com> wrote:
>
> On 2015-07-31 at 15:51:50 -0400, Michael Bar-Sinai wrote:
>> Nice find! I forgot about this campaign, even though I linked to its original page once [1]. It's interesting to note that you can always replace control flow with inheritance, as long as you allow conditional expressions (e.g. Java's treaty operator). This is how SmallTalk's Boolean class worked.
>>
>
> Coming back to this after a while, because I've been mulling this over.
>
> I like the abstraction afforded by objects and polymorphism. It makes it
> easier to fit a system into my head.
>
> However, I also like performance. Balancing the two is difficult. What
> recent work has been done in making it possible to have the best of both
> worlds? Using polymorphism is still a form of branching and it can be
> more expensive than inlining code since it can require multiple lookups
> depending on how you dispatch.
>
> So far I see work done on JIT, inline caching, profile guided
> optimisation, program specialisation, and multi-stage programming, but
> how much of that makes it out to everyday programmers? I know JITs and
> inline caches are the most successful of these. The others seem less
> prevalent. I am not a programming language system programmer, but I'd
> like to learn more about these techniques.
>
> In a related line of thinking, John Carmack wrote in [^1] about the
> balance between different styles of programming where, in one, you split
> functions into smaller functions and in the other, you manually inline
> the functions so that it clear what you are actually running.
>
> What has bothered me is that it seems that the language should help with
> that directly — that's what languages are for, no?
>
> Cheers,
> - Zaki Mughal
>
> [^1] "John Carmack on Inlined Code" <http://number-none.com/blow/john_carmack_on_inlined_code.html>.
>
>>
>>
>>
>>
>>
>> [1] https://today.java.net/pub/a/today/2008/08/21/complex-table-cell-rendering.html <https://today.java.net/pub/a/today/2008/08/21/complex-table-cell-rendering.html>
>>> On Jul 29, 2015, at 06:15, Philip Durbin <philipdurbin at gmail.com> wrote:
>>>
>>> http://antiifcampaign.com <http://antiifcampaign.com/>
>>> "The goal of the Anti-IF Campaign is to raise awareness of the effective use of software design principles and practices, by first of all removing bad, dangerous IFs."
>>>
>>> _______________________________________________
>>> codecraft mailing list
>>> codecraft at or8.net
>>> http://or8.net/mailman/listinfo/codecraft
>>
>
>> _______________________________________________
>> codecraft mailing list
>> codecraft at or8.net
>> http://or8.net/mailman/listinfo/codecraft
>
> _______________________________________________
> codecraft mailing list
> codecraft at or8.net
> http://or8.net/mailman/listinfo/codecraft
More information about the codecraft
mailing list