Tcl: Hello World

File: hello.tcl
puts "Hello World!"

Run it with:

$ tclsh hello.tcl

Project Euler #1 in English:

Take the numbers from 1 upto but not including 1000 and for each number, if the number is divisible by 3 or 5 add it to a sum. Once every number has been looked up, print that sum.


I’ve been thinking about trying to use Lua as a algorithm description language instead of Python, there are a few things holding me back. One is that the end statements in Lua add a small but significant amount of space especially when I’m programming on paper.

I do wish that there was simple scripting language that was more Pascal like and supported Goto. Lua 5.2 has a goto statement, but it’s not widely available yet. Python does not support goto natively, but does use exceptions for control flow, which can work in a limit way for goto like constructs.

The main reason I want a version of GOTO is because I’ve been looking at Donald Knuth’s The Art of Computer Programming, and his descriptions of algorithms essentially use gotos rather than structured loops for control flow. I’d like to be able to translate his algorithms into code essentially as they are, before trying to rework them into structured form.

Practically, C has been the best language so far for doing immediate translations of Knuth’s algorithms that I’ve played with.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s