PUBLIC INDEX legacy zcourts.com ZCOURTS - VOL. 02
LONDON - 2026
Learning Scala : My first attempt at a command line progress bar
While on my path to learning Scala, or rather improving my very lacking Scala knowledge I've written a progress bar for the command line... I'm pretty sure it is far more verbose than it needs to be, but until I know how...
Static article
Imported body
Legacy aliases
Article archive
FIG. 02
notes
surface
research
surface
Article
app model
publish
surface
Imported writing rendered as native Fission Markdown content.
SECTION
Source and context.
The static release keeps the original post body locally while the backend content pipeline is still being built.
legacy
archive
bar
code-less
command-line
command-line-progress-bar
learn
progress
progress-bar
scala
verbose
programming
Published 2011-12-20 on legacy zcourts.com. Estimated reading time: 1 min.
Original routes are preserved as local aliases so older links keep resolving to this static archive.
While on my path to learning Scala, or rather improving my very lacking Scala knowledge I've written a progress bar for the command line... I'm pretty sure it is far more verbose than it needs to be, but until I know how to code less and do more, this is it:
<!-- more -->
object Main {

  def main(args: Array[String]): Unit = {
    println("Starting...")
    var i = 0
    val n = 100
    while (i < n) {
      print(pad(i))
      Thread.sleep(150)
      i += 1
    }
    println("Done...")
  }

  def pad(i: Int) = {
    var n = 0
    val str = new StringBuilder
    while (n < i) {
      if (n == 50)
        str.append(i + 1)
      else
        str.append(".")
      n += 1
    }
    if (i < 50) {
      while (n < 50) {
        str.append(" ")
        n += 1
      }
      str.append(i + 1)
    }
    if (i==99)
      str.append("\n")
    else
      str.append("\r")
    str.toString
  }

}
CR
Courtney Robinson
zcourts.com
Building the infrastructure for the agentic future.
LET'S CONNECT
courtney@crlog.info
Based in London
© 2025 Courtney Robinson. All rights reserved.