thinking in an auto way
Don't repeat yourself
When you are coding, remember that never do same thing twice. For example you want indent some lines.
1 | auto main() -> int |
Never move to line 3, keypress 4 spaces and move to line 4, keypress 4 space again.
Use vi, there are many ways
- move to line 3,
shift venter vi visual mode,jselect line 4,shift >to increase indent - move to line 3,
shift venter vi visual mode,:normal iand press 4 spaces and enter - move to line 3,
shift venter vi visual mode,shift >and then move to line 4, press. - move to line 3,
ctrl vblock select, andjto select next line,shift ito insert 4 spaces,esc
Also, you can use awk and sed to achieve the same effects.
Actions on the code
Actions on the code, or code transformations, is a serial's operations on the code. Record all operations into tape, called macro, and the macro can be applied to some other places, mapping the code from origin state to desired state.
Operation space
All possible operations compose an Action space. AI should learn to choice some actions, transform the code to a stable state, a state may be pass compile or pass unit test. If AI can do this, we call it auto coding.
Learning from history and some basic rules
Bayesian learning
We init some prior rules to the bot. He will update the prior with posterior.
Reinforcement Learning
Use some reinforcement strategies to perform better actions on the code.
Interactive with human
Consider the indent example above, when I indent line 3, bot help me indent line 4, is it stable? Yes, done!