Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6914575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:21:56+00:00 2026-05-27T09:21:56+00:00

One thing I don’t understand about Scala, is why Null subclasses everything, despite not

  • 0

One thing I don’t understand about Scala, is why Null subclasses everything, despite not passing the substitution test. Presumably this is for Java compatibility, which is fine, I guess — but then Scala pushes the Option[T] pattern.

This I don’t understand. An Option[T] doesn’t give you any extra guarantees (as every T is a defacto Option anyway). But it also makes a total of 4 states:

val a: Option[String] = null
val b: Option[String] = Some(null)
val c: Option[String] = None
val d: Option[String] = Some("A string")

This seems both inefficient (from a bytecode pov) and perhaps even worse than just pain Java. What my question is, why didn’t Scala make Option[T] a special case that translates directly to a java bytecode’s T. All interfacing with Java code (that uses references) would have to be via this Option[T] (which really, is exactly what it is). And there would be an annotation or something, for when a Scala method works with a T that can’t be None.

This seems like the most obviously correct, most typesafe and most efficient.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:21:56+00:00Added an answer on May 27, 2026 at 9:21 am

    There are three possible reasons:

    1. Scala is a thin wrapper, that only adds new stuff and they don’t want to break that.
    2. They don’t want to make Java libraries a pain in the ass to use, because all the arguments would then be Option[T] instead of T.
    3. They don’t want to have to use name-mangling or annotations to differentiate libraries written in Scala and written in Java (to mark a method as taking a “non-nullable reference”).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just learn up to tree and one thing I don't understand about it
One thing that really interests me that I don’t see much written about or
I don't understand one thing. Why do I have to use foreign key to
I don't understand one thing. If I want to get JSON data (key-value-pairs) from
The one thing I don't like about javascript is that there are hundreds of
One thing I don't like about writing javascript-based applications is that you have to
One thing I'm concerned about is I create two ints, but don't release them.
One thing I really miss about Java is the tool support. FindBugs, Checkstyle and
One thing I've always wondered about is how software patches work. A lot of
One thing that bugs me about IE is that when it goes to load

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.