CLANG vs GCC tests of fortran/f2c program

jb jb.1234abcd at gmail.com
Mon Jun 25 12:40:12 UTC 2012


Jakub Lach <jakub_lach <at> mailplus.pl> writes:

> 
> > I am more concerned about an aspect of the language the clang tools are
> > written in, namely the use of object-oriented paradigm of c++ (it is a
> > phony
> > paradigm, one that does not exist in nature or reality, which explains
> > the failure rate of C++ OO projects historically and current usage
> > decline).
> > I sense that the relative slowness of generated code has to do with it.
> > Perhaps
> > some other attributes of that code's quality too, even if not now, then in
> > the
> > future.
> 
> Yes, this is one thing really puzzled me. Maybe it's related to Apple's
> affinity 
> to Objective-C? 

Well, let me add some more and important facts to this discussion. 
If it caused so much emotions and name calling, then at least everybody should
know what this is all about.

Clang is a compiler front-end for C, C++, Objective-C and Objective-C++
programming languages and it uses LLVM as its back-end.

Both, clang and LLVM, are written in C++.

LLVM provides middle layers of compilation process and is e.g. responsible for
optimization of intermediate code, which next will be converted and linked into
machine-dependent assembly code.

Based on this source
  http://en.wikipedia.org/wiki/Objective-C
the Objective-C was influenced by Smalltalk's object-oriented programming
model, while C++ by Simula's.
This has implications for characteristics and performance of Objective-C,
for example:
- there are quite few important language elements in C++ that are not in
  Objective-C, like namespaces, multiple inheritance, operator overloading, etc
- "... Objective-C applications tend to be larger than similar C or C++
  applications because Objective-C dynamic typing does not allow methods to be
  stripped or inlined."
- "... Because Objective-C uses dynamic runtime typing and because all method
  calls are function calls (or, in some cases, syscalls), many common
  performance optimizations cannot be applied to Objective-C methods (for
  example: inlining, constant propagation, interprocedural optimizations, and
  scalar replacement of aggregates). This limits the performance of Objective-C
  abstractions relative to similar abstractions in languages such as C++ where
  such optimizations are possible."
- "... Objective-C is decidedly geared toward run-time decisions while C++ is
  geared toward compile-time decisions. The tension between dynamic and static
  programming involves many of the classic trade-offs in programming: dynamic
  features add flexibility, static features add speed and type checking."
  My Note: please keep in mind we are talking about language used for writing
  clang, a compiler tool.

So, Objective-C has disadvantage with regard to size od generated code,
performance, and optimization as compared to C++.

But both share OO (object-oriented) paradigm, which many pros consider
synthetic, or pulled out of thin air if you prefer, with negative effects on
devs mental health, design, and resulting code quality.

I hope I got all facts right -:)

It seems to me that switching to clang was a correct strategic decision for
reasons linked to GPLv3 license as described in my prior post and by other
thread posters.
But there seems to be some price paid related to "written in C++" facts
described by me in both posts, which may make some people come to a conclusion
that the decision was based more on a political factor (Apple) than on
technical merits.
Because I did not participate or followed FreeBSD's internal process, I can
not express any opinion to what extend both factors were considered and
discussed.

OK. Judge for yourselves, and have fun.

jb




More information about the freebsd-questions mailing list