tolueno7
tolueno7

Reputation: 31

Choosing a syntax for a new language based on Logo

I'm building a project that consists of a web port of LogoWR (Tutle Graphics), but I want to make some changes to the syntax, such as the way variables are named.

Original:

:variable

New:

#number_variable
$text_variable
:indistinct (Can be number or text or other)

The objective is to train children (about 10 to 14 years old) to use variables. It should also teach them type casting (and about using different variable types), but with a "physical view" - always doing the casting explicitly. I want something like $text = text(#number), so that the user can view the type of a variable without seeing its declaration.

The question is, in your opinion, is it too hard for the children to follow these rules?

Upvotes: 3

Views: 112

Answers (1)

david.pfx
david.pfx

Reputation: 10853

It depends a lot on who the children are and what stage they are at.

Beginning programmers should be insulated from types. There are plenty of challenging things to learn without that level of complication. Logo is excellent because it encourages thinking patterns such as programmability and problem decomposition very early with concrete outcomes. I'm sure you know this better than I do.

Types are in many ways unnecessary unless the children have mastered the basics and need to take on quite sophisticated programming challenges. May languages used by professional programmers (Python, Ruby, etc) have typed values but not typed variables, and it works well for problems in their domain. Personally I find the need to convert numbers to strings and back annoying rather than anything else.

If you do see a real need for typed variables and type conversions I would avoid the thing that looks like an ordinary function. Also consider that conversions can trigger exceptions (or some kind of error). I think I prefer either an explicit conversion function with a default, or the as' syntax.

$text = Text.convert(#number, "?")
$text = #number as Text

It takes me back to early dialects of Basic, and much pain.

Upvotes: 0

Related Questions