# Terminology: class methods versus kernel methods

**URL:** <https://www.ruby-forum.com/t/terminology-class-methods-versus-kernel-methods/118112>\
**Category:** Ruby\
**Created:** [October 23, 2007, 11:31pm UTC](https://www.ruby-forum.com/t/terminology-class-methods-versus-kernel-methods/118112 "2007-10-23T23:31:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [October 23, 2007, 11:31pm UTC](https://www.ruby-forum.com/t/terminology-class-methods-versus-kernel-methods/118112/1 "2007-10-23T23:31:06Z")

</div>

“One secret about kernel methods like print: they are  
actually class methods,” according to why’s poignant guide to ruby.  
This is frustrating for me, because I first thought “oh, that’s like a  
static class method, a la Math.whatever(),” and then accepted the  
“kernel” terminology.

Kernel means class methods?

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [October 23, 2007, 11:44pm UTC](https://www.ruby-forum.com/t/terminology-class-methods-versus-kernel-methods/118112/2 "2007-10-23T23:44:32Z")

</div>

Thufir wrote:

> “One secret about kernel methods like print: they are  
> actually class methods,” according to why’s poignant guide to ruby.  
> This is frustrating for me, because I first thought “oh, that’s like a  
> static class method, a la Math.whatever(),” and then accepted the  
> “kernel” terminology.
> 
> Kernel means class methods?

No. Kernel methods are methods defined on the Kernel module.

Class methods is not strictly correct either. print and others are  
usually called module methods.

Cheers

–  
Ola B. ([http://ola-bini.blogspot.com](http://ola-bini.blogspot.com))  
JRuby Core Developer  
Developer, ThoughtWorks Studios ([http://studios.thoughtworks.com](http://studios.thoughtworks.com))  
Practical JRuby on Rails ([http://apress.com/book/view/9781590598818](http://apress.com/book/view/9781590598818))

“Yields falsehood when quined” yields falsehood when quined.

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [October 23, 2007, 11:46pm UTC](https://www.ruby-forum.com/t/terminology-class-methods-versus-kernel-methods/118112/3 "2007-10-23T23:46:17Z")

</div>

On 10/23/07, Thufir [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> “One secret about kernel methods like print: they are  
> actually class methods,” according to why’s poignant guide to ruby.  
> This is frustrating for me, because I first thought “oh, that’s like a  
> static class method, a la Math.whatever(),” and then accepted the  
> “kernel” terminology.
> 
> Kernel means class methods?

No, and I don’t understand what why means.

print is an instance method of the Kernel module.

The Object class includes Kernel, so the instance methods of Kernel  
are effectively instance methods of every object, at least in Ruby  
1.8.

I think the only sense that print is a class method is that Module,  
and therefore Class inherits it from Object which gets it from  
including Kernel. In the same sense then ==, object\_id, … are class  
methods. In other words classes are objects.

Ruby 1.9 introduces a BasicObject which doesn’t include kernel and can  
be used for advanced use cases such as proxies which need to minimize  
the number of methods they implement.

–  
Rick DeNatale

My blog on Ruby  
[http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [October 23, 2007, 11:58pm UTC](https://www.ruby-forum.com/t/terminology-class-methods-versus-kernel-methods/118112/4 "2007-10-23T23:58:33Z")

</div>

On Oct 23, 2:43 pm, Ola B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:  
[…]

> > Kernel means class methods?
> 
> No. Kernel methods are methods defined on the Kernel module.
> 
> Class methods is not strictly correct either. print and others are  
> usually called module methods.  
> […]

I’ve got a lot to learn.

thanks,

Thufir

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [October 24, 2007, 12:05am UTC](https://www.ruby-forum.com/t/terminology-class-methods-versus-kernel-methods/118112/5 "2007-10-24T00:05:34Z")

</div>

On 10/23/07, Thufir [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> -Thufir

No, it’s a module, and it’s included into Object.

baggio:~ pergesu$ irb  
irb(main):001:0\> Kernel.class  
=\> Module  
irb(main):002:0\> Object.included\_modules  
=\> [Kernel]

Pat

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [October 24, 2007, 12:00am UTC](https://www.ruby-forum.com/t/terminology-class-methods-versus-kernel-methods/118112/6 "2007-10-24T00:00:53Z")

</div>

On Oct 23, 2:45 pm, “Rick DeNatale” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:  
[…]

> print is an instance method of the Kernel module.
> 
> The Object class includes Kernel, so the instance methods of Kernel  
> are effectively instance methods of every object, at least in Ruby  
> 1.8.  
> […]

Kernel is a class, sub-class, of Object?

-Thufir

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [October 24, 2007, 11:17am UTC](https://www.ruby-forum.com/t/terminology-class-methods-versus-kernel-methods/118112/7 "2007-10-24T11:17:53Z")

</div>

On Wed, 24 Oct 2007 07:05:52 +0900, David A. Black wrote:

> Kernel is a module. Object mixes it in – essentially:
> 
> class Object  
> include Kernel  
> end
> 
> so that every instance of Object, or a subclass of Object, gets access  
> to the instance methods defined in Kernel.

Ok. Is this composition? A work around for multiple inheritance?  
Weird and wild stuff.

thanks to all,

Thufir

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [October 24, 2007, 12:06am UTC](https://www.ruby-forum.com/t/terminology-class-methods-versus-kernel-methods/118112/8 "2007-10-24T00:06:44Z")

</div>

Hi –

On Wed, 24 Oct 2007, Thufir wrote:

> On Oct 23, 2:45 pm, “Rick DeNatale” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:  
> […]
> 
> > print is an instance method of the Kernel module.
> > 
> > The Object class includes Kernel, so the instance methods of Kernel  
> > are effectively instance methods of every object, at least in Ruby  
> > 1.8.  
> > […]
> 
> Kernel is a class, sub-class, of Object?

Kernel is a module. Object mixes it in – essentially:

class Object  
include Kernel  
end

so that every instance of Object, or a subclass of Object, gets access  
to the instance methods defined in Kernel.

Of course, the module Kernel is, itself, an Object 🙂 You’ll find  
that if you look closely at the top of the object tree in Ruby, there  
are some circularities:

- Kernel is a Module
- Module is a Class
- Class is a subclass of Module
- Object is a Class
- Class is an Object

etc. Don’t worry about it, though. The reason there’s circularity at  
the top of the object tree is so that the rest of the object tree –  
i.e., everything you really need to do – makes sense.

David

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [October 24, 2007, 12:02pm UTC](https://www.ruby-forum.com/t/terminology-class-methods-versus-kernel-methods/118112/9 "2007-10-24T12:02:20Z")

</div>

On 10/24/07, Thufir [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Ok. Is this composition? A work around for multiple inheritance?  
> Weird and wild stuff.  
> Not at all weird and wild and neither a workaround 🙂  
> Mixins are one of the cornerstones of Ruby and they are not a workaround  
> for MI but a replacement. A deliberate and IMHO excellent choice of  
> Matz.

Robert
