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 8930565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:55:11+00:00 2026-06-15T08:55:11+00:00

What is the difference between a scala script and scala application? Please provide an

  • 0

What is the difference between a scala script and scala application? Please provide an example

The book I am reading says that a script must always end in a result expression whereas the application ends in a definition. Unfortunately no clear example is shown.

Please help clarify this for me

  • 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-06-15T08:55:12+00:00Added an answer on June 15, 2026 at 8:55 am

    I think that what the author means is that a regular scala file needs to define a class or an object in order to work/be useful, you can’t use top-level expressions (because the entry-points to a compiled file are pre-defined). For example:

    println("foo")
    
    object Bar {
        // Some code
    }
    

    The println statement is invalid in the top-level of a .scala file, because the only logical interpretation would be to run it at compile time, which doesn’t really make sense.

    Scala scripts in contrast can contain expressions on the top-level, because those are executed when the script is run, which makes sense again. If a Scala script file only contains definitions on the other hand, it would be useless as well, because the script wouldn’t know what to do with the definitions. If you’d use the definitions in some way, however, that’d be okay again, e.g.:

    object Foo {
        def bar = "test"
    }
    
    println(Foo.bar)
    

    The latter is valid as a scala script, because the last statement is an expression using the previous definition, but not a definition itself.

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

Sidebar

Related Questions

What is the difference between Iterator and Iterable in scala? I thought that Iterable
Possible Duplicate: What is the difference between scala self-types and trait subclasses? I understand
Can someone please explain the major differences between Scala, Groovy and Clojure. I know
The difference between Chr and Char when used in converting types is that one
What is the difference between Scala traits Haskell type class and C++0x Concepts? Like
What is the difference between sealed abstract and abstract Scala class?
Please have a look at the REPL session below. The only difference between both
What is the difference between a var and val definition in Scala and why
Possible Duplicate: Scala traits vs abstract classes What is the conceptual difference between abstract
Is there a difference between classes Tuple2 and Pair in scala? It seems to

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.