Mixing Tcl and Io

  • 5 Replies
  • 2341 Views
*

Zero

  • Eve
  • ***********
  • 1287
Mixing Tcl and Io
« on: November 23, 2017, 01:51:47 pm »


As you know, I like programming languages. Here I do a little thought experiment: mixing John Ousterhout's language Tcl and Steve Dekorte's language Io.

An interesting feature of Tcl is that function evaluation isn't automatic. You have to put code inside square brackets if you want it to be executed. The square brackets and their content will be "replaced by" the output of the code inside them.

set x 24
set y 18
set z "$x + $y is [expr $x + $y]"
puts $z


Io is modern and minimalist. An object is a list of slots, where each slot may contain data/code. You'd call an object's method by naming the corresponding object's slot.

Account := Object clone
Account balance := 0
Account deposit := method(amount,
    balance = balance + amount
)

account := Account clone
account deposit(10.00)
account balance println




Mixing them would give something like this:

set Dog [Object clone];

Dog set greet [
   fun {
      print "Hello, [arg]. I'm [name].";
   };
];

set my-dog [Dog clone];

my-dog
   set name "Maxy the dog",
   greet John;
   
-> Hello, John. I'm Maxy the dog.


"set" means "create a slot in yourself, with this name and this value".

In the first line, we're talking to the Environment, saying: create a slot named "Dog". The value of this slot will be the result of the code in square brackets [Object clone].

With "Object clone", we're talking to the object "Object", asking it to return a clone of itself.

The general form of a command is
command ::= <subject> <verb> <arguments> { "," <verb> <arguments> } ";"

Example:
obj part3 subPartB doThis like that, doThat like this;
where
"obj part3 subPartB" is the subject
"doThis" is a function with arguments "like" and "that"
"doThat" is a function with arguments "like" and "this"

I choose not to use named function arguments. Arguments are accessible through "arg", which contains the list of every argument the function was called with.

This would blend perfectly with the pub/sub semantics of Birdy.


*

Thierry

  • Nomad
  • ***
  • 60
  • God is a sphere. Press 9 to enter.
Re: Mixing Tcl and Io
« Reply #1 on: November 23, 2017, 02:07:57 pm »
What those languages can do that python cannot ? (Compared to guys like you I really consider myself as beginner in programming !  :))

*

Zero

  • Eve
  • ***********
  • 1287
Re: Mixing Tcl and Io
« Reply #2 on: November 23, 2017, 02:40:44 pm »
Nothing, really. All general purpose mainstream programming language are (pseudo) Turing-complete, which means they can compute everything, if they have enough space-time.

Differences are rather:
- some things are easier in one language, other things are easier in another
- porting to specific platforms can be easy/hard
- the ecosystems are different (ecosystem = libraries made by communities)
- communities have different "style" and size...

You code in Python? Python is good for AI. Good choice!

*

Thierry

  • Nomad
  • ***
  • 60
  • God is a sphere. Press 9 to enter.
Re: Mixing Tcl and Io
« Reply #3 on: November 23, 2017, 09:56:08 pm »
Nothing, really. All general purpose mainstream programming language are (pseudo) Turing-complete, which means they can compute everything, if they have enough space-time.

Differences are rather:
- some things are easier in one language, other things are easier in another
- porting to specific platforms can be easy/hard
- the ecosystems are different (ecosystem = libraries made by communities)
- communities have different "style" and size...

You code in Python? Python is good for AI. Good choice!

ok I get it.
Yes Python is the only language I know. I went to it because I saw roboticists in many forums going to it and being quite satisfied.  I love it as well. Thanks to it I saw very fast that I could do almost everything with a machine. I don't say I don't want to go further with other languages but at least for what I need now this is enough.

Are you into Python as well ?

*

Thierry

  • Nomad
  • ***
  • 60
  • God is a sphere. Press 9 to enter.
Re: Mixing Tcl and Io
« Reply #4 on: November 23, 2017, 10:23:28 pm »
By the way ... IO dictionaries  are weird ! They look more like "set" than "dict". There s no item:value... ???

http://iolanguage.org/tutorial.html


*

Zero

  • Eve
  • ***********
  • 1287
Re: Mixing Tcl and Io
« Reply #5 on: November 24, 2017, 09:17:28 am »
Actually, Python is not my favorite language :)

This "There's only 1 way to do it" (the pythonic way) philosophy isn't my taste, really. Or maybe it's just because I like to choose my own indentation style. I'm more Perl-ish style. Javascript is currently what excites me most. People usually under-estimate it, seeing it as a language that encourages bad practices and unstructured code, but it's wrong. It demands discipline, but once you're there, it can be everywhere, it can be very fast, and it's elegant.

Now Python is a perfect choice for you in my opinion. It gives you structure. In AI and robotics fields, it is highly appreciated by communities. You can work easily with very high level concepts, and get things done neatly. Stick to it, master it, I'm sure you'll be a happy dev. A dev should be happy!

About Io dictionaries, it's ok... There's everything you would expect: atPut() can set new key:values, at() fetches a value when given a key, keys() returns the list of keys, and foreach() lets you loop through it. What it doesn't have though, is a literal syntax for expressing them, like {a:1, b:2} for instance. But well, it's a minimalist language.

 


Will LLMs ever learn what is ... is?
by HS (Future of AI)
November 10, 2024, 06:28:10 pm
Who's the AI?
by frankinstien (Future of AI)
November 04, 2024, 05:45:05 am
Project Acuitas
by WriterOfMinds (General Project Discussion)
October 27, 2024, 09:17:10 pm
Ai improving AI
by infurl (AI Programming)
October 19, 2024, 03:43:29 am
Atronach's Eye
by WriterOfMinds (Home Made Robots)
October 13, 2024, 09:52:42 pm
Running local AI models
by spydaz (AI Programming)
October 07, 2024, 09:00:53 am
Hi IM BAA---AAACK!!
by MagnusWootton (Home Made Robots)
September 16, 2024, 09:49:10 pm
Attempting Hydraulics
by MagnusWootton (Home Made Robots)
August 19, 2024, 04:03:23 am
LLaMA2 Meta's chatbot released
by spydaz (AI News )
August 24, 2024, 02:58:36 pm
ollama and llama3
by spydaz (AI News )
August 24, 2024, 02:55:13 pm
AI controlled F-16, for real!
by frankinstien (AI News )
June 15, 2024, 05:40:28 am
Open AI GPT-4o - audio, vision, text combined reasoning
by MikeB (AI News )
May 14, 2024, 05:46:48 am
OpenAI Speech-to-Speech Reasoning Demo
by MikeB (AI News )
March 31, 2024, 01:00:53 pm
Say good-bye to GPUs...
by MikeB (AI News )
March 23, 2024, 09:23:52 am
Google Bard report
by ivan.moony (AI News )
February 14, 2024, 04:42:23 pm
Elon Musk's xAI Grok Chatbot
by MikeB (AI News )
December 11, 2023, 06:26:33 am

Users Online

427 Guests, 0 Users

Most Online Today: 507. Most Online Ever: 2369 (November 21, 2020, 04:08:13 pm)

Articles