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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:04:08+00:00 2026-05-13T16:04:08+00:00

I have been doing Java for a long time and started Scala about 6

  • 0

I have been doing Java for a long time and started Scala about 6 months ago. I love the language. One thing that I discovered is that there are multiple ways to do things. I don’t know if it is because of the nature of the language or because it’s still young and evolving and idioms and best practices haven’t emerged.

What surprises me is I have always been a python over perl person where:

“There should be one– and preferably only one –obvious way to do it.”

makes more sense to me than

“There’s more than one way to do it”.

I’m interested to know where you think Scala fit on this scale and why?


Quotes: Python PEP20 and Perl quote

  • 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-13T16:04:08+00:00Added an answer on May 13, 2026 at 4:04 pm

    My experience with Scala is that there is more than one way to do things, but relatively few “best” ways to do things. The library has very few gratuitous options for doing things different ways; when it does so, it’s usually to enable extra expressiveness or compactness or efficiency in a subset of cases.

    For example, if you want to sum an array of integers, you could be completely procedural, which would generate code that was as fast as possible, at the expense of being a little clunky–but if this is really time-critical code, this is the unique best way to solve the problem:

    val array = Array(1,2,3,4,5)
    var sum = 0
    var index = 0
    while (index < array.length) {
      sum += array(index)
      index += 1
    }
    sum
    

    There are equally general functional approaches that are slower when working with primitives (this may change with @specialized in 2.8) but leave you with less tedium:

    var sum = 0
    Array(1,2,3,4,5).foreach(x => sum += x)
    sum
    

    And then there are slightly less general functional constructs that are designed for just this sort of problem (since it comes up a lot) and this is “best” if you want clean, compact code:

    Array(1,2,3,4,5).reduceLeft( _ + _ )
    

    And sometimes there are very non-general constructs to do exactly what you want; in Scala 2.8, for example:

    Array(1,2,3,4,5).sum
    

    So you get a continuum of choices with tradeoffs in general power, compactness, clarity, and speed. If you can assume that the code needs only to be accessible to people who are quite familiar with Scala, and you know whether you need the absolute best possible performance or not, the good choices are usually rather limited. But, because of the expressive power of the language and library, there are usually many possible if suboptimal ways to do things.

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

Sidebar

Ask A Question

Stats

  • Questions 311k
  • Answers 311k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I ended up doing this: glAlphaFunc(GL_NOTEQUAL, 0); [sprite1.texture setAliasTexParameters]; [sprite1… May 13, 2026 at 10:28 pm
  • Editorial Team
    Editorial Team added an answer Db4o uses the CLR-reflection mechanisms to retrieve meta-information of the… May 13, 2026 at 10:28 pm
  • Editorial Team
    Editorial Team added an answer You need to begin a path, and close it when… May 13, 2026 at 10:28 pm

Related Questions

We have recently migrated a large, high demand web application to Tomcat 5.5 from
update: I know there is no one best way to do everything. Sorry for
In my implementation of Java NIO I have not been able to get SelectionKey.attach()
I've noticed over time that Clojure users have nothing but massive enthusiasm for the
I'm new to Hibernate, and while there are literally tons of examples to look

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.