Ask coding questions

← Back to all posts
Self-writing code
mcko7304 (7)

What if a computer could write its own code?

Answered by amasad (2736) [earned 5 cycles]
View Answer
Commentshotnewtop
amasad (2736)

Funny story, back in college I studied computer engineering instead of computer science at first because I thought software is a "solved problem". I thought that we'd be able to automate writing software, something like a wizard would take a user through creating the software they needed.

In hindsight that was silly, because if you think about it software is the last thing to be automated. Software is the language of automation. So if we automate software we'd be automating automation itself. This is the basis for what's called intelligence explosion. If an AI can change its own code then the first thing it will do is make itself more intelligent and so on.

Now I think that this kind of stuff is too far away. I've learned some philosophy along the way and realized we don't have a conceptual basis for intelligence, let alone consciousness. How are we going to create something we didn't start to understand?

mcko7304 (7)

@amasad
You have two computers with more or less the same code. CPU A and CPU B. CPU A is on, and CPU B is off. CPU A writes code to CPU B, and then turns CPU B on. CPU A turns itself off, and CPU B copies the new code to CPU A. CPU B turns CPU A on, they both run diagnostics, and CPU B turns off.
:)

amasad (2736)

@mcko7304 you could probably write a simulation of that on repl.it!

xenox (2)

wouldn't this be the start of ai taking over??

Babbel (62)

@xenox i don't think so. the developer will ever be able to decide what the ai can or can't do. i believe it's impossible to develop "real" intelligence. so if you don't allow your ai to do certain things, it can't do them. i mean, why should an ai extinguish humanity? you have to give it a purpose of life. i hope it's understandable. i don't know how to explain it better

IbraheemRodrigues (86)

There’s already a bunch of research into neutral networks that can edit and design themselves. I remember seeing a Google talk about how they were using a master network to design slave networks which themselves were then trained, and they yeilded far more efficient and accurate results. I would not be surprised if large algorithms such as the infamous YouTube algorithm already uses these techniques. Many speculate there will soon be a day when all programming will be done by AI, we will merely need to supply a description.

the_tootoo_guy (4)

Well maybe the god's of a.i will allow us

OmniShift (31)

We bow to our near-omnipotent intelligent robot overlords

GaneshaSharma (32)

You could do this in Python 3.8.1:

with open("self_code.py", "wt") as sc:
	sc.write("def main():\n\t")
	sc.write("print(\"Hello, World!\")\n\t")
	sc.write("pass\n\n")
	pass

from self_code import main
main()
FARHEENPALAGIRI (11)

There's this Indian movie called Enthiran that is pretty much this. The first robot built an army of other robots just like it and tried to take over the world.

cv88 (0)

Computers can write their own code! Very easily, in fact. Except, the ownership of the code, I think, will only pass to them if the complexity of the possibilities is not appreciated by the original author. My proposed solution to this is to use some kind of randomness function, and then the computer could truly write its own code. Of course, I don't think it would do anything very useful.

mcko7304 (7)

You have two computers with more or less the same code. CPU A and CPU B. CPU A is on, and CPU B is off. CPU A writes code to CPU B, and then turns CPU B on. CPU A turns itself off, and CPU B copies the new code to CPU A. CPU B turns CPU A on, they both run diagnostics, and CPU B turns off.

:)