Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Learn it in a day languages
Index -> General Programming
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
wtd




PostPosted: Wed Nov 15, 2006 10:15 am   Post subject: (No subject)

bugzpodder wrote:
python, perl, php (you can get away with basics, but dont expect to be a master at it after a day)


With all due respect, none of these languages are in the same ballpark as those mentioned earlier. At some level, they all have quirky, inconsistent syntax and semantics that takes quite some time to come to grips with.
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Wed Nov 15, 2006 5:03 pm   Post subject: (No subject)

A bit of code, just for fun.

Let's create a variable!

Lua:

code:
foo = 42


Tcl:

code:
set foo 42


Io:

code:
foo := 42


Let's print it!

Lua:

code:
print(foo)


Tcl:

code:
puts $foo


Io:

code:
foo println


Let's read in a string!

Lua:

code:
line = io.read()


Tcl:

code:
set line [gets stdin]


Io:

code:
line := File standardInput readLine


Let's read in a number!

Lua:

code:
num = io.read("*number")


Tcl:

code:
set num [scan [gets stdin] "%f"]


Io:

code:
num := File standardInput readLine asNumber


Let's make it a function!

Lua:

code:
function read_number()
   return io.read("*number")
end


Tcl:

code:
proc read_number {} {
   return [scan [gets stdin] "%f"]
}


Io:

code:
readNumber := method(
   File standardInput readLine asNumber
)


Let's set a minimum number!

Lua:

code:
function read_number(minimum)
   num = io.read("*number")
   if num > minimum then
      return num
   else
      return minimum
   end
end


Tcl:

code:
proc read_number {minimum} {
   set num [scan [gets stdin] "%f"]
   if {$num > $minimum} {
      return $num
   } else {
      return $minimum
   }
}


Io:

code:
readNumber := method(minimum,
   num := File standardInput readLine asNumber
   if(num > minimum, num, minimum)
)
rdrake




PostPosted: Wed Nov 15, 2006 5:41 pm   Post subject: (No subject)

A bit more code, just for fun.

Let's create a variable!

Ruby:

code:
foo = 42


Let's print it!

Ruby:

code:
puts foo


Let's read in a string!

Ruby:

code:
line = gets.chomp


Let's read in a number!

Ruby:

code:
num = gets.chomp.to_i


Let's make it a function!

Ruby:

code:
def read_number()
   gets.chomp.to_i
end


Let's set a minimum number!

Ruby:

code:
def read_number(minimum)
   num = gets.chomp.to_i
   if num > minimum
      num
   else
      minimum
   end
end
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 18 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: