Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't fully agree with @edutesoy answer. </p> <p><a href="http://en.wikipedia.org/wiki/First-class_object" rel="nofollow noreferrer">First-class</a> means that an implicit constructs is reified as an explicit construct that can be passed around like any object. Classes in Java are not "first-class", they are mirrors where you can inspect some properties but are not the the object itself. </p> <p>That you can not change the structure of the class at run-time is fine, e.g. add fields, change method body or signature, and that under this perspective it's partly "read-only" is ok. </p> <p>But let's consider static fields. I guess everybody agrees that unless <code>final</code> static fields are mutable, just like instance fields. In Smalltalk, these are just fields defined on the class itself, rather than on instances of the class. Also, in Smalltalk, class-side methods are polymorphic just like any other method, and :</p> <pre><code>aClass field: aValue. </code></pre> <p>might resolve differently depending on the class that is passed. This is not possible in Java ; a static field or method must be referenced via its <em>type</em>. This also means that it does not <a href="https://stackoverflow.com/questions/2223386/why-doesnt-java-allow-overriding-of-static-methods/2223408#2223408">allow overriding static methods</a> (read the link for more details) as would be the case if they were truely first class. </p> <p>The fact that reflection is possible in Java doesn't make classes "first-class"--you can only pass a representation of the class around. And to come back to the original question: I don't know of any statically typed language with first-class classes (but my knowledge is limited, maybe one exists).</p> <p><strong>EDIT</strong></p> <p>Actually, now I remember it exists StrongTalk (<a href="http://www.strongtalk.org/" rel="nofollow noreferrer">http://www.strongtalk.org/</a>) which is Smalltalk with static typing. The typing issues are discussed in this paper: <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.95.6935&amp;rep=rep1&amp;type=pdf" rel="nofollow noreferrer">Strongtalk: Typechecking Smalltalk in a Production Environment</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload