Re: [fpc-pascal] for .. in loop implementation

2009-01-08 Thread Florian Klaempfl
Vinzent Höfler schrieb:
 Jürgen Hestermann wrote:
 
 Mantra: First make it work, then make it fast.

 In general that's true from the programmer's viewpoint. But this does
 not apply to adding language details because there is no 'first make
 it work'. Why obscure important implementation details if the only
 benefit is saving some writing?
 
 I won't judge on the only save some writing here, but generally it
 *does* apply to language features: If a particular language feature
 helps you writing correct code faster (by supporting you to make it work
 instead of relying on your abilities to use the debugger), then it does
 apply.
 
 The real question is if the (or any other) proposal is good enough to
 do just that, or if it's really some syntactic sweetener (not even
 sugar, sugar at least contains energy). That's something to discuss.

There is not much to discuss: Who has time to implement it without
hurting the implementation of other maybe more important stuff. If
someone provides usable (readable, commented code with tests, full
implementation support also the iterating interfaces) patches to
implement the for in ... stuff I'am sure they get applied.

 
 Let me take a rather extreme point of view: After all, all those for-,
 while-, and repeat-until-loops are only there to save you from some
 typing work[0], because Pascal already has a perfectly good
 loop-construct with which you can do all that: goto. Would you agree
 here? Probably not.

Not really because the use case of typical while/for/repeat loops is
much wider. How often do you iterate over the odd days of a week?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] for .. in loop implementation

2009-01-08 Thread Jeremy Cowgar

Marco van de Voort wrote:

In our previous episode, leledumbo said:

  

The latter one has iteration overheads, while the former can be optimized to
loop as many as needed. I'm not saying I'm the best Pascal programmer, but
in case there's a (better) solution to this (rather than extending the
language) please tell me.



Your assesment is correct as far as I can see. 


However IMHO that doesn't meant you are right. One single case of an
optimalization advantage, and then in a border case like iteration over a
constant set does not justify a language extension.
  


What is the negative of adding it? To me, I program in a language 
because it makes my life easy, not because each keyword has a 
certain/clear purpose and cannot be done any other method. The easier FP 
is for me to program in (or the less typing I have to do), the better FP 
is to me. I'm confused on why not to add it.


Jeremy

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] for .. in loop implementation

2009-01-08 Thread Marco van de Voort
In our previous episode, Jeremy Cowgar said:
  However IMHO that doesn't meant you are right. One single case of an
  optimalization advantage, and then in a border case like iteration over a
  constant set does not justify a language extension.
 
 What is the negative of adding it?

Clutter, maintenance, and somebody has to do both implementation and
maintenance, addition to documentation tool, pretty printer etc.

 To me, I program in a language 
 because it makes my life easy, not because each keyword has a 
 certain/clear purpose and cannot be done any other method. The easier FP 
 is for me to program in (or the less typing I have to do), the better FP 
 is to me. I'm confused on why not to add it.

Easy and typing are not related. Easy allows me to do my job quickly.
Typing has never been limiting in my job.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] for .. in loop implementationt

2009-01-08 Thread Marco van de Voort
In our previous episode, Jeremy Cowgar said:
  Clutter, maintenance, and somebody has to do both implementation and
  maintenance, addition to documentation tool, pretty printer etc.

 
 I wonder how much maintenance would actually have to be done? Once a 
 language construct is present, does it really take that much to keep it 
 up? 

Well, I only see the practice from years of reading bugreports, but :

often bugreports pertaining to language features are about special cases and
interactions between features. Like automated types, properties etc. What if
the right side is an expression instead of a value or a constant? What if it
involves ref counted types, what if it involves a temp location ? Etc.

 The same for the additions to documentation, pretty printer, etc... It's
 all done once and should be fine after that.

After a few additions, patches and tweaks, usually yes. And then it turns up
that Delphi also accepts   after in etc.
 
 However, I am speaking out of a not ever looking at the compiler source, 
 so I may be pretty far off base. Just thinking aloud.

People typically only think of a few standard cases like there are in the
manual. It is a totally different magnitude to fix any constuction the users
find in their existing Delphi code.

If you think it is worth it, by all means go ahead.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] for .. in loop implementation

2009-01-08 Thread Jürgen Hestermann

Vinzent Höfler schrieb:
 I won't judge on the only save some writing here, but generally it
 *does* apply to language features: If a particular language feature
 helps you writing correct code faster (by supporting you to make it work
 instead of relying on your abilities to use the debugger), then it does
 apply.

What I fear (from observing the last decade or two) is that the language 
becomes bloated by adding one gimmick after the other just to say me 
too. Every new feature is something that a (new) user has to learn 
about. And the more types of FOR loops you add the more confusing it gets.


 Let me take a rather extreme point of view: After all, all those for-,
 while-, and repeat-until-loops are only there to save you from some
 typing work[0], because Pascal already has a perfectly good
 loop-construct with which you can do all that: goto. Would you agree
 here? Probably not.

Of course not. But would you on the other side agree with adding each 
and every gimmick mankind can think of? Probably not either.


 Maybe, but you started talking about performance. ;-)
 Nono, you did: Everything that obscures what's going on under the hood
 has the potential to generate performance problems.

You are right that not you started talking about performance but 
leledumbo in his starting post about this topic where he assumed a 
performance gain:


The latter one has iteration overheads, while the former can be 
optimized to loop as many as needed.


So none of us started talking about it. ;-)

 So to get to the point, finally: The argument that some particular
 language construct has the potential to generate performance problems is
 NIL. IMNSHO.

I doubt that. I often stumble over programs which are awfully slow 
(Novell Salvage Dialog for examples sometines needs many minutes to sort 
80 objects!). And that compared with the everywhere heard statement 
You don't need to think about performance, it's only important that it 
runs at all makes me thinking. Many programmers simply don't know about 
how their mighty language functions perform and what they do in the 
background. But without knowing this you don't even have an idea of how 
fast it will be.


I also had such experience with Virtual Pascal where the 
FindFirst/FindNext API functions are obscured by an extra layer to 
support multiple platforms (which I didn't know at first). I only 
wondered why my simple scan program for the creation date of files took 
2 days on our server. After removing all the overhead by directly using 
FindFirst/FindNext from the windows API it boosted up to 6 hours only. 
Sure, many people don't care whether a program runs 2 days or 6 hours 
but I do.


Jürgen Hestermann.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] for .. in loop implementation

2009-01-08 Thread Jonas Maebe


On 08 Jan 2009, at 19:01, Jürgen Hestermann wrote:

I doubt that. I often stumble over programs which are awfully slow  
(Novell Salvage Dialog for examples sometines needs many minutes to  
sort 80 objects!). And that compared with the everywhere heard  
statement You don't need to think about performance, it's only  
important that it runs at all makes me thinking. Many programmers  
simply don't know about how their mighty language functions perform  
and what they do in the background. But without knowing this you  
don't even have an idea of how fast it will be.


I also had such experience with Virtual Pascal where the FindFirst/ 
FindNext API functions are obscured by an extra layer to support  
multiple platforms (which I didn't know at first). I only wondered  
why my simple scan program for the creation date of files took 2  
days on our server. After removing all the overhead by directly  
using FindFirst/FindNext from the windows API it boosted up to 6  
hours only. Sure, many people don't care whether a program runs 2  
days or 6 hours but I do.


These are examples of bad underlying implementations. In both of these  
cases the implementation can probably be optimised to deliver close to  
maximal performance. The evolution to more and more abstraction is  
simply because there are more and more different underlying platforms,  
and because the days that most programmers were able to take full  
advantage of the underlying platform are long gone. With the moves to  
system and process virtual machines, many-cores, cloud computing,  
accelerators etc. this is only getting worse.


Not to mention that going as low level as possible to get the last bit  
of performance will mean that you'll have to redo that work over and  
over again, unless you stay with one particular generation of one  
particular platform.



Jonas___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal