Programming Helper: Get Code with Loops & Conditionals

  • Thread starter Bartholomew
  • Start date
  • Tags
    Programming
In summary, the speakers are discussing the idea of creating a program that can generate code by "guessing" at the desired output based on input and then suggest alterations to the code. They mention the potential use of evolutionary computing and question if such a program already exists. They also discuss the potential implications of such a program on the role of professional programmers. The conversation then shifts to the possibility of using a debugger or AI to assist with code writing and debugging, and the limitations of determining patterns from limited data.
  • #1
Bartholomew
527
0
I'm writing a complicated Java program (for me, at least) and getting some bugs. I thought of something: why not have a program that can "guess" at the code you want if you step it through for test input and tell it what output you want at various stages? It could come up with likely code which would produce the answer you said and you would check to make sure. It would produce code as variations on simple looping and conditonal structures and if you wanted something more complicated (like for example if you wanted to use a library function) you would just write that line yourself and it would help fill in the blanks. Because looping and conditional structures are so predictable--if you had a human who looked at input and output with the information that they were built around loops and conditional structures, the human could probably figure out what was going on--I don't think it would be impractical to make a program that could do this. It could practically do it just by guessing--you could use evolutionary computing. Has someone already made this thing?
 
Computer science news on Phys.org
  • #2
Hey good idea.. In fact why don't you write a program that writes code for you! :rofl: :cool:
 
  • #3
I guess I really mean more of a debugging tool than actually writing the program. I mean, like, say you have a variable that has to be kept at a certain value in various places in the code which otherwise works. You would tell the helper what you wanted the variable to be and at what times, and what information in general contributes to the variable being this value, and it would suggest alterations to your code that could produce the results you said.

Edit: (reply to Anttech) Well, wouldn't it be an efficiency gain if you had programs that could mostly write other programs?

(Of course, this might render many professional programmers obsolete... maybe not such a good idea to have it write everything)
 
Last edited:
  • #4
This is easy to do. Just build a big table that contains every possible input and the corresponding output. Then all your program has to do is read in the input, look up the output in the table and then write out the output.
 
  • #5
You might do that as a last resort but it would require a lot of human work to match inputs and outputs! The helper should suggest with greater priority the code constructs it finds that are shorter but still work, so it should not suggest the table approach often.
 
  • #6
Bartholomew said:
I guess I really mean more of a debugging tool than actually writing the program. I mean, like, say you have a variable that has to be kept at a certain value in various places in the code which otherwise works.

Then why don't you just say x = whatever where you want that variable to take on that "certain value"
 
  • #7
Bartholomew said:
You might do that as a last resort but it would require a lot of human work to match inputs and outputs! The helper should suggest with greater priority the code constructs it finds that are shorter but still work, so it should not suggest the table approach often.

If you don't supply the computer with all the inputs and outputs, then how is it supposed to know what works? You can't just give the computer a few samples and expect it to pick out a pattern. Even a human requires an enormous amount of information in order to perform useful pattern matching.
 
  • #8
Not true--for example, "find the pattern" puzzles usually only give you four or five numbers and from that you can figure out a likely pattern. Computers are fully capable of writing code given examples of what it should do. In fact, a few years ago I remember reading about a program that used evolutionary computing to write a program to control a prosthetic thumb. Of course, that one DID have a huge amount of input-output examples to work on, but that application dealt with "real-world" data. If all you want your computer to do for you is make appropriate basic looping/conditional statements, it probably wouldn't require as many examples.
 
  • #9
Bartholomew said:
Edit: (reply to Anttech) Well, wouldn't it be an efficiency gain if you had programs that could mostly write other programs?

(Of course, this might render many professional programmers obsolete... maybe not such a good idea to have it write everything)

Depends on how "efficient" the program is that writes your programs... Software Engineering is exactly that... You engineer solutions to a remite u are given... Now for an application to do this for you is in the relms of AI...

Most Debuggers will corect syntax for you AFAIK
 
  • #10
Bartholomew said:
Not true--for example, "find the pattern" puzzles usually only give you four or five numbers and from that you can figure out a likely pattern. Computers are fully capable of writing code given examples of what it should do. In fact, a few years ago I remember reading about a program that used evolutionary computing to write a program to control a prosthetic thumb. Of course, that one DID have a huge amount of input-output examples to work on, but that application dealt with "real-world" data. If all you want your computer to do for you is make appropriate basic looping/conditional statements, it probably wouldn't require as many examples.

Only the most trivial of patterns can be determined from just a few inputs. And you certainly can't demonstrate that computers can make intelligent inferences from small amounts of data by citing an example that uses massive amounts of data to teach the system. And controlling a thumb is a relatively simple task compared to writing a program.

