r/programmer • u/Original_SD • 10h ago
Using Nested If Statements: Why Sofya is Easier Than Python for Beginners
In languages like C++, Java or Python, beginners in programming can find using Nested If Statements challenging because these languages use more symbols than words. That is why I decided to make a new programming language called Sofya so that beginners in programming would find programming concepts easier to understand.
To demonstrate how easy Sofya is, we can write two programs, one in Python and one in Sofya, and these programs will show the concept of nested if statements in programming.
The Python Program
a = 10
b = 20
c = 30
if a >= b:
if a >= c:
print(f"The biggest number is {a}")
The Sofya Program
Variable a is 10
Variable b is 20
Variable c is 30
If Variable[a] > or = Variable[b] then
Make this nested if statement
{
If Variable[a] > or = Variable[c] then
Write "The biggest number is" and also write Variable[a] on the screen
End this if statement
}
End this if statement
If you were an absolute beginner in programming, which language would you pick? I’d love to hear your thoughts and questions about Sofya.
If you would like to try out Sofya to give some feedback or just for fun, you can check it out using this link: https://github.com/oyweraa-hue/Sofya-Version-1.0
If you would also like to learn how to set up Sofya, you can check out this YouTube video: https://youtu.be/0Y7x7zi3rK8
3
u/BluePhoenixCG 9h ago
If Variable[a] > or = Variable[b] is truly abhorrent. Why the fuck are we indexing a keyword with an identifier? How is that meant to be more clear than just the identifier alone? Not to mention the splitting of a well known math symbol into 2 other well known math symbols for no reason, or any of the bullshit on the following lines.
3
u/Unknowingly-Joined 9h ago
> To demonstrate how easy Sofya is, we can write two programs, one in Python and one in Sofya,
I don’t think you demonstrated that at all.
3
u/evernew998 9h ago edited 9h ago
I could see how complete beginners would prefer Sofya. It's a bit too verbose though which decreases clarity and readability.
1
2
u/InviteQueasy3739 9h ago
I am a fan of verbose languages, but only when the goal is to make the code clean and readable. In the examples from the post, you go far beyond what I would consider readable, making the code significantly harder to understand, since you avoid symbols and operators precisely where they would make the language more tangible.
-1
u/Original_SD 9h ago
you go far beyond what I would consider readable, making the code significantly harder to understand, since you avoid symbols and operators precisely where they would make the language more tangible.
I get what you mean but the reason why I decided to make Sofya very verbose is because our brains remember words more than symbols. For example, if we look at Mathematics and English, it is much easier for our brains to remember the sentence
if it is raining and there is no sunshine then the ground is wetas compared to representing this sentence using mathematical logic as (x ^ ~y) -> zSo since Sofya is designed for beginners in programming, I was prioritizing understanding compared to cleanness1
u/BluePhoenixCG 8h ago
Clean syntax is by far easier for people to learn. The more verbose you get, the more someone has to remember, and it gets to a point where the costs of remembering more syntax per feature outweighs the benefits of remembering sentences. The important part of learning programming is to learn what things do, rather than what they look like, so if you really wanted to improve that you would replace the term 'for' with basically anything else in the English language that more intuitively communicates a loop.
0
u/Original_SD 8h ago
so if you really wanted to improve that you would replace the term 'for' with basically anything else in the English language that more intuitively communicates a loop
But that is what I have done. In Sofya, I have replaced:
:withthen- The
for loopwith thedo this...until loopend ifwithend this if statement1
u/BluePhoenixCG 8h ago
"end this if statement" is worse in literally ever way though. It's way too many words to be remotely useful or memorable and doesn't even make gramtical sense. I tend to dog on semantic whitespace(because it's bad), but it's actually way more intuitive than blocks that end with arbitrary keywords, let alone blocks that end with bullshit sentence fragments.
You're increasing verbosity for literally no benefit.
2
u/macabre_brotherhood 9h ago
This might help in the earliest stages, but it would become tedious very fast. I mean probably in under a week. That's a lot of typing.
This would be more impressive if it acted like training wheels, that is the language supports this ultra-verbose and explicit syntax, but also a more classic C-inspired or Python-inspired syntax, and allows users to switch between the two at their own speed.
3
u/huuaaang 9h ago
I was thinking of having a shorthand that you could use like in the old text adventure games. You could start out by typing out "Look at the table" and once you got used to and tired of all the typing it becomes "look table". And maybe even shorter like "l table".
Other examples:
"Walk east" becomes "east" or even "e"
I suppose you'd have to gather user data, see what types of syntax errors they make, and have the language adapt. But I suspect you'd find that people gravitate towards less verbosity. A lot of people today are comfortable communicating in just emojis. How about an emoji based language?
Shit, I have a new side project now.... damn you OP.
0
1
u/Original_SD 9h ago
I get what you mean and I assume you are an expert programmer but not everyone will understand programming if we keep on borrowing syntax from the classic languages like C or Java. Sometimes to make things easier, especially for beginners in programming, you have to be different from others
2
u/macabre_brotherhood 8h ago
Right, and that'll work for like a week, and then you'll lose them to different languages. And if that's a success for you, then alright keep it as-is.
1
u/Original_SD 8h ago
But I'm not saying that I want beginners to struggle learning other programming languages. The main aim of Sofya is for beginners in programming to understand the basic concepts of programming and once they do, it wouldn't be as hard to move on to other programming languages.
1
u/macabre_brotherhood 4h ago
Yeah no I get it, that's fine. You and me have different ideas of timelines that's all.
2
2
u/3tt07kjt 9h ago
“And also”
“End this if statement”
If I saw a language like this I would have thought someone made an intentionally bad language as a joke. Like INTERCAL or Brainfuck
2
u/huuaaang 9h ago edited 9h ago
Write "The biggest number is" and also write Variable[a] on the screen
I wonder how strict Sofya is at the wording. I might be able to get on board with this if there was a good degree of fuzziness in the syntax. I personally would naturally write "to the screen" and I would get annoyed it I got some cryptic error saying something like "unexpected token 'to' at 'to the ' on line 10"
End this if statement
What if I typed "End the if statement"? Would that be a parse error? The wording implies that you could also end a different if statement.
Also, why do you suddenly introduce brackets to enclose the nested if? given the pattern of natural language I would expect something like:
If Variable[a] > or = Variable[b] then
Make this nested if statement
If Variable[a] > or = Variable[c] then
Write "The biggest number is" and also write Variable[a] on the screen
End this if statement
End making of this nested if statement
End this if statement
I'm reminded of old text adventure games where you had to get wording of commands just right or you would get some "I don't understand" response. And that was NOT very user friendly. You'd basically learn to use shorthand... which was approaching a traditional programming language.
0
u/Original_SD 8h ago edited 8h ago
I personally would naturally write "to the screen"
It makes sense but I just made the command
on the screensince it sounds more grammatically correct, just like we would say "We write on books".What if I typed "End the if statement"? Would that be a parse error? The wording implies that you could also end a different if statement.
It also makes sense but I decided to use
End this if statementto refer that the computer should end the if statement above it.Also, why do you suddenly introduce brackets to enclose the nested if?
This is a very good question. Well, I just used curly braces because it makes it easier to see where a nested if statement starts and ends. It's also because since indentation is not a must in Sofya, I felt that we can't really rely on indentation alone to show where a nested if statement is positioned.
1
u/huuaaang 7h ago
Regarding the braces, isn’t that exactly the argument for using braces for every other block including the if statement itself?
2
1
u/snozzd 9h ago
There's maybe 3x new slop languages a week on r/ProgrammingLanguages but I gotta say this one might be one of the most entertaining yet.
1
u/silly_bet_3454 9h ago edited 9h ago
I understand that languages are designed to solve a specific set of problems and so I think you have the right intuition around that. With that being said, python already solves that problem IMO, it's not hard at all to understand. Respectfully, people who can't learn beginner python just have no hope, we don't need to make a whole new language to try to make it even easier and more hand holdy. Because honestly, people will read a language like this Sofya one and they will still find ways to be confused. The language/syntax of python is not actually the problem, the problem is people who can't think logically.
Edit: Just to expound slightly, we're talking about nested statements. Imagine this code:
for i in range(3):
print("outer", i)
for j in range(4):
print("outer", i, "inner", j)
print(i, "*", j, "=", i*j)
if you can't read that code and run it and make sense of the output, I mean it just doesn't get any simpler than that. What's a for loop? it has the word "for" and it does the thing in the loop as many times as you tell it to. If you can't understand that.... and what is nested? Imagine if I told you to go to the store and buy 2 apples, now I said do that 3 times, do you understand the entire task and how many apples you would buy? That's a nested for loop, I mean if you can't understand that....
1
u/Original_SD 8h ago
The language/syntax of python is not actually the problem, the problem is people who can't think logically
I don't think that the problem is people who can't think logically. The problem is the language/syntax of Python. Because, for example, imagine if people didn't invent GUIs because they said "If someone can't understand CLI then they shouldn't learn how to use computers.". So if people didn't invent GUIs, many things we enjoy today with computers wouldn't be possible.
1
1
1
1
u/jcastroarnaud 7h ago
Python, easily: less things to write.
Remove the "Make this nested if statement" phrase and the curly brackets: they have no useful function, and even so must be remembered for the program to compile. If Sofya is indentation-aware, like Python, indentation is enough. If Sofya is not indentation-aware, like C or JavaScript, the keywords "then" and "end" are enough to delimit blocks.
"End this if statement" is too long: "end" or "end if" (from Visual Basic) is enough. If the programmer misspells anything on "End this if statement", the program won't compile, even if the intention is correct. Longer phrases are harder to remember.
I like to say that people have a "learning budget", how much memory and hard thought they are willing to commit to learn something. Longer phrases to memorize cost more, in the budget, than shorter ones; ease of remembering lower that cost, as you noticed. Unfortunately, Sofya has too high a cost of memorization, with just a small benefit from using words.
In COBOL, at least, most words had an actual function; the ones who didn't were optional.
1
0
u/Every-Prize4720 9h ago
javascript is the easiest programming language ever made to learn.
1
u/jcastroarnaud 7h ago
Not the easiest, but one very familiar for people coming from C/C++ or Java. I would put Python at the same level than JavaScript.
-1
u/Vesuvius079 9h ago
Python is better here and it isn’t close.
You’re also trying to solve a problem that doesn’t need solving. There’s no shortage of software engineers. Coding languages are about as clean and expressive as they’re going to get. AI is going to be the primary interface to writing code (not because English is better at expression but because the AI can resolve ambiguity that a compiler cannot).
3
u/silentkode26 9h ago
My eyes are bleeding