Assignment operator likes and dislikes

If you are to use a scripting language, would you like this syntax for assigment and comaprison:

            count := 0
            count := count + 1
            if count = 10 then

… or rather this one?

            count = 0
            count = count + 1
            if count == 10 then

The first is based on Pascal, the second on Java/C syntax. I follow Mr. Wirth’s argumentation to some point that an assignment is different from the mathematical equality “=” operator, and therefore should use something else. He suggested “:=” IIRC.

What do you think?

Edit: personally I’d prefer “count <- count + 1” to show the direction of the data flow.

If you want to “support” the major languages(for easier porting),
make your ifs, fors and whiles generic. Like C, C++, C#, Java etc

if(this == that) {
...
}

I +1 for Java style == because it looks like emoticon.

My first thought is: don’t design a scripting language. Time sink, use an existing one unless you really want the learning exercise.

The language in question is highly specialized and has a very tiny set of features. It’s not a general purpose language, so porting other code to it will make no sense, I assume.

It’ll be a language to create recursive graphical structures. To be more precise it will be an abstraction layer for this:

I have most of it in place now, but before I release it, I want the syntax to be somewhat stable. Since C and Java are both in the top 3 of the programming language charts, I guess it’s a good idea to stay close to their syntax, regrdless of the more theoretical considerations what would be a good syntax?

I had most of it already from older projects. It’s done at the time of posting this, except better loops (hgas only goto now). The only question is the to decide on a syntax which the people like. And yes, I know that the standard approach is to use an existing language, and I full agree there.

:= is much more annoying to type than =.

To give an idea what I have so far. A script like this …


// Turtle interpreter test
    
    setLineWidth(3)
    setScale(0.04)
    setColor(#FF7F00)
    startPainting()
    turn(180)
    up(10)
    
    count = 0
    
start:
    
    forward(40)
    placeSphere(1)
    turn(90)
    forward(40)
    placeSphere(1)
    turn(90)
    forward(40)
    placeSphere(1)
    turn(90)
    forward(40)
    placeSphere(1)
    up(5)
    turn(70)
    
    count = count + 1
    
    if count < 20
    {
        goto start
    }
    up(5)

… will create a graphic like this:

Since all suggestions were towards Java/C syntax, I’ve set up the interpreter this way currently. Color values are denoted #RRGGBB as in HTML. The script controls a “Turtle” ( http://en.wikipedia.org/wiki/Turtle_graphics ) which moves in 3D space and can draw lines (cylinders) there. Also place objects, spheres are used to round the bends in the example.

Maybe I should get rid of all the paranthesis around arguments?

While I’m in favor of := for assignment, that battle was lost a long time ago. Just use = for assignment and == for equality, and if your language distinguishes between statements and expressions, make assignment a statement.

Couldn’t agree more.

Then again, the language you’re most comfortable with will be the one you have a bias towards.

-Pickle