February 24, 2003
The way most cpu's compile if/else is:

if it's just an if clause, it assumes the branch *will* be taken, and puts the code inline

if it's an if/else clause, it assumes the else is the most likely branch,
but keeps the 'if' portion
inline also which requires a jump-around.

This is so an implementation detail.  Some cpu's can't branch very far so it pays to keep the code close together in memory.  On some the branch is expensive if taken, on some it's expensive both ways, on others (older cpu's) it's no more expensive than any other instruction.

The compiler vendor is the one that should be worrying about how to encode the semantics of the program into the cpu's instruction set and optimizing around its performance characteristics.

The only case where I feel something is missing is with SIMD instructions; there is a basic register type on the machine that we don't have access to at high level.  Arrays can fill this role, but many SIMD operations involve rearranging the slots or converting from one bit size to another... things array operations do not easily represent.  And the SIMD instructions usually are designed for a specific size array.  Sure you can use any size and ignore the remainder of the results.

Inline assembler is good for expressing an routine as efficiently as possible.  It's not good for exposing a low level datatype.

Sorry I seem to have changed the subject... ;)

I agree with the subject line.  Succinctness *is* power.  Explicitness just adds bloat.  It's useful bloat sometimes, but it can and does get in the way.  The requirement for being explicit should be in the coding standards for the company or project, not in the language.  The language should allow succinctness or explicitness, as the circumstances require.

Sean

"Mike Wynn" <mike.wynn@l8night.co.uk> wrote in message news:b3dgjj$2qiq$1@digitaldaemon.com...
>
> as do most modern JavaVM's (only the early 1.0.x where pure interpreters)
> Java VM's are not all JIT (compile before) some are dynamic compilers
> (compile if its used more than once as compilation + execute time can be
> longer than interpret once time) also this allows the true main line of
the
> code to be compiled.
> with C compilers 'if' is usally compiled as branch over the if clause,
with
> a dynamic compiler if the if cluase is not entered then it is compiled as
a
> branch out of the main line to the if clause making the common case code faster (missed branches are less expencive on most cpu's than taken branches).


February 25, 2003
"Ken Carpenter" <kencr@shaw.ca> wrote in message news:b3cg9g$1tfo$1@digitaldaemon.com...
> "Mark T" <Mark_member@pathlink.com> wrote in message news:b3aonm$dpc$1@digitaldaemon.com...
> > In article <b38jlm$1nb9$1@digitaldaemon.com>, Walter says...
> > >"Mark Evans" <Mark_member@pathlink.com> wrote in message news:b37347$cdr$1@digitaldaemon.com...
> > >> http://www.paulgraham.com/fix.html
> > >D: C++ is too complicated
> > ; Java, C# use VMs and don't have generics
> Many people hear "C# uses a VM" and assume that it's the same as Java.

Their respective VM's are pretty similar in how they work, and similar in being relatively large, although C#'s is much more ambitious.

> Just to clarify, C# and other .NET languages are first compiled to a "VM" code (CIL), but they are then compiled to native code before they are executed.

Of course. However, the native code is not stored anywhere, so at some point during the execution of your app it is going to spend time compiling. For a large app, this can be a very substantial performance hit. The upside of JITting is the generated code can be customized to the particular CPU being used.


February 25, 2003
"Bill Cox" <bill@viasic.com> schrieb im Newsbeitrag news:3E590E6E.4050204@viasic.com...

> It sounds like they have some good software.  Their "Network" algorithm components sound like the kind of thing I do a lot.

Hi, yes their algorithms are very advanced.

> I read some of their on-line documentation.  You have to create graphs in their database, run their algorthms, and then read out the results. It's not really reusable code.  For example, you couldn't use it to add graph functionality to hyper-graphs.

Really? Hm... must have changed radical since last time I used it. Normaly you get a set of classes and than make your way. But I have to say I didn't had a closer look into the online documentation. Robert


February 25, 2003
A good description of what first class functions entail from the excellent "Structure and Interpretation of Computer Programs", by Abelson and Sussmen:


"In general, programming languages impose restrictions on the ways in which computational elements can be manipulated. Elements with the fewest restrictions are said to have first-class status. Some of the ``rights and privileges'' of first-class elements are:64

* They may be named by variables.
* They may be passed as arguments to procedures.
* They may be returned as the results of procedures.
* They may be included in data structures.

Lisp, unlike other common programming languages, awards procedures full first-class status. This poses challenges for efficient implementation*, but the resulting gain in expressive power is enormous.

*: The major implementation cost of first-class procedures is that allowing procedures to be returned as values requires reserving storage for a procedure's free variables even while the procedure is not executing."


Dan Liebgold
February 26, 2003
"Walter" <walter@digitalmars.com> wrote in message news:b3f78a$h06$1@digitaldaemon.com...
> Of course. However, the native code is not stored anywhere, so at some
point
> during the execution of your app it is going to spend time compiling. For
a
> large app, this can be a very substantial performance hit. The upside of JITting is the generated code can be customized to the particular CPU
being
> used.

Actually, it is possible to "pre-JIT" the code using the ngen utility (Native Image Generator).  This can be used to precompile all (or some) of the assemblies used in your application.  You might, for example, choose to do this at install time.

There is one major caveat, however.   The JIT performs on-the-fly code optimizations, while ngen does not.  Thus, depending on the type of code in a given .NET assembly the JIT may run slower or faster than the precompiled version.  Your profiler is your friend here.


Ken Carpenter


February 27, 2003
The Oz book claims that 'procedure' is the more general concept (2.3.4).  So it talks about first-class procedures, which is a new twist, but basically sound, though it might ruffle feathers among functional programmers.

http://www.info.ucl.ac.be/people/PVR/book.html

Mark


>A good description of what first class functions entail from the excellent "Structure and Interpretation of Computer Programs", by Abelson and Sussmen:


1 2 3 4 5
Next ›   Last »