CS 3060: Programming Languages

Io

Robert C. Green II, Ph.D.

Day 1

Ferris Beuler

Day 1

Meet Io. Like Ruby, Io is a rule bender. He's young, wicked smart, and easy to understand but hard to predict. Think Ferris Bueller. If you like a good party, you'll have to let Io show you around the town. He'll try anything once. He might give you the ride of your life, wreck your dad's car, or both. Either way, you will not be bored. As the quote above says, you won't have many rules to hold you back.
I found that after Io, I had a much stronger understanding of how JavaScript worked.

Io is...

Prototype-based programming is a style of object-oriented programming in which behaviour reuse (known as inheritance) is performed via a process of cloning existing objects that serve as prototypes. This model can also be known as prototypal, prototype-oriented, classless, or instance-based programming. Delegation is the language feature that supports prototype-based programming.

The Interpreter & Running Files

						
				io
						
					

Comments

						
				// 
				/* */
				#
						
					

Messages & Receivers

						
		"Your message here" println
						
					
						
			Receiver Message
						
					

Printing Output

						
	"I pity the full that prints" println
	"I pity the full that prints" print
						
					
						
	"I pity the full that prints" writeln
	"I pity the full that prints" write
						
					

Printing Output

						
   "#{Value1} is something like #{Value2}" interpolate println
						
					

Loops

						
	loop("getting dizzy..." println)
						
					
						
	3 repeat("foo" print)
						
					

Loops

						
	while(<condition>, <do message>)
						
					
						
	i := 1
	while(i <= 11, i println; i = i + 1); 

	while(i <= 11, 
		i println; 
		i = i + 1
	); 
						
					

Loops

						
  for(<counter>, <start>, <end>, <optional step>, <do message>)
						
					
						
for(i, 1, 11, i println); "This one goes up to 11" println
for(i, 1, 11, 2, i println); "This one goes up to 11" println
						
					
						
for(i, 1, 2, 1, i println, "extra argument")
for(i, 1, 2, i println, "extra argument")
						
					

Control Structures

						
		if(condition, true code, false code)
						
					
						
if(true, "It is true.", "It is false.")
if(false) then("It is true") else("It is false")
if(false) then("It is true." println) else("It is false." println)

if(y < 10) then(x := y) elseif(y == 11) then(x := 0) else(x := 2)
						
					

Control Structures

						
if(y < 10) then(x := y) elseif(y == 11) then(x := 0) else(x := 2)
						
					
						
if(y < 10) then  
	(x := y) 
elseif(y == 11) then 
	(x := 0) 
else(x := 2)
						
					

Methods

						
	method(Optional arguments, body)

				 		
				 	
						
	method("So, you've come for an argument." println)

	method() type

	drive := method("Vroom" println)
				 		
				 	

Methods

						
	newMethod := method(Param1, Param2, 
		body
		...
		body

		return varName
	)
				 		
				 	

Lists

						
 toDos := list("find my car", "find Continuum Transfunctioner")

 a: = list(1, 2, 3, 4)
 a average
 a sum
 a at(1)
 a append(4)
 a pop
 a prepend(1)
						
					

Maps

						
			elvis := Map clone
			elvis atPut("home", "Graceland")
			elvis at("home")
			elvis atPut("style", "rock and roll")

			elvis asObject
			elvis asList
			elvis keys

			elvis size
						
					

The Infamous Main...

						
	if(isLaunchScript,

	...

	)
				 		
				 	

Resources

  • http://iolanguage.org/
  • http://iolanguage.org/scm/io/docs/IoGuide.html
  • http://iolanguage.org/scm/io/docs/reference/index.html
  • http://en.wikibooks.org/wiki/Io_Programming
  • http://c2.com/cgi/wiki?IoLanguage
  • http://rigaux.org/language-study/syntax-across-languages-per-language/Io.html

Assignment

Assignment #2

Read Day 2