Generator
A generator is a device which is used to produce or generate anything. It has capability to take output from any source and then convert this energy to work and hence produce output in any useful form. A generator may produce electricity, data, any particular code, language etc.
Generator in terms of computer science is a special routine which is used to control iterative behavior of loop. They are invoked inside the loops. When generator invocation stage is reached then iterator object encapsulates the state of generator and it executes until loop is not terminated.
Code generator is a special program which is used to convert high level language into a stream of instructions that can be executed by machine easily. Here input for generators are high level languages and output is assembly languages or sometimes may be low level languages. Code generation occurs at run time of program.
In terms of electric science generator is that device which is used to produce electricity. It takes input from any mechanical energy source. Dynamo was the first electrical generator which uses electromagnetic principles to convert mechanical energy to electric energy. It was based on Faraday’s principle.