A tool that suggests optimized logic for a piece ofcode/module/function

Discussion in 'C Programming' started by karthikbalaguru, Jan 11, 2010.

  1. Hi,
    There are certain editors that highlight
    the syntax/color for datatypes/variables
    or comments etc.

    Similarly,
    Is there a tool for C language that
    could suggest an optimized/alternate
    programming logic for the function that
    is written ?

    The optimized/alternate logic can be
    suggested as soon as we finish coding
    for one function or it can be suggested
    as soon as the code is compiled/parsed
    by that tool.

    It will be even more helpful if that tool
    also provides the cycle counts, cache
    usage, cache misses and lines of code
    also.

    It would be better if that tool has an
    option to enable / disable this feature
    either through compile time or some
    other configurations.

    Any ideas ?

    Thx in advans,
    Karthik Balaguru
     
    karthikbalaguru, Jan 11, 2010
    #1
    1. Advertising

  2. karthikbalaguru

    acd Guest

    On 11 Jan., 21:07, karthikbalaguru <>
    wrote:
    > Hi,
    > There are certain editors that highlight
    > the syntax/color for datatypes/variables
    > or comments etc.
    >
    > Similarly,
    > Is there a tool for C language that
    > could suggest an optimized/alternate
    > programming logic for the function that
    > is written ?
    >
    > The optimized/alternate logic can be
    > suggested as soon as we finish coding
    > for one function or it can be suggested
    > as soon as the code is compiled/parsed
    > by that tool.
    >
    > It will be even more helpful if that tool
    > also provides the cycle counts, cache
    > usage, cache misses and lines of code
    > also.
    >
    > It would be better if that tool has an
    > option to enable / disable this feature
    > either through compile time or some
    > other configurations.
    >
    > Any ideas ?
    >
    > Thx in advans,
    > Karthik Balaguru


    Brain?

    Seriously, I think this is impossible.
    What I can recommend to you are some good books, including
    (More) Programming Perls
    and
    Hacker's delight.

    Andreas
     
    acd, Jan 12, 2010
    #2
    1. Advertising

  3. karthikbalaguru

    scattered Guest

    On Jan 12, 11:04 am, acd <> wrote:
    > On 11 Jan., 21:07, karthikbalaguru <>
    > wrote:
    >
    >
    >
    >
    >
    > > Hi,
    > > There are certain editors that highlight
    > > the syntax/color for datatypes/variables
    > > or comments etc.

    >
    > > Similarly,
    > > Is there a tool for C language that
    > > could suggest an optimized/alternate
    > > programming logic for the function that
    > > is written ?

    >
    > > The optimized/alternate logic can be
    > > suggested as soon as we finish coding
    > > for one function or it can be suggested
    > > as soon as the code is compiled/parsed
    > > by that tool.

    >
    > > It will be even more helpful if that tool
    > > also provides the cycle counts, cache
    > > usage, cache misses and lines of code
    > > also.

    >
    > > It would be better if that tool has an
    > > option to enable / disable this feature
    > > either through compile time or some
    > > other configurations.

    >
    > > Any ideas ?

    >
    > > Thx in advans,
    > > Karthik Balaguru

    >
    > Brain?
    >
    > Seriously, I think this is impossible.
    > What I can recommend to you are some good books, including
    > (More) Programming Perls
    > and
    > Hacker's delight.
    >
    > Andreas- Hide quoted text -
    >
    > - Show quoted text -


    I don't see why it would be impossible. Optimizing compilers exist and
    by using similar techniques it should be possible to write a compiler
    that uses C as both the source and target language. How useful this
    would be is another question. The resulting code would need to be
    humanly readable if the tool would be of any use and the would
    probably place severe restrictions on the sorts of optimizations that
    can be done. I would be surprised if no work along these lines has
    been done.

    -scattered
     
    scattered, Jan 12, 2010
    #3
  4. Re: A tool that suggests optimized logic for a piece of code/module/function

    On 2010-01-12, scattered <> wrote:
    > On Jan 12, 11:04 am, acd <> wrote:
    >> On 11 Jan., 21:07, karthikbalaguru <>
    >> wrote:
    >> > Hi,
    >> > There are certain editors that highlight
    >> > the syntax/color for datatypes/variables
    >> > or comments etc.

    >>
    >> > Similarly,
    >> > Is there a tool for C language that
    >> > could suggest an optimized/alternate
    >> > programming logic for the function that
    >> > is written ?

    >>
    >> > The optimized/alternate logic can be
    >> > suggested as soon as we finish coding
    >> > for one function or it can be suggested
    >> > as soon as the code is compiled/parsed
    >> > by that tool.

    >>
    >> > It will be even more helpful if that tool
    >> > also provides the cycle counts, cache
    >> > usage, cache misses and lines of code
    >> > also.

    >>
    >> > It would be better if that tool has an
    >> > option to enable / disable this feature
    >> > either through compile time or some
    >> > other configurations.

    >>
    >> > Any ideas ?

    >>
    >> > Thx in advans,
    >> > Karthik Balaguru

    >>
    >> Brain?
    >>
    >> Seriously, I think this is impossible.
    >> What I can recommend to you are some good books, including
    >> (More) Programming Perls
    >> and
    >> Hacker's delight.
    >>
    >> Andreas- Hide quoted text -
    >>
    >> - Show quoted text -

    >
    > I don't see why it would be impossible. Optimizing compilers exist and
    > by using similar techniques it should be possible to write a compiler
    > that uses C as both the source and target language. How useful this
    > would be is another question. The resulting code would need to be
    > humanly readable if the tool would be of any use and the would
    > probably place severe restrictions on the sorts of optimizations that
    > can be done. I would be surprised if no work along these lines has
    > been done.
    >


    Indeed, some of what he suggested (loop counting, etc) would be not
    only very useful, but would be an excellent parsing/analysis learning
    experience if the OP were to try and implement it himself.

    And C would be an excellent language for this, because it has so few
    keywords and such straightforward branch control contructs (function
    pointers aside).
     
    Andrew Poelstra, Jan 12, 2010
    #4
  5. karthikbalaguru

    Walter Banks Guest

    scattered wrote:

    > On Jan 12, 11:04 am, acd <> wrote:
    >
    > > (More) Programming Perls
    > > and
    > > Hacker's delight.


    ---------------------------------------

    >


    > I don't see why it would be impossible. Optimizing compilers exist and
    > by using similar techniques it should be possible to write a compiler
    > that uses C as both the source and target language. How useful this
    > would be is another question. The resulting code would need to be
    > humanly readable if the tool would be of any use and the would
    > probably place severe restrictions on the sorts of optimizations that
    > can be done. I would be surprised if no work along these lines has
    > been done.


    Programming Pearls and Hacker's delight are both must haves
    even if you are only remotely interested programming algorithms.

    There has been quite a bit of work done in compilers at the
    expression level to optimize algorithms and statements
    implementing functionally equivalent statements in the
    generated code.

    The problem in the bigger scale suggested by the op is the
    ability to recognize the larger overview of the programming
    objective at the scale of turning a bubble sort into a quick
    sort.

    At the statement level recognizing functionality is generally
    a simple task. At the function level this a significantly larger
    problem.

    The solution may be mostly hard work and processing
    cycles. A start may be to catalog common functions
    and implementations and create a significant tool
    to recognize these functions from source code extracting
    out key function parameters and then using these to select
    alternative implementations.

    As well as the data base of common functions a significant
    piece of expert system software would need to be written
    to extract knowledge out of the source.

    Do-able probably.

    Regards,

    --
    Walter Banks
    Byte Craft Limited
    http://www.bytecraft.com
     
    Walter Banks, Jan 12, 2010
    #5
  6. karthikbalaguru

    Walter Banks Guest

    karthikbalaguru wrote:

    > Is there a tool for C language that
    > could suggest an optimized/alternate
    > programming logic for the function that
    > is written ?
    >
    > The optimized/alternate logic can be
    > suggested as soon as we finish coding
    > for one function or it can be suggested
    > as soon as the code is compiled/parsed
    > by that tool.
    >
    > It will be even more helpful if that tool
    > also provides the cycle counts, cache
    > usage, cache misses and lines of code
    > also.
    >
    > It would be better if that tool has an
    > option to enable / disable this feature
    > either through compile time or some
    > other configurations.


    Metrics are available in many (especially embedded system)
    compilers as part of the listing and report files. Better
    compilers do a good job of instruction scheduling and
    cache management in their code generation.

    The issue is the larger one of function rewriting where
    the problem is larger and less work has been done
    looking for solutions.


    Regards,

    --
    Walter Banks
    Byte Craft Limited
    http://www.bytecraft.com
     
    Walter Banks, Jan 12, 2010
    #6
  7. karthikbalaguru

    Andy Guest

    On Jan 12, 11:12 am, scattered <> wrote:
    > I don't see why it would be impossible. Optimizing compilers exist and
    > by using similar techniques it should be possible to write a compiler
    > that uses C as both the source and target language. How useful this
    > would be is another question. The resulting code would need to be
    > humanly readable if the tool would be of any use and the would
    > probably place severe restrictions on the sorts of optimizations that
    > can be done. I would be surprised if no work along these lines has
    > been done.


    The optimizations would have to be limited to that subset that can be
    implemented at the C level. That might be difficult to do, since the
    optimization is not usually concerned with whether or not the
    optimized version can be portrayed in C.

    The generated C code would have to look similar (same variable names,
    etc.) to the original to be useful.

    And if the compiler can show you those optimizations in the form of
    modified code, why not have it skip showing you the code and just
    optimize it behind the scenes like it always does?

    Andy
     
    Andy, Jan 12, 2010
    #7
  8. On Jan 12, 11:03 pm, Walter Banks <> wrote:
    > karthikbalaguru wrote:
    > > Is there a tool for C language that
    > > could suggest an optimized/alternate
    > > programming logic for the function that
    > > is written ?

    >
    > > The optimized/alternate logic can be
    > > suggested as soon as we finish coding
    > > for one function or it can be suggested
    > > as soon as the code is compiled/parsed
    > > by that tool.

    >
    > > It will be even more helpful if that tool
    > > also provides the cycle counts, cache
    > > usage, cache misses and lines of code
    > > also.

    >
    > > It would be better if that tool has an
    > > option to enable / disable this feature
    > > either through compile time or some
    > > other configurations.

    >
    > Metrics are available in many (especially embedded system)
    > compilers as part of the listing and report files. Better
    > compilers do a good job of instruction scheduling and
    > cache management in their code generation.
    >


    Yes, many embedded system based
    compilers support the report generation
    of cache misses, cache usage and
    instruction cycles. I would like to
    convey that it would be better if the
    same tool provides those various
    optimization reports for both the
    logics apart from the optimized/
    alternate logic suggested by it.

    > The issue is the larger one of function rewriting where
    > the problem is larger and less work has been done
    > looking for solutions.
    >


    It is strange that no much research or
    work is done in this area ? Strange !!

    I think, this is one of the most required
    tool for efficient software development
    in any kind of platform.

    Thx in advans,
    Karthik Balaguru
     
    karthikbalaguru, Jan 12, 2010
    #8
  9. On Jan 12, 10:56 pm, Walter Banks <> wrote:
    > scattered wrote:
    > > On Jan 12, 11:04 am, acd <> wrote:

    >
    > > > (More) Programming Perls
    > > > and
    > > > Hacker's delight.

    >
    > ---------------------------------------
    >
    >
    >
    > > I don't see why it would be impossible. Optimizing compilers exist and
    > > by using similar techniques it should be possible to write a compiler
    > > that uses C as both the source and target language. How useful this
    > > would be is another question. The resulting code would need to be
    > > humanly readable if the tool would be of any use and the would
    > > probably place severe restrictions on the sorts of optimizations that
    > > can be done. I would be surprised if no work along these lines has
    > > been done.

    >
    > Programming Pearls and Hacker's delight are both must haves
    > even if you are only remotely interested programming algorithms.
    >
    > There has been quite a bit of work done in compilers at the
    > expression level to optimize algorithms and statements
    > implementing functionally equivalent statements in the
    > generated code.
    >


    True !

    > The problem in the bigger scale suggested by the op is the
    > ability to recognize the larger overview of the programming
    > objective at the scale of turning a bubble sort into a quick
    > sort.
    >


    Exactly, this is the actual problem that
    has to be addressed.

    > At the statement level recognizing functionality is generally
    > a simple task. At the function level this a significantly larger
    > problem.
    >
    > The solution may be mostly hard work and processing
    > cycles. A start may be to catalog common functions
    > and implementations and create a significant tool
    > to recognize these functions from source code extracting
    > out key function parameters and then using these to select
    > alternative implementations.
    >
    > As well as the data base of common functions a significant
    > piece of expert system software would need to be written
    > to extract knowledge out of the source.
    >
    > Do-able probably.
    >


    Thx in advans,
    Karthik Balaguru
     
    karthikbalaguru, Jan 12, 2010
    #9
  10. On Jan 13, 12:05 am, Andy <> wrote:
    > On Jan 12, 11:12 am, scattered <> wrote:
    >
    > > I don't see why it would be impossible. Optimizing compilers exist and
    > > by using similar techniques it should be possible to write a compiler
    > > that uses C as both the source and target language. How useful this
    > > would be is another question. The resulting code would need to be
    > > humanly readable if the tool would be of any use and the would
    > > probably place severe restrictions on the sorts of optimizations that
    > > can be done. I would be surprised if no work along these lines has
    > > been done.

    >
    > The optimizations would have to be limited to that subset that can be
    > implemented at the C level.


    True !

    > That might be difficult to do, since the
    > optimization is not usually concerned with whether or not the
    > optimized version can be portrayed in C.
    >


    True, but i am looking only at the
    C level optimization.

    > The generated C code would have to look similar (same variable names,
    > etc.) to the original to be useful.
    >


    I think, in such scenarios, the tool should
    be having tremendous knowledge about
    the software/program and take care
    end to end. Maybe, the tool can generate
    report on the changes and the reason for
    the changes so the developer can use
    it for further developments or any other
    maintenance activities on that code.

    > And if the compiler can show you those optimizations in the form of
    > modified code, why not have it skip showing you the code and just
    > optimize it behind the scenes like it always does?
    >


    Maybe, it would be better if it
    can do it before user rather than
    behind the scenes so that the user
    is aware of the kind of optimzations
    that are being done and could be
    taken care. It is also needed so that
    the developer will be able to take care
    of further developments on the same
    program/software and also for the
    maintenance activities on that
    program/software.

    Thx in advans,
    Karthik Balaguru
     
    karthikbalaguru, Jan 12, 2010
    #10
  11. On Jan 12, 9:12 am, scattered <> wrote:

    > I don't see why it would be impossible. Optimizing compilers exist and
    > by using similar techniques it should be possible to write a compiler
    > that uses C as both the source and target language. How useful this
    > would be is another question. The resulting code would need to be
    > humanly readable if the tool would be of any use and the would
    > probably place severe restrictions on the sorts of optimizations that
    > can be done. I would be surprised if no work along these lines has
    > been done.


    That would be a useless tool, all it would do would be obfuscate. If
    the code contains optimizations that can be made by machine, what is
    the point of modifying the source code? Let the machine make the
    optimizations when the code is compiled and keep the source intact.

    DS
     
    David Schwartz, Jan 12, 2010
    #11
  12. Re: A tool that suggests optimized logic for a piece of code/module/function

    On 2010-01-12, David Schwartz <> wrote:
    > On Jan 12, 9:12 am, scattered <> wrote:
    >
    >> I don't see why it would be impossible. Optimizing compilers exist and
    >> by using similar techniques it should be possible to write a compiler
    >> that uses C as both the source and target language. How useful this
    >> would be is another question. The resulting code would need to be
    >> humanly readable if the tool would be of any use and the would
    >> probably place severe restrictions on the sorts of optimizations that
    >> can be done. I would be surprised if no work along these lines has
    >> been done.

    >
    > That would be a useless tool, all it would do would be obfuscate. If
    > the code contains optimizations that can be made by machine, what is
    > the point of modifying the source code? Let the machine make the
    > optimizations when the code is compiled and keep the source intact.
    >
    > DS


    The idea would be that it could provide suggestions, not necessarily
    implement them or even come up with a concrete solution. Even something
    as simple as highlighting a function as "O(n^3)" would be helpful.

    Saying something like "this looks like a Bubblesort" and linking to a
    database (or wiki link) of sorting algorithms would also be nice, even
    if the machine didn't understand the data structures or nature of the
    data well enough to help.
     
    Andrew Poelstra, Jan 12, 2010
    #12
  13. karthikbalaguru

    Jasen Betts Guest

    On 2010-01-11, karthikbalaguru <> wrote:
    > Hi,
    > There are certain editors that highlight
    > the syntax/color for datatypes/variables
    > or comments etc.
    >
    > Similarly,
    > Is there a tool for C language that
    > could suggest an optimized/alternate
    > programming logic for the function that
    > is written ?
    >
    > The optimized/alternate logic can be
    > suggested as soon as we finish coding
    > for one function or it can be suggested
    > as soon as the code is compiled/parsed
    > by that tool.
    >
    > It will be even more helpful if that tool
    > also provides the cycle counts, cache
    > usage, cache misses and lines of code
    > also.
    >
    > It would be better if that tool has an
    > option to enable / disable this feature
    > either through compile time or some
    > other configurations.
    >
    > Any ideas ?


    you seem to be asking for a compiler that is
    tightly bopund to an editor, (which seems contrary to the unix
    philosophy) such compiler is likely to optimise worse than GCC.

    Tweaked C code is likely to only work well on a single architecture.

    optimising compilers often alter the order in which statements are
    executed etc...

    If you really want to optimise for a single architecture
    you should probably be coding in assembler anyway.






    > Thx in advans,
    > Karthik Balaguru



    --- news://freenews.netfront.net/ - complaints: ---
     
    Jasen Betts, Jan 12, 2010
    #13
  14. karthikbalaguru

    Stefan Ram Guest

    Re: A tool that suggests optimized logic for a piece of code/module/function

    karthikbalaguru <> writes:
    >Similarly,
    >Is there a tool for C language that
    >could suggest an optimized/alternate
    >programming logic for the function that
    >is written ?


    I have not read the whole thread, so, I am sorry,
    if this was already mentioned:

    http://www.supercompilers.com/white_paper.shtml
     
    Stefan Ram, Jan 13, 2010
    #14
  15. karthikbalaguru

    Rich Webb Guest

    Re: A tool that suggests optimized logic for a piece of code/module/function

    On Tue, 12 Jan 2010 13:34:11 -0800 (PST), David Schwartz
    <> wrote:

    >On Jan 12, 9:12 am, scattered <> wrote:
    >
    >> I don't see why it would be impossible. Optimizing compilers exist and
    >> by using similar techniques it should be possible to write a compiler
    >> that uses C as both the source and target language. How useful this
    >> would be is another question. The resulting code would need to be
    >> humanly readable if the tool would be of any use and the would
    >> probably place severe restrictions on the sorts of optimizations that
    >> can be done. I would be surprised if no work along these lines has
    >> been done.

    >
    >That would be a useless tool, all it would do would be obfuscate. If
    >the code contains optimizations that can be made by machine, what is
    >the point of modifying the source code? Let the machine make the
    >optimizations when the code is compiled and keep the source intact.


    What he's looking for is not compiler optimizations but optimization of
    the underlying algorithm. As somebody else mentioned, seeing a bubble
    sort and deciding that a quick sort would be more appropriate.

    --
    Rich Webb Norfolk, VA
     
    Rich Webb, Jan 13, 2010
    #15
  16. Re: A tool that suggests optimized logic for a piece of code/module/function

    Rich Webb <> writes:
    > On Tue, 12 Jan 2010 13:34:11 -0800 (PST), David Schwartz
    > <> wrote:
    >>On Jan 12, 9:12 am, scattered <> wrote:
    >>> I don't see why it would be impossible. Optimizing compilers exist and
    >>> by using similar techniques it should be possible to write a compiler
    >>> that uses C as both the source and target language. How useful this
    >>> would be is another question. The resulting code would need to be
    >>> humanly readable if the tool would be of any use and the would
    >>> probably place severe restrictions on the sorts of optimizations that
    >>> can be done. I would be surprised if no work along these lines has
    >>> been done.

    >>
    >>That would be a useless tool, all it would do would be obfuscate. If
    >>the code contains optimizations that can be made by machine, what is
    >>the point of modifying the source code? Let the machine make the
    >>optimizations when the code is compiled and keep the source intact.

    >
    > What he's looking for is not compiler optimizations but optimization of
    > the underlying algorithm. As somebody else mentioned, seeing a bubble
    > sort and deciding that a quick sort would be more appropriate.


    Of course, that particular example is not terribly useful in practice,
    since it's easy enough to just not write a bubble sort in the first
    place. But it's a good as an example because it's easy to understand.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, Jan 13, 2010
    #16
  17. karthikbalaguru

    Ed Prochak Guest

    On Jan 12, 3:19 pm, karthikbalaguru <>
    wrote:
    > On Jan 13, 12:05 am, Andy <> wrote:
    >
    > > On Jan 12, 11:12 am, scattered <> wrote:

    >
    > > > I don't see why it would be impossible. Optimizing compilers exist and
    > > > by using similar techniques it should be possible to write a compiler
    > > > that uses C as both the source and target language. How useful this
    > > > would be is another question. The resulting code would need to be
    > > > humanly readable if the tool would be of any use and the would
    > > > probably place severe restrictions on the sorts of optimizations that
    > > > can be done. I would be surprised if no work along these lines has
    > > > been done.

    >
    > > The optimizations would have to be limited to that subset that can be
    > > implemented at the C level.

    >
    > True !
    >
    > > That might be difficult to do, since the
    > > optimization is not usually concerned with whether or not the
    > > optimized version can be portrayed in C.

    >
    > True, but i am looking only at the
    > C level optimization.
    >
    > > The generated C code would have to look similar (same variable names,
    > > etc.) to the original to be useful.

    >
    > I think, in such scenarios, the tool should
    > be having tremendous knowledge about
    > the software/program and take care
    > end to end. Maybe, the tool can generate
    > report on the changes and the reason for
    > the changes so the developer can use
    > it for further developments or any other
    > maintenance activities on that code.
    >
    > > And if the compiler can show you those optimizations in the form of
    > > modified code, why not have it skip showing you the code and just
    > > optimize it behind the scenes like it always does?

    >
    > Maybe, it would be better if it
    > can do it before user rather than
    > behind the scenes so that the user
    > is aware of the kind of optimzations
    > that are being done and could be
    > taken care. It is also needed so that
    > the developer will be able to take care
    > of further developments on the same
    > program/software and also for the
    > maintenance activities on that
    > program/software.
    >
    > Thx in advans,
    > Karthik Balaguru


    There is such a tool. It is called a code review.
     
    Ed Prochak, Jan 13, 2010
    #17
  18. Re: A tool that suggests optimized logic for a piece of code/module/function

    On Tue, 12 Jan 2010 11:12:18 -0800 (PST), karthikbalaguru
    <> wrote:

    >On Jan 12, 11:03 pm, Walter Banks <> wrote:


    >> The issue is the larger one of function rewriting where
    >> the problem is larger and less work has been done
    >> looking for solutions.
    >>

    >
    >It is strange that no much research or
    >work is done in this area ? Strange !!
    >
    >I think, this is one of the most required
    >tool for efficient software development
    >in any kind of platform.


    If the problem on average is badly trained programmers, the obvious
    solution should be improving the training of programmers.

    A tool that points out suboptimal constructs etc. might be useful in
    the training phase, but what is the point of using it in actual
    program production ?
     
    Paul Keinanen, Jan 13, 2010
    #18
  19. Re: A tool that suggests optimized logic for a piece of code/module/function

    Paul Keinanen <> writes:

    >If the problem on average is badly trained programmers, the obvious
    >solution should be improving the training of programmers.


    >A tool that points out suboptimal constructs etc. might be useful in
    >the training phase, but what is the point of using it in actual
    >program production ?


    If sufficiently sophisticated it could be used as a regression tester
    for code submitted to a revision system.

    This presumes, however, that it's better to have "optimal" source code
    than to have readble/expressive source code.

    --
    Chris.
     
    Chris McDonald, Jan 13, 2010
    #19
  20. karthikbalaguru

    Phil Carmody Guest

    Re: A tool that suggests optimized logic for a piece of code/module/function

    Rich Webb <> writes:
    > On Tue, 12 Jan 2010 13:34:11 -0800 (PST), David Schwartz
    > <> wrote:
    >
    >>On Jan 12, 9:12 am, scattered <> wrote:
    >>
    >>> I don't see why it would be impossible. Optimizing compilers exist and
    >>> by using similar techniques it should be possible to write a compiler
    >>> that uses C as both the source and target language. How useful this
    >>> would be is another question. The resulting code would need to be
    >>> humanly readable if the tool would be of any use and the would
    >>> probably place severe restrictions on the sorts of optimizations that
    >>> can be done. I would be surprised if no work along these lines has
    >>> been done.

    >>
    >>That would be a useless tool, all it would do would be obfuscate. If
    >>the code contains optimizations that can be made by machine, what is
    >>the point of modifying the source code? Let the machine make the
    >>optimizations when the code is compiled and keep the source intact.

    >
    > What he's looking for is not compiler optimizations but optimization of
    > the underlying algorithm. As somebody else mentioned, seeing a bubble
    > sort and deciding that a quick sort would be more appropriate.


    Unless it was only ever a handful of items, in which case an
    insertion sort might be more appropriate. Know your N (most
    important when N might be large, of course, but also when it's
    small). However, anything which brings about the nuking of
    bubblesort in any context is an improvement.

    Phil
    --
    Any true emperor never needs to wear clothes. -- Devany on r.a.s.f1
     
    Phil Carmody, Jan 13, 2010
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Phin
    Replies:
    2
    Views:
    468
    =?Utf-8?B?ZGhucml2ZXJzaWRl?=
    Jun 2, 2005
  2. Pat

    I need suggests

    Pat, Jan 23, 2007, in forum: Python
    Replies:
    3
    Views:
    292
    Laurent Pointal
    Jan 23, 2007
  3. Phin

    "Google Suggests" and the AJAX .NET Wrapper?

    Phin, Jun 1, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    121
    dhnriverside
    Jun 2, 2005
  4. Patrick Plattes

    Download a file piece by piece

    Patrick Plattes, Nov 30, 2006, in forum: Ruby
    Replies:
    2
    Views:
    215
    Patrick Plattes
    Nov 30, 2006
  5. Jake Barnes
    Replies:
    4
    Views:
    116
    Thomas 'PointedEars' Lahn
    Jan 8, 2006
Loading...

Share This Page