Kernel
module? What would change if all the things currently defined on Kernel
were defined on Object
, and there were no such module as Kernel
?Kernel
or on Object
?It is the core that provides basic services for all other parts of the OS. It is the main layer between the OS and underlying computer hardware, and it helps with tasks such as process and memory management, file systems, device control and networking.
Definition. The kernel is the most important part of the operating system. It is the primary interface between the hardware and the processes of a computer. The kernel connects these two in order to adjust resources as effectively as possible.
The kernel is a computer program at the core of a computer's operating system and generally has complete control over everything in the system. It is the portion of the operating system code that is always resident in memory and facilitates interactions between hardware and software components.
I'll start with a question: what would self
be inside a typical Kernel
method such as puts
? The closest thing to a meaningful self
inside puts
would probably be the Ruby runtime itself. Similarly for other "methods that really want to be functions" like Array
or fork
. So you can look at Kernel
as a dumping ground for methods that are, more or less, commands or messages to Ruby itself.
Kernel
also has odd methods like sub
and chop
that are really only useful for one-off ruby -e
scripts. These things tend to use $_
as an implied self
but I think they can be considered as special cases of the "commands to the Ruby runtime" as above.
Where does a method go when you want to be able to call that method on any object? I'd say that it would go into Object
. If the method is really a function in disguise and has no meaningful self
, then it would go into Kernel
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With