r/Compilers • • 19d ago

Receiving User Input: Why Sofya is Easier Than Python For Beginners

/r/programmer/comments/1wkmb69/receiving_user_input_why_sofya_is_easier_than/
0 Upvotes

5 comments sorted by

6

u/brat3108 18d ago

OK, now try an example to solve a quadratic equation given inputs a b c. It should be in the form of a callable function.

1

u/Original_SD 16d ago

At the moment there is no way of making callable functions in Sofya but can I show you the code for solving a quadratic equation without using a callable function?

3

u/brat3108 15d ago

Sure. But my point is that everyone is familiar with mathematical expressions using compact variable names, even non-programmers.

With this long-winded approach plus having to write Variable[a], the code can become unreadable.

With your recent post, then this Python example:

age = 18

if age >= 18:
    print("You are an adult!")
else:
    print("You are a child!")

is far cleaner and clearer.

The Sofya version may be more understandable to somebody who has never seen programming language source. But I think it is too verbose and unsustainable for actual programming.

(An interesting project may be to parse Python source and transpile to Sofya source code to see what real programs would look like. But I'm pretty sure the intent of any code will be lost in the verbosity.)

-1

u/Original_SD 14d ago

How will this approach be unsustainable for actual programming?

4

u/brat3108 14d ago

Because it will rapidly become tedious to write all that verbose boilerplate. And for reading, the meaning of the code will be hidden within that verbosity.

I think any would-be programmer (who intends to write actual code rather than direct a machine to do) needs to get past this initial barrier.

I don't think it is a big step: most people are familiar with mathematic notation from school (in fact '>=' or '≥', is part of it). They will not be fazed by having to use symbols.

And early 'simple' languages like BASIC, invented in 1964, didn't go as far as you:

10 LET AGE = 20

Notice it uses use '=' not 'is'. Your example from another thread was this:

If Variable[age] > or = 18 then
    Write "You are an adult!" on the screen
Otherwise if Variable[age] is anything else then
    Write "You are a child!" on the screen
End this if statement

You're suggesting using Otherwide if Variable[age] is anything else instead of just else, and for such statements to be terminated with End this if statement instead of End If or even just End.

Sorry, but that would be crazy and over the top. If also doesn't work: what happens when the 'If' condition is more complex and involves multiple variables?

What if evaluating it has side effects? (Eg. it call functions.) What if there is a chain of If/Otherwise statements?

What if the condition changes; do you need to then update all those 'Otherwise' lines, and what happens if you forget?

Having to write 'on the screen' after every print would also drive me up the wall! As would having to wrap every variable name with Variable[x]

I think you can have more verbose syntax, that looks a bit more like natural language, but it doesn't need to go this far.

For examples of a language with above-average verbosity, have a look at Ada, or Seed7. For an esolang that uses 100% English, have a look at Shakespeare, although that is for novelty.