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

  • Home
  • SEARCH
  • 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 6543723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:22:48+00:00 2026-05-25T11:22:48+00:00

I know you can define them indirectly achieve something similar with companion objects but

  • 0

I know you can define them indirectly achieve something similar with companion objects but I am wondering why as a language design were statics dropped out of class definitions.

  • 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-25T11:22:48+00:00Added an answer on May 25, 2026 at 11:22 am

    I also posted this question on scala users google group and Bill Venners one of the authors of “Programming in scala” reply had some insights.

    Take a look at this: https://groups.google.com/d/msg/scala-user/5jZZrJADbsc/6vZJgi42TIMJ and https://groups.google.com/d/msg/scala-user/5jZZrJADbsc/oTrLFtwGjpEJ

    Here is an excerpt:

    I think one
    goal was simply to be simpler, by having every value be an object,
    every operation a method call. Java’s statics and primitives are
    special cases, which makes the language more “complicated” in some
    sense.

    But another big one I think is to have something you can map Java’s
    statics to in Scala (because Scala needed some construct that mapped
    to Java’s statics for interop), but that benefits from OO
    inheritance/polymorphism. Singleton objects are real objects. They can
    extend a superclass or mix in traits and be passed around as such, yet
    they are also “static” in nature. That turns out to be very handy in
    practice.

    Also take a look at this interview with Martin Odersky (scroll down to Object-oriented innovations in Scala section) http://www.artima.com/scalazine/articles/goals_of_scala.html

    Here is an excerpt:

    First, we wanted to be a pure object-oriented language, where every value is an object, every operation is a method call, and every variable is a member of some object. So we didn’t want statics, but we needed something to replace them, so we created the construct of singleton objects. But even singleton objects are still global structures. So the challenge was to use them as little as possible, because when you have a global structure you can’t change it anymore. You can’t instantiate it. It’s very hard to test. It’s very hard to modify it in any way.

    To Summarize:

    From a functional programming perspective static members are generally considered bad (see this post by Gilad Bracha – the father of java generics. It mainly has to do with side effects because of global state). But scala had to find a way to be interoperable with Java (so it had to support statics) and to minimize (although not totally avoid) global states that is created because of statics, scala decided to isolate them into companion objects.

    Companion objects also have the benefit of being extensible, ie. take advantage of inheritance and mixin composition (separate from emulating static functionality for interop).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know I can define default parameters in python, but can I do so
I know you can define a global variable in Objective-C by using extern, but
I know I can define new structs in ruby by doing Person = Struct.new(:first_name,
As I know I can define a new Enum DataFormat at the my project
I know that one can define an 'expected' exception in JUnit, doing: @Test(expect=MyException.class) public
I'd like to know how can I define two signatures for the constructor with
Does anyone know if and/or how you can define macro definitions in a gSoap
This is something I know can be done somehow , because I've done it
I know that with other properties you can define their default value by using
I know if I add withSources when I define one dependency, sbt can download

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.