Codetown ::: a software developer's community
object Hello {
def main(args: Array[String]): Unit = {
println("Hello world.")
}
}
powerbookg4:tmp zemian$ scalac Hello.scala powerbookg4:tmp zemian$ scala Hello
Hello world.
Note that Scala main entry program is a "object" instead of "class". "object" in Scala is like a class that define a type, but it force it to be a singleton(only one instance), so it almost like "static" in Java. Your main entry in command line must be an object with the main method defined.
You may turn your source file into a script by enter a expression that invoke the main method on the end of the file, and then run it through "scala" instead of compiling it. For example:
object Hello {
def main(args: Array[String]): Unit = {
println("Hello world.")
}
}
Hello.main(args)
powerbookg4:tmp zemian$ scala Hello.scala Hello world.
Note the difference. 1 no compile. 2 you give scala the script file name, not the type name!
Happy programming!
Tags:
Codetown is a social network. It's got blogs, forums, groups, personal pages and more! You might think of Codetown as a funky camper van with lots of compartments for your stuff and a great multimedia system, too! Best of all, Codetown has room for all of your friends.
Created by Michael Levin Dec 18, 2008 at 6:56pm. Last updated by Michael Levin May 4, 2018.
Check out the Codetown Jobs group.

David Gudeman discusses battle-tested architectural patterns for resource-constrained engineering teams. Drawing from over a decade of startup experience, he explains how pairing GCP, Firebase, and Cloud Run accelerates product-market fit. Learn how to eliminate redundant frontend state, structure event-driven backends, and maintain lean DevOps while building for long-term scalability.
By David Gudeman
Changesets v3.0, released on August 11, 2026, introduces significant updates for JavaScript monorepos. It offers leaner installations, a rebuilt CLI, and changes to peer dependency management that resolve long-standing complaints. Upgrading involves configuration updates. The tool focuses on versioning and changelogs while supporting contributors in declaring release intents.
By Daniel Curtis
Out-of-order HTML streaming, a user experience pattern popularized by front-end frameworks and that allows users to view and interact faster with a page before it is entirely loaded, is making its way to web browsers. The proposal has the browser patching placeholders as data arrives. Developers can use either declarative HTML or matching JavaScript APIs. Available in Chrome 151.
By Bruno Couriol
This week's Java roundup for September 14th, 2026, features news highlighting: the GA release of JDK 27, LibericaJDK 27, Open J Proxy 1.0 and A2A Jakarta 1.0; point releases of Azul Payara, JHipster, JetBrains Ktor and BoxLang; and introducing Netflix ja, a modern JMS command line development experience for Java developers.
By Michael Redlich
Uber has redesigned shard placement in M3DB with fixed size subclusters to limit the impact of node failures, maintenance, and cluster scaling. The approach bounds shard dependencies, preserves replica isolation, and uses a greedy algorithm to select shard migrations while avoiding a separate rebalancing pass and unnecessary data movement.
By Leela Kumili
© 2026 Created by Michael Levin.
Powered by