There really aren't very many cases where people can figure out the solution to a problem given a small amount of information, so it certainly isn't reasonable to expect a computer program to do the same thing. There are a lot of times when people seem to solve a problem given only a few bits of information; but this is only possible because humans carry around a staggering amount of context information that computers don't understand.
 
  • #11
"They will invent self spelling wands before they..."Mr.Weasly(Harry Potter)

As for the debugging idea.You can make some print statements or use the standard debbuger.
I usually spend hours looking for logical errors in my code.
 
Last edited:
  • #12
The reason I mentioned the prosthetic thumb controller was that it actually did generate code. It wasn't just a neural net; it actually came up with a code solution.

Programs tend to be much simpler than real-world systems. They tend to be linear and they are always very clear-cut. The task of finding a possible solution is further simplified because the programmer can point out necessary relations between the variables so that suggested solutions which do not incorporate those relations can be discarded.
 
  • #13
Bartholomew said:
Programs tend to be much simpler than real-world systems. They tend to be linear and they are always very clear-cut.

Parts of most programs are clear-cut and linear. Most programs as a whole are very non-linear and very fuzzy. A computer would have to only look at very small portions of the program to do any useful reasoning.

Bartholomew said:
The task of finding a possible solution is further simplified because the programmer can point out necessary relations between the variables so that suggested solutions which do not incorporate those relations can be discarded.

You would most likely have to spend more time teaching the computer about the relationships between variables than you would have had to spend if you just wrote the program yourself.

If you have a large number of variables than using the computer to solve the problem is too computationally intensive. The interactions are just too complex for the very linear computer to understand.

If you have only a few variables then the amount of time it takes you to just type out the code should be negligible. How did you plan to make it easier to tell the computer about relations between variables instead of just writing code?
 
  • #14
A computer would have to only look at very small portions of the program to do any useful reasoning.

Well, you'd be intended to point the computer in the direction of what lines are questionable.

But I guess this would be most practical as a debugging tool rather than as a from-scratch program writer. You could say that such-and-such a variable has the wrong value at such-and-such a point and also at such-and-such a point, tell the computer what its values _should_ be at those points, and the computer would determine where it was modified and by what and generate possible ways to correct it while keeping mostly unmodified what you had already written. If the variable depends on the use of external functions, the programming helper could look at those functions just as it would look at any other code (except this code would be unalterable) and on the basis of that suggest ways to alter how you use them.
 
  • #15
Bartholomew said:
But I guess this would be most practical as a debugging tool rather than as a from-scratch program writer. You could say that such-and-such a variable has the wrong value at such-and-such a point and also at such-and-such a point, tell the computer what its values _should_ be at those points, and the computer would determine where it was modified and by what and generate possible ways to correct it while keeping mostly unmodified what you had already written. If the variable depends on the use of external functions, the programming helper could look at those functions just as it would look at any other code (except this code would be unalterable) and on the basis of that suggest ways to alter how you use them.

That's a much more reasonable suggestion. I'm still not certain that such a program would really be helpful...I can't think of very many situations where something like that would have been useful to me...but it might have some uses in more specific applications.

External functions would still be quite a problem, since there's no limit to the amount of side effects they can have. You would have to provide the program with assurances about what outside functions will and won't change.
 

What is "Programming Helper: Get Code with Loops & Conditionals"?

"Programming Helper: Get Code with Loops & Conditionals" is a tool designed to assist programmers in writing code using loops and conditionals. It provides pre-written code snippets that can be easily customized and inserted into a larger code base, saving time and reducing errors.

How does "Programming Helper: Get Code with Loops & Conditionals" work?

The tool works by allowing the user to select from a variety of common programming tasks, such as iterating through a list or implementing a conditional statement. The user can then customize parameters and options, and the tool will generate the corresponding code that can be copied and pasted into their project.

Is "Programming Helper: Get Code with Loops & Conditionals" suitable for all programming languages?

No, the tool is designed for specific programming languages and may not be suitable for all languages. Currently, it supports popular languages such as Java, Python, and JavaScript, but it may expand to include more languages in the future.

Is "Programming Helper: Get Code with Loops & Conditionals" a replacement for learning how to code?

No, the tool is meant to assist and enhance the coding process but is not a replacement for learning how to code. It is important to have a thorough understanding of programming concepts and syntax to effectively use the tool and write quality code.

Is "Programming Helper: Get Code with Loops & Conditionals" a free tool?

Yes, "Programming Helper: Get Code with Loops & Conditionals" is a free tool available for anyone to use. However, there may be premium features or subscriptions available for advanced users or teams.

Similar threads

  • Computing and Technology
Replies
2
Views
703
  • Computing and Technology
Replies
9
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
Replies
15
Views
4K
  • Programming and Computer Science
Replies
6
Views
1K
Replies
11
Views
2K
  • Programming and Computer Science
Replies
18
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
2
Views
944
Back
Top