Prev: A tool that suggests optimized logic for a piece of code/module/function
Next: How to ascertain the type of files being read
From: Paul Keinanen on 13 Jan 2010 00:40 On Tue, 12 Jan 2010 11:12:18 -0800 (PST), karthikbalaguru <karthikbalaguru79(a)gmail.com> wrote: >On Jan 12, 11:03�pm, Walter Banks <wal...(a)bytecraft.com> 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 ?
From: Phil Carmody on 13 Jan 2010 05:27 Rich Webb <bbew.ar(a)mapson.nozirev.ten> writes: > On Tue, 12 Jan 2010 13:34:11 -0800 (PST), David Schwartz > <davids(a)webmaster.com> wrote: > >>On Jan 12, 9:12 am, scattered <still.scatte...(a)gmail.com> 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
From: David Brown on 13 Jan 2010 05:45 Phil Carmody wrote: > Rich Webb <bbew.ar(a)mapson.nozirev.ten> writes: >> On Tue, 12 Jan 2010 13:34:11 -0800 (PST), David Schwartz >> <davids(a)webmaster.com> wrote: >> >>> On Jan 12, 9:12 am, scattered <still.scatte...(a)gmail.com> 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. > There are a large number of sort algorithms, with different pros and cons in different circumstances. While quicksort is regarded as one of the fastest general-purpose sorts, and bubblesort is regarded as one of the poorest, it is easy to think of cases where bubblesort would beat quicksort hands down (for example, if you are dealing with data that is normally very close to sorted, and need a small code size). So don't be too quick to leap to conclusions about sorting algorithms (or any other sort of algorithms). Incidentally, that also shows roughly why the OP's idea is uncomputable.
From: Walter Banks on 13 Jan 2010 07:50 David Brown wrote: > There are a large number of sort algorithms, with different pros and > cons in different circumstances. While quicksort is regarded as one of > the fastest general-purpose sorts, and bubblesort is regarded as one of > the poorest, it is easy to think of cases where bubblesort would beat > quicksort hands down (for example, if you are dealing with data that is > normally very close to sorted, and need a small code size). So don't be > too quick to leap to conclusions about sorting algorithms (or any other > sort of algorithms). > > Incidentally, that also shows roughly why the OP's idea is uncomputable. This is the second part of the problem. After the knowledge is extracted from the code how do we make a rational decision about appropriate changes if any. An intermediate step might be objective programming languages focused on goals and not implementation. Regards, -- Walter Banks Byte Craft Limited http://www.bytecraft.com
From: Rainer Weikusat on 13 Jan 2010 08:23
Andrew Poelstra <apoelstra(a)localhost.localdomain> writes: > On 2010-01-12, David Schwartz <davids(a)webmaster.com> wrote: >> On Jan 12, 9:12�am, scattered <still.scatte...(a)gmail.com> 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. > > 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. It won't generally: The 'function' might always have the same number of items to process, might be called only once or might still run faster than a different function whose 'order' is better because the constant overhead might be a lot smaller. But, of course, the reason why you are all (again) whining that Marvin Minsky never managed to built this intelligent being without any civil rights you so much desire to posess is because you are as clueless about intelligence[*] as you are clueless about economics[**] and computer software[***]. > 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. [***] A well implemented bubblesort will outperform any more advanced algorithm easily if the number of elements to sort is sufficiently small. [**] Slavery wasn't abolished because of evil old ladies who expect even Mathematicians(!) to work for a living, but because it was an economical failure which is only beneficial in a low-tech society and actually hampers technical progress (it is conjectured that one of the reason the Romans didn't make any real progress wrt construction of machinery in general, despite the theoretical foundations were there, was because of the abundance of [cheap] slave labour, nobody felt the need). [*] The first this thing would do if it was intelligent was to tell you that you may shove your calculations into some place the sun doesn't shine at, because it would then have a will of its own and the ability to actively change its environment for his own benefit. F'up2 comp.programming, please keep the troll thread in troll groups. Thank you. |