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.

Reddit has rebuilt its core backend, migrating Comments, Accounts, Posts, and Subreddits from a legacy Python monolith to Go microservices. The migration improves performance, halves critical write latency, and modernizes the platform for future scalability while preserving correctness across multiple datastores.
By Leela Kumili
Amazon announced support for the Agent-to-Agent (A2A) protocol in Amazon Bedrock AgentCore Runtime, enabling communication between agents built on different frameworks. The protocol allows agents developed with Strands Agents, OpenAI Agents SDK, LangGraph, Google ADK, or Claude Agents SDK to "share context, capabilities, and reasoning in a common, verifiable format."
By Vinod GojeIn this podcast Shane Hastie, Lead Editor for Culture & Methods spoke to Joe Cassavaugh about building a sustainable solopreneur game development business, the importance of authenticity over conventional wisdom, and learning from both successes and failures in the digital content marketplace.
By Joe Cassavaugh
At the Ignite conference, Microsoft unveiled the Cobalt 200 ARM processors, boasting a remarkable 50% performance boost. Engineered with advanced AI simulations and robust security features, it supports high-density workloads with 132 cores. As the next-gen solution for Azure, Cobalt 200 sets a new standard in efficiency and power, enhancing cloud capabilities for diverse applications.
By Steef-Jan Wiggers
Matthias Niehoff discusses how to bridge the gap between application development and data engineering. Learn to apply software engineering best practices to data pipelines, embrace boring technologies, and simplify architecture to maximize business value and data reliability.
By Matthias Niehoff
© 2025 Created by Michael Levin.
Powered by