(no title)
foobarbaz321 | 1 year ago
In fact, Smalltalk takes this much further, such that basically all flow control (including if-then-else) is handled as message sends (e.g. if-then is just a message sent to the Boolean object taking a block as it's argument).
The downside is the syntax can feel a tad clunky. The upside is incredibly simple and consistent language grammar, while making it trivial to create new flow control mechanisms since the language has all the tools baked in (primarily first class blocks).
pjmlp|1 year ago
hi-v-rocknroll|1 year ago
foobarbaz321|1 year ago
[deleted]
anal_reactor|1 year ago
[deleted]
ivancho|1 year ago
devjab|1 year ago
How many C style context even really exist today? The block separation by single characters is ok. Using (), [] and {} to separate things makes things easier on the compiler, but it’s probably down to personal preference whether you like that syntax or not. I certainly vastly prefer the more simplistic approach where you don’t have to wrap everything in brackets. Like a loop… why does it really have to be inside a () denotion? Similarly I prefer Pythons indent to {}’s. Which can technically make your code harder to read, but if your Python code is hard to read it’s likely bad. Not always, but most of the time. I guess {} is better than BEGIN END, but maybe not in terms of readability.
The end of line character, ; is also sort of unnecessary for the most parts. Again it’s mostly a relic which helps the compiler, and some people like it while others don’t.
Modern loops look nothing like they did in C. Neither does variables or properties.
The use of English for a lot of things, or the use of western character sets, is also sort of bad in the modern world. Which is part of the reason behind the huge popularity of Go in Asia. Not that it’s so bad as it’s just how it is and everyone has adopted.
Anyway. Modern C style syntax like you’ll finds in C# or Java is rather cumbersome in my opinion. Rust sort of falls into this category but at least with Rust it’s very easy to define ownership of your stored data as you pass it around in your code. But almost all of it is exactly that… modern. Almost none of it is from C and a lot of it would not have existed without languages like Ruby.
You also have to keep in mind that Ruby predates the modern C syntax. As others have mentioned it’s been influential on the modern C syntax, but it was also made in a world where they modern syntax simply didn’t exist.
saurik|1 year ago
stouset|1 year ago
The popularity and usefulness of Ruby’s block-based control flow, which you seem to take issue with, is almost certainly largely responsible for the adoption of lambdas in… basically every modern language, not to mention being backported to existing languages like C# and Java.
Frankly your hot take is terrible. C was an amazing language, but there are an infinite number of practical and effective ways to improve upon it. Particularly having just admitted that you’ve never actually used the syntax in question it’s honestly astonishing that your first instinct is to jump straight to posting about how much better the C approach is.
Hell, you’d be hard-pressed these days to find a modern language that uses C-style `for` loops. They might say `for` on the tin, but they’re much closer to Ruby-style enumerators than they are to C-style setup-condition-increment control flow. With, of course, the caveat that that’s all they ever can be since they’re keyword syntax rather than just a method.
What a sad world this would be if everything interesting in programming was discovered by K&R in the 1970s.
krainboltgreene|1 year ago
You're talking about a 25 year old decision.
bhaak|1 year ago
You are crazy if you think that a C style for loop is good designed. It's way to powerful but terse and obtuse to do correctly beyond the simplest application.
C style syntax as a whole is also nothing special if you mean semicolons and braces.
If you include stupid design decisions like braceless blocks in "C style syntax" I wouldn't even know what to think of that opinion.
jojobas|1 year ago
Funnily, regardless of deeply different implementations, for loops look almost the same in Python and Ruby.
crabbone|1 year ago
I hope you don't mean Ruby (I haven't investigated Smalltalk grammar). Ruby grammar is atrocious due to string interpolation stuff. Nothing to do with handling loops or conditionals, but still... Ruby is not at all an example of a language with good grammar.
Unfortunately, it's surprisingly rare for popular languages to have good grammar. If you look at it from up close, there are lots and lots of really bad decisions in virtually any language in common use today. I think, this is just not a high-priority concern for most users, but still...
Joker_vD|1 year ago
pjmlp|1 year ago
https://richardeng.medium.com/syntax-on-a-post-card-cb6d85fa...