Announcing ObjoScript

True, but were it gets nasty and obtuse is if you were to do this:

newChars[++pos] = s[pos++];

That line is just a mess. I would not be upset to just have:

newChars[pos] = s[i]
pos++

A fair point. Not a hill I’m going to die on arguing against :wink:

The trouble with advanced C-family syntax is it tends to allow you to write either very elegant code if you’re judicious, or blow your foot and lower leg clean off if you’re a cowboy.

I do own a copy of Kernighan And Ritchie (2nd edition) bought new … It was not my most useful purchase! :wink:

That was back when I saw everything going that way (I had been coding in BASIC, FORTRAN and Pascal) … C got me to step away from coding for a good while!

It’s not the concepts, I just found that type of syntax hard to read/absorb, and no fun!!!

-Karen

My experience was originally with Algol style languages: Pascal, Basic, PL1, etc., but I didn’t really mind C syntax. My big complaint with C was/is that the only way you could call by reference is to pass a pointer. I never was able to deal with pointer syntax without having to go to the reference manual every time I needed to use a pointer, or try to follow someone else’s code that used them. I haven’t minded programming in Java and Javascript which are both C syntax.

And I have not minded C#, although it is getting so full of lamdas now that they might be snatching defeat from the jaws of victory when it comes to me. Java, JavaScript, C#, Swift and similar Algol descendants provide the ref syntax you want, get rid of pointers except for code marked unsafe for very particular needs, etc. But these mainstream languages do tend to get a lot of bolted-on obtuseness after awhile, trying to be all things to all people.

I’ve just implemented support for switch statements.

They work as you might expect:

switch someValue {
  case anotherValue {
    // Code...
  }
  
  case aFunctionCall(), "literal", 3 * 2 {
    // Code...
  }
  
  else {
    // Executes if none of the cases match `someValue`
  }
}

They were trickier to implement than I had anticipated. For those interested, the compiler translates a switch statement into a nested if...else statement so there is no performance advantage to using them over if statements but they can be easier to read.

3 Likes

Nice!

No worries about the chained (not nested) ifs - the times of using static jump tables for better performance are long gone anyway.

1 Like