8 ms·
I don't get it. Why most "modern" languages are using such weird/contrived and hard to read syntax? I can understand that C++ evolved over a long time, starti
by stephc_int13 4y ago
I don't get it.
Why most "modern" languages are using such weird/contrived and hard to read syntax?
I can understand that C++ evolved over a long time, starting from C backward compatibility, I think mistakes were made but I can imagine the constraints.
But for Rust and Zig, they started from scratch, why do they have to use so many sigils (magic symbols)?
System programming should not look like sed or Perl.
- ModernMech 4y agoSystems programming is about very precisely specifying all aspects of the program down to the lifetimes and sizes of all variables, so that the compiler can make advanced optimization decisions that result in fast and compact binaries. All that specification comes with a lot of syntax, and some of it can be inscrutable considering the limited character set we're working with. That's how you get things like the turbofish, but it's there for a reason.
- Capricorn2481 4y ago>All that specification comes with a lot of syntax CommonLisp can do this without that syntax
- sealeck 4y agoCommonLisp is not really suitable for systems programming (hence the lack of systems software written in it).
- jedisct1 4y agoZig is very readable, and doesn't use many sigils at all.
- omgtehlion 4y ago.{ zig has a lot of .{ } }
- stephc_int13 4y agoThis part is ugly and annoying but not too difficult to read.
- stephc_int13 4y agoZig uses ? and ! in ways that are difficult to read IMHO, for example.
- pwdisswordfishc 4y agoWhat is hard to read about Rust and Zig?
- Georgelemental 4y agoTo give an example, the functionality of `?` in Rust used to be provided by the `try` macro (https://doc.rust-lang.org/core/macro.try.html https://doc.rust-lang.org/core/macro.try.html). Dedicated syntax was later added because it made a lot of code cleaner and easier to read, at the expense of a minimal upfront learning cost.
- anon291 4y agoMany people complain about language's use of symbols, and then fail to think of what it would look like without the symbols. Realistically, humans are incredibly good at manipulating symbols to reduce verbosity, it's why I just used an apostrophe.
- stephc_int13 4y agoI don't mind a bit of verbosity. With words, on multiple lines, not with an esoteric combination of sigils.
- anon291 4y ago> I don't mind a bit of verbosity. With words, on multiple lines, not with an esoteric combination of sigils. Realistically, if you were expressing the amount of stuff going on in these lines, then you would want symbols.
- singularity2001 4y agoSwift is modern and beautiful, but crippled by its ecosystem.
- RazrFalcon 4y agoWhile I do like Swift and wish Rust would look as nice, it doesn't have references and lifetimes. Those two alone make code way nicer. Anonymous closure arguments, aka $0, are probably the ugliest part of its syntax. numbers.contains(where: { $0 > 0 })
- klibertp 4y agoThere's no such thing as hard to read syntax[1]. There's only syntax you're unfamiliar with, or syntax that isn't supported by your editor yet. That's it. Don't project your reaction to unfamiliarity as a general law. Instead, either ignore the languages with syntaxes you don't like, or just go and learn them before forming an opinion. And ffs don't talk about syntax being "pretty" or "ugly". That's the epitome of subjectivity, I have a hard time trying to understand why would anyone out of their teens want to argue about that. Ancient Romans knew that de gustibus non disputandum est, yet here we are, "discussing" what is beautiful and what's not. [1] There are some constraints that stem from the optics and mechanics of an eyeball. Other than that, it's purely subjective.
- stephc_int13 4y agoI strongly disagree. I think that style is a matter of taste, and some part of syntax can be regarded as styling decisions, like with placement of tabs vs spaces, braces alignment, snake_case vs camelCase etc. But there is a continuum of syntax readability, brainfuck is less easy to read than Perl that is still easier to read than Sed. And I think exactly the opposite about familiarity, the less familiar you are with a syntax the better your judgment is about its readability. Of course that can be learned, but that is not the point. Programming languages should really strive to be as easy to read as possible, even at the cost of being more difficult to write. Code should never look arcane, especially to someone unfamiliar with the language / codebase.
- klibertp 4y agoBrainfuck is harder to read not because of the syntax, but because it describes very low level semantics. Actually, it's not even harder to read - it's harder to comprehend. You're conflating comprehensibility with readability - they're not the same. There's a reason why people get tested for "reading comprehension" and not just "reading". In other news, I now know that you have your own idea about how programming languages should be. Good for you. That idea is not grounded in any research, because there is no research available, but you're welcome to have it, and when you write your own language you're welcome to stick to it. Logical conclusion of your last statement is this: https://en.wikipedia.org/wiki/Inform#Example_game_2 https://en.wikipedia.org/wiki/Inform#Example_game_2 I'll leave you to think about why it's not the most popular programming language on the planet. I'd say more, but I don't want to inconvenience Daniel any more than I already have the previous time, so let's just strongly agree to strongly disagree.