dart-lang / language

Design of the Dart language
Other
2.67k stars 205 forks source link

Terminating Tokens #72

Open munificent opened 6 years ago

munificent commented 6 years ago

This is a proposed solution #69, optional semicolons.

I'm calling it "terminating tokens" to differentiate it from other semicolon insertion rules we might investigate. In this proposal, the rules are roughly:

The "known ambiguity" part means that newlines are only used to act as implicit semicolons or to resolve ambiguities. A newline won't cause a syntax error on the next line. This lets us ignore most newlines, which minimizes the amount of migration and breakage.

On the other hand, the rules are fairly complex and subtle. We may not catch all of the ambiguities, and it may make it harder to introduce syntax in the future because it might cause a new ambiguity.

lrhn commented 6 years ago

Example:

{ v
-- x}

Since -- would be a terminating token (e1 is a full expression, and -- can start a new statement), then:

{ v
-- }

would have the same termination behavior as the first example, at least if you only look one token ahead. I don't think grammar based disambiguation at "known ambiguity" positions will be sufficient to avoid the new line from causing a syntax error. (Not saying that this is a problem, just that I'm not sure we can avoid causing a syntax error on the next line in general, while keeping the grammar unambiguous).

MarkOSullivan94 commented 6 years ago

In places where a semicolon is currently allowed, if the next token is a terminating token, no semicolon is required

If I've understood this correctly it sounds like there'll be a mix of code with semicolons and code without semicolons? If so, it sounds like it could be pretty confusing.

mrmitew commented 6 years ago

In places where a semicolon is currently allowed, if the next token is a terminating token, no semicolon is required

If I've understood this correctly it sounds like there'll be a mix of code with semicolons and code without semicolons? If so, it sounds like it could be pretty confusing.

Not really. Look at Kotlin. The language allows having optional semicolons but to be honest, I have never seen anyone actually mixing both unless the code has been automatically converted to Kotlin from Java and user didn't have the diligence to clean it up.

gamebox commented 5 years ago

@MarkOSullivan94 Sounds like a case for dartfmt :-)

mit-mit commented 5 years ago

Moving this to icebox for now; for more details, see https://github.com/dart-lang/language/blob/master/resources/optional-semicolons-prototype.md

PhilParisot commented 5 years ago

@mit-mit this is a feature I was really looking forward to, and can add a lot of "Coolest kid on the block" factor if done properly. People I've spoken to all thought Dart felt dated, it sounds dumb and trivial but making semicolons optional adds a lot of flash to a language.

andrewackerman commented 5 years ago

@PhilParisot Forgive me for saying so, but to me, it sounds incredibly arbitrary to say a language feels dated just because it uses semicolons. There are plenty of other features in Dart that make it feel like quite a fresh language (and there are a lot of reasons that Javascript, for example, feels like a dated language despite having semicolons be optional).

PhilParisot commented 5 years ago

@andrewackerman for sure and I completely agree I was just speaking about my personal experience and the people I spoke with which is obviously quite a limited perspective.

But if anything can give Dart (and by consequence Flutter) more appeal, even if just a little, we have to explore it further. Flutter is gaining great momentum and revived Dart as a language but before Flutter, Dart was almost lost beyond the point of no return. I now spent a lot of resources on Flutter and I don't want to see it fail, and for it not to it needs to become widely adopted.

I just see semicolons as a way to make it more appealing to some, maybe just a few, but a number we probably can't ignore. Flutter's ecosystem depends on it. Flutter's ecosystem is arguably its biggest drawback right now.

Just my two cents.

andrewackerman commented 5 years ago

@PhilParisot The ecosystem is absolutely one of Flutter's biggest drawbacks. But that goes well beyond such a minor concern like optional semicolons. There needs to be more comprehensive tools/tooling, robust third party libraries, in-depth and easy-to-use learning resources, streamline some things that need streamlining... the list goes on and on for things that Dart/Flutter could improve. The make-or-break point on whether Dart and Flutter catches wind and takes off or eats dirt is not going to be some small feature that is both complicated to implement and entirely cosmetic with subjective-at-best benefits.

We should not be trying to make Dart into a language that everyone will love, because that's not possible to achieve (and many languages in the past have fallen on their face for trying). Dart should focus on carving its niche and filling it well, and it's making great progress in doing that. Now the biggest things it needs require maturing the engine, fleshing out the more important and comprehensive features, and allowing the community to grow and develop their own contributions to the ecosystem.

(And in my honest opinion, people who decide not to use Dart/Flutter for such a petty reason as it having mandatory semicolons aren't people we should be taking seriously anyway. Being a programmer means learning many different programming languages, and that means getting used to a multitude of different styles and syntaxes. People who aren't willing to do that are, in my eyes, aren't that serious about being programmers.)

munificent commented 5 years ago

I think we should take all potential users seriously and users do have aesthetic preferences and those preferences do change in aggregate ways over time.

If you opened a restaurant thirty years ago, formica tables and disco pumping through the stereo would be great. Today, those might impact the restaurant's success, even though the food is equally good either way.

When we design a language's syntax, we have to be thoughtful about the expectations and psychology of our choices. Users have varying complex, often emotional relationships to the products they use. Of course, no one aesthetic choice will appeal to everyone because people are different. So what we do is aim for broad trends that appeal to a lot of people.

shinayser commented 5 years ago

Why don't you guys ask for Flutter's users opinion on the next "Flutter User Survey Q3"? This could be defintely a more democratic way to solve that.

munificent commented 5 years ago

Why don't you guys ask for Flutter's users opinion on the next "Flutter User Survey Q3"?

The Flutter Survey has asked about semicolons, so we have some of that data now. I'm not sure what the rules are around sharing it publicly, and we don't have a lot of detailed data, but there is some. Of course, this data is biased towards existing Flutter users, which is good and bad. Good because it focuses on the priority of real users. But it also unweights language changes that might improve adoption since non-users aren't counted.

shinayser commented 5 years ago

Why don't you guys ask for Flutter's users opinion on the next "Flutter User Survey Q3"?

The Flutter Survey has asked about semicolons, so we have some of that data now. I'm not sure what the rules are around sharing it publicly, and we don't have a lot of detailed data, but there is some. Of course, this data is biased towards existing Flutter users, which is good and bad. Good because it focuses on the priority of real users. But it also unweights language changes that might improve adoption since non-users aren't counted.

You have a interesting point. But when you say "non-users aren't counted", well, we can be sure (at least for the current state of flutter) the huge majority of non-users will probably coming from the mobile development right? Android and iOS developers, where both plataforms uses languages that have no semi-colons (Kotlin and Swift). That said, a language that has semi-collons for someone that comes from a language without it, seems "outdated". That was my thought when I started developing in Dart. Today I LOVE dart, but the semicollons stills a big pain for me. (I was Kotlin developer for years).

Abion47 commented 5 years ago

Android and iOS developers, where both plataforms uses languages that have no semi-colons (Kotlin and Swift).

Those platforms also use Objective-C and Java - languages that DO require semicolons. And while there are probably more people who primarily use Swift for iOS development than Objective-C (though this gets less true the more years of experience an iOS developer has), there are a TON of Android developers who use Java, not least of which because it's an extremely popular first language in universities and online courses for both mobile and general programming.

And let's not also forget the people coming over from React(-Native) and the Javascript world, who still can't make up their collective mind on whether or not semicolons are the root of all evil and likely never will. I'd argue against making semicolons optional if only to prevent that hundred-year war from spilling into Dart as well.

That said, a language that has semi-collons for someone that comes from a language without it, seems "outdated".

I can agree that going from a semicolon language to a non-semicolon language or vice versa is quite jarring the first time. That being said, I still consider it quite the leap in logic to go from saying a language that mandates semicolons is quite a different experience than a language that omits them to saying the approach of mandating semicolons as a whole is "outdated".

That was my thought when I started developing in Dart. Today I LOVE dart, but the semicollons stills a big pain for me. (I was Kotlin developer for years).

I can definitely sympathize with the idea that semicolons are a bit of an inconvenience, but really it just takes experience and eventually, you get to the point where you don't even have to think about it. And once you get to that point, it's a lot easier to remember not to use them than the other way around.

shinayser commented 5 years ago

If "semi-colons" just can't find a proper end, why not give the users the choice to use it or not? Maybe just a flag on the ".yaml" could be enough.

Abion47 commented 5 years ago

If "semi-colons" just can't find a proper end, why not give the users the choice to use it or not? Maybe just a flag on the ".yaml" could be enough.

Because it's not that easy. Making a language omit semicolons is already a somewhat complicated choice since you need to treat some whitespace as a statement terminator but also be able to tell when it's not terminating the statement. Making a language use semicolons as an option makes things even more complicated since you now need to be able to support when statements are explicitly terminated. And all this complication is assuming that you are designing a language with those rules from scratch; adding the rules to an already developed and in production language means you have to change the language rules to incorporate all these considerations without making any breaking changes (or at the very least as few as possible).

Making semicolons optional at this stage of Dart's life is going to be a very involved task, and it's going to have long-reaching consequences. As such, it's going to require an immense amount of effort from the Dart team, effort that could be spent on other more immediate, more universally beneficial, and/or less controversial concerns. And it's not like they can just work on this quietly while they work on other things since every language feature going forward would also need to be designed with optional semicolons in mind.

For these and a hundred other more specific reasons, this is not a decision that can be made so lightly. And since this is all over a language feature that is purely cosmetic and entirely subjective whether it's at all beneficial, my vote is to please just don't bother. Focus instead on making Dart more powerful, more flexible, and more extensible than ever before, and don't essentially press pause on Dart's development for months while the Dart team figure out how to approach this.

lrhn commented 5 years ago

My best guess is that Dart, with its current syntax, cannot be modified to make semicolons unnecessary without a massive change to how code is written (and a migration of all existing code).

Bob has already tried to deduce the rule system that would be needed to account for the way we already break statements, so that we won't have to modify too much code. The rule system was too complicated to be practically useful; users will need to remember the rules, and nobody would be able to do that.

The most likely incremental approach would be to make the syntax indentation dependent. That has other issues (it's nice enough when code is written, but how do you make a formatter for something where parsing depends on formatting, what happens if you cut-n-paste code with different indentation, how will an editor work with incomplete or unaligned code). It's not impossible, but it has its own issues.

So, maybe we should just create a completely new syntax, .dart+, which is not backwards compatible, but which allows all the same features as .dart code. Start from scratch. Drop semicolons (and commas!) and unnecessary parentheses, and ... everything we don't like, but in a way that can still be compiled back to .dart if necessary. (But that will also double our development tool complexity and split the community, so maybe not).

Abion47 commented 5 years ago

Creating a new language syntax from scratch would be just as much work if not more than to incorporate optional semicolons into existing Dart. Now, once Dart has better tooling support, someone (not in the Dart team) could independently create a DartX or whatever that will either transpile into Dart or compile into the same bytecode, but as it stands, it makes even less sense to justify essentially creating an entirely new official language that would need to be supported alongside Dart just to make semicolons optional.

munificent commented 5 years ago

Creating a new language syntax from scratch would be just as much work if not more than to incorporate optional semicolons into existing Dart.

Any new syntax would have a lot in common with existing Dart and other languages. We wouldn't say, reboot the entire expression syntax from scratch. Large portions would remain the same.

lrhn commented 5 years ago

Any new syntax would have a lot in common with existing Dart and other languages. We wouldn't say, reboot the entire expression syntax from scratch. Large portions would remain the same.

Maybe. Maybe not :smiling_imp:

g5becks commented 5 years ago

With dart being a language targeted at building uis, ergonomics are pretty important. Dart 2 was a major change , the entire type system was changed. Is there any way to implement this feature in dart 3?

munificent commented 5 years ago

Probably not this specific proposal for making semicolons optional, but yes generally there is a desire to revisit syntax and ergonomics relatively soon. We're mostly focused on extension methods and non-nullable types right now. After that, I think there is a tentative plan to circle back to usability and expressiveness features.

g5becks commented 5 years ago

@munificent Sounds great. I think you guys are doing a terrific job with the language btw.

Thanks.

nathanfranke commented 4 years ago

I think we should take all potential users seriously and users do have aesthetic preferences and those preferences do change in aggregate ways over time.

ok

steinathan commented 4 years ago

I came from Javascript to Typescript and I don't really need to write semi-colons because my code editor with some plugins (prettier) does this for me, is there a kind of thing available in dart where I don't need semi-colons to terminate statement lines? ( I suck at writing semi-colons)

Abion47 commented 4 years ago

@navicstein Not unless there is some obscure VS Code extension for it. There is no tangible plan to make semicolons optional in Dart, though there is an intent to revisit language-wide syntax and ergonomics once nullable types hit production.

rmControls commented 3 years ago

If there's a will there's a way....

jwarkentin commented 3 years ago

As a general engineering principle, less is more. Any syntax that doesn't need to exist, shouldn't. It only creates room for frequent mistakes (hence the plethora of "missing semicolon" jokes) and potentially inhibits readability.

Maybe I'm the odd one out or maybe I'm just one of a small number of uninvested potential users willing to bother commenting but I landed here because I got excited about Flutter and started digging into Dart, only to then discover that it surprisingly requires semicolons. Having spent the last decade largely working with JavaScript, Python, Kotlin, Ruby and shell scripting, it just seemed so dated and unnecessary. I don't miss C or Java and I'm definitely not looking to go back to the overly verbose syntax I had to write 20 years ago. I'm not sure yet if Flutter is worth the pain and nuisance. Languages should get out of the way, not in it. Verbosity and rigidity is what drove me away from Go. Kotlin is an absolutely brilliant example of how to design a language that's exciting to use.

Also, FWIW, Python has seen huge adoption and the syntactic whitespace hasn't inhibited that - plus, whitespace is optional when brackets and semicolons are used. Syntactic whitespace may not be awesome from a grammar standpoint but it can make the user experience awesome.

With all that said, I know Google doesn't have a reputation of listening to users so I was already hesitant about trying to adopt another Google technology. Just thought I'd try again to share some feedback.

Abion47 commented 3 years ago

@jwarkentin

Having also spent the last decade working in languages like Java, Dart, and C#, but also languages like Javascript, Swift, Kotlin, and Python, the presence of semicolons in a language (or lack thereof) has never been an issue - a language has it or it doesn't, and it doesn't take much of a mental effort to "switch modes" between the two. Likewise, having or not having semicolons has never impacted readability in the slightest in real-world code that I have written or seen, much like the inclusion of a period at the end of a single sentence doesn't suddenly make me hyper-aware of its existence.

The only programmers I have ever seen who have extensive issues with semicolons being included/excluded are people who operate exclusively in one idiom or the other, and they seem to have somehow generated their own subjective arguments why their side is objectively better. Programmers such as myself who switch frequently between them don't generally care as long as the language is consistent with its choice. It takes a little bit of effort to get to that point, sure, but it's not that big of a deal and, frankly, is part of the job description. Sure, I may have my personal opinions on the matter (I greatly dislike Python's use of indentation for blocks as I think it makes longer code files much harder to visually parse), I don't take to the streets with my torch and pitchforks because it's just that - a subjective opinion on an inherently subjective matter, and I certainly won't let those opinions limit my growth as a developer.

I would like to dispel one notion though. There is nothing "outdated" about a language utilizing semicolons as a terminator. FORTRAN is one of the oldest programming languages in existence (predating C by 15 years) and it doesn't use semicolons, and it was shortly followed by ALGOL which did, and then Lisp which didn't. For as long as there have been high-level programming languages, there have been languages that used semicolons and there have been languages that didn't use semicolons. The removal of semicolons isn't a recent development or modern fad - it's a cosmetic choice that has co-existed with the opposite idiom for both of their relative histories.

At any rate, what you say is true - less is more. However, that logic can also be applied to Dart's current situation: don't exert unnecessary effort. For better or for worse, Dart already uses semicolons, so to remove them now would be a monumental undertaking. As I have said in this very thread more than once, as passionate as people get about this topic, at the end of the day it is a cosmetic change with little practical benefit. I would much rather the Dart team work on improving the language in other more practical ways (such as ADTs, data enums, and the upcoming NNBD) than spending time on this.

I will close with this. If you think Dart (and, by extension, Flutter) are going to be a headache and a pain simply because they use semicolons, then you have sheltered yourself as a developer. You have lost the ability to be flexible and reactive by restricting yourself to a particular "family" of languages, and you have established a protective little bubble that you refuse to operate outside of. Not that there's anything wrong with picking a preferred specialty, of course, but that does tend to make you somewhat biased when weighing in on matters that fall outside of that specialty. Having such a stance as a developer means you are going to miss out on a lot of emerging frameworks and technologies simply because you can't be bothered to train yourself to be flexible in what tools you work with. (And I still don't know how your complaints regarding the verbosity of C, Java, and Go have anything to do with semicolons.)

jwarkentin commented 3 years ago

That's quite the leap of assumptions but ok.

Yes, semicolons have come and gone and still exist in plenty of languages. Newer and more popular languages today have made them optional. It's a trend and that makes them feel dated.

I have worked with an enormous variety of tech and I prefer things that don't impose more decisions or limitations than necessary on me as a developer and that seek to make life easy. To me this is bigger than semicolons.

My concern is the language design philosophy and decision making approach. More than having something that is technically cool, I need something that is practically cool. In my experience, that tends to go hand-in-hand with the willingness of a technology creator's willingness to listen to users. Creators define the community and the community largely defines the experience. ✌️

Abion47 commented 3 years ago

Newer and more popular languages today have made them optional. It's a trend and that makes them feel dated.

Newer programming languages like what? Julia doesn't use them, Elm does. Swift doesn't use them, Rust does. Kotlin doesn't use them, Dart does. It seems pretty even across the aisle of "newer" languages in terms of which ones use them and which ones don't.

And as far as the "popular" languages, the following is the top 10 programming languages in popular use according to the KIOBE index at the time of this writing (* = semicolons required, ** = semicolons optional):

Of those 10, 5 of them require semicolons, 2 require no semicolons, and 2 have optional semicolon use (though 1 of which still highly recommends their use for security purposes). Don't confuse "trendy" with "popular" or "modern". Only time tells which languages actually stick around, and so far time has told that having or not having semicolons plays no role whatsoever in that distinction.

More than having something that is technically cool, I need something that is practically cool.

There is no objective practical benefit toward requiring or omitting semicolon use. It is a purely subjective preference.

My concern is the language design philosophy and decision making approach.

And my concern is the "don't waste effort on cosmetic improvements when there are more practical and useful things to work on" approach. This would've been a good discussion to have years ago when the Dart language spec was first being deliberated. Now it's largely pointless, as making semicolons optional at this point would be FAR more trouble than it's worth, which is especially egregious considering the mile-long list of other things they could be working on instead.

In my experience, that tends to go hand-in-hand with the willingness of a technology creator's willingness to listen to users. Creators define the community and the community largely defines the experience.

And which members of the community should the creators listen to? From what I can tell, there are two equally-sized vocal minorities that either demand mandatory semicolons or demand their removal, and everyone else doesn't really seem to ultimately care.

jwarkentin commented 3 years ago

You can listen to the users that agree with your personal preferences or collect data about what makes devs happy and act on it. Just depends on the goals of the language and who it's trying to attract: people like you or people in general.

Anyway, I don't care enough to argue a about this but it's worth pointing out that the TIOBE index is not useful for understanding what languages are actually most popular for new projects or what languages developers actually want to use. Github stats and the annual Stack Overflow surveys are better ways to gauge that.

Abion47 commented 3 years ago

Just depends on the goals of the language and who it's trying to attract: people like you or people in general.

Well, there's your problem. The Dart team made their decision a long time ago on which direction they want to go where semicolons are concerned so that ship was sailed. And as far as attracting "people in general", that's not possible. Semicolon terminators are a polarizing issue so you will never please everyone, and making it optional is even worse in many ways. When you try to please everyone, you end up pleasing no one. Might as well just stick with what you have.

...the TIOBE index is not useful for understanding what languages are actually most popular for new projects or what languages developers actually want to use. Github stats and the annual Stack Overflow surveys are better ways to gauge that.

StackOverflow's 2020 survey listed Rust as the most loved language, and it won by A LOT. However, it's also worth mentioning that it is a list made by random programmers visiting StackOverflow and that the vast majority of respondents had less than 5 years of professional experience.

I have similar reservations with Github stats as literally anyone can throw code up into a repository and Github is by far the most popular repository platform out there. For example, Github lists Javascript as its most popular language and Python as a close second, which sounds impressive until you realize that a growing majority of the aging pip and node ecosystems consist of low quality or abandoned packages and that every single one of them has a repository somewhere. A surface glance also ignores two very crucial facts about those respective languages: Javascript is the de facto language of the web, and Python is the de facto language of data science and machine learning (not to mention a very capable scripting language), so they are naturally going to have massive numbers. What's far more interesting is that Java, despite being an ancient language by modern standards with many glaring flaws, is in third place, and Go, being a far younger language than any of those three, is not far behind.

StackOverflow surveys only show what is trendy and Github stats fail to show the whole picture. TIOBE may not measure popularity for new projects, but so what? New projects don't measure popularity or longevity, just what people are experimenting with. Instead, TIOBE measures what has been proven useful and marketable by the industry at large, not by whatever individual programmers happen to be tinkering with at a given time.

mit-mit commented 3 years ago

Hi there, Michael from the language team. Thanks for all the passionate comments. I'd like to clarify the current status. This feature has been "put on ice", not because we feel there is a lack of demand, but because we after multiple investigations concluded that it wasn't practically possible to do this within the current Dart syntax. Bob (@munificent) wrote up a detailed explanation. For example, in Dart variable declarations don't start with a keyword, but rather just the type. That makes it hard to disambiguate with our statement grammar. Further, we have very few reserved keywords, so even a basic line like hide bar is ambiguous (it could be a hide statement following an import, or it could be a declaration of a variable bar of type hide).

Right now we're in the middle of adding sound null safety. This is a very, very large change. Layering a change to our core language syntax op top of that would add a tremendous amount of risk to an already risky feature, which we found unacceptable. We may revisit this feature again in the future, but would then likely have to do so in the context of making some fairly fundamental changes to the Dart syntax.

awkj commented 3 years ago

I think the fundamental difference between dart and java, rust and many other languages is that most people learn dart just for flutter, and this part of people, including me, is very important to the programming user experience.

Also, thanks to munificent's article, I realized that my two concerns (type declaration and not having to write semicolons) turned out to be relevant in DSL parsing

let a:string = 3 vs string a = 3;

Or we can expect a big break change in dart 3 to bring these changes someday

C-style declaration syntax. We could require a keyword for declaring a variable like TypeScript, Kotlin, and Swift all do. Possibly even move types on the right

Looking forward to this moment

godenji commented 3 years ago

We may revisit this feature again in the future, but would then likely have to do so in the context of making some fairly fundamental changes to the Dart syntax.

Now that null-safe-by-default has landed, yes, please, follow, for example, Scala's lead and put types on the right. If optional semi-colons come about naturally from that change, fantastic, kill N birds with one stone.

And thanks for being open to pushing Dart into the brave new world of data classes, pattern matching, immutable collections (one can dream), meta programming, etc.

Abion47 commented 3 years ago

@godenji That's a massive breaking change to the entire language which will affect every code repository, package, Flutter plugin, app, and server backend that has ever been written in Dart. It's not worth it for such a subjective cosmetic feature.

shinayser commented 3 years ago

@godenji That's a massive breaking change to the entire language which will affect every code repository, package, Flutter plugin, app, and server backend that has ever been written in Dart. It's not worth it for such a subjective cosmetic feature.

Actually, not. Just making it optional like Kotlin, will break anything.

Abion47 commented 3 years ago

@shinayser Please read the Dart team's reason for putting this feature request on ice (not to mention the comment that I was responding to).

TL;DR - Making semicolons optional introduces too many compiler ambiguities to be practically viable with the language syntax as it is right now with type information coming before identifiers (e.g. String s = 'abc';). If Dart was changed to have type information after identifiers like how languages like Swift and Kotlin do it (e.g. s: String = 'abc', then it is more possible, but doing so will break virtually all code ever written in Dart. And doing that is not worth it just for the sake of making semicolons optional.

godenji commented 3 years ago

but doing so will break virtually all code ever written in Dart. And doing that is not worth it just for the sake of making semicolons optional.

At the time of release of dart-types-on-the-right, exactly zero existing code bases will break. And depending on the implementation, code bases that elect to upgrade to this hypothetical dart version, won't break either (i.e. if the language maintainers keep deprecated types-on-the-left around for a few releases).

Look, types-on-the-right isn't just about actually enabling optional semi-colons; it's about improving the language. Scala, Swift, Kotlin, etc. put the type definition on the right for improved type inference, and, as a rather nice side effect, ambiguities like those mentioned in the why-we-can't-implement-optional-semi-colons document, simply don't exist -- shouldn't be a surprise then that semi-colons are optional in all modern types-on-the-right languages.

That Flutter/Dart developers have brought up pain points such as:

indicates that all is not well in the house of Dart, this despite the absolutely compelling product that is Flutter. Developers coming from other modern languages will natually be taken aback by the current state of affairs. Fortunately at least some of the above items will be addressed, hopefully much sooner than later.

Abion47 commented 3 years ago

@godenji Of all the things you listed, the first item is the only item that requires type-on-the-right to be implemented. Everything else might be helped with such a change, but it is far from necessary (although granted, neither of us are in a position to concretely make that claim one way or the other, so we would have to wait for a Dart team member to weigh in on that). And several of the things you listed are features of functional programming, and seeing that Dart is not an FP language, there's no real need for it to support let alone prioritize.

Also, how would it break zero code-bases? It's a syntactical 180. Sure, they can release scripts or compiler flags or whatever to support/convert code written for previous versions, but that would require package developers to actually use them, which means old packages that aren't actively maintained but still provide a useful utility are doomed to fall by the wayside. The Dart team had a hard enough time supporting this transition with null-safety, and that was a change that involved little in terms of breaking syntax and most of what it did break in existing code bases were the product of bad coding practices that needed refactoring anyway.

[...] shouldn't be a surprise then that semi-colons are optional in all modern types-on-the-right languages.

I really wish people would stop using the lack of semicolons as evidence of a semicolon being modern. Semicolon-less languages have been around just as long as languages using a semicolon or some other delimiter. In fact, some of the first text-based programming languages written simply assumed one statement per line, thus predating the need for delimiters entirely. A design choice that predates semicolons by definition cannot be considered a "modern feature". It's a cosmetic choice with no objective effect on development within the language.

Abion47 commented 3 years ago

(There's a good Russian saying characterizing the users complaining about semicolons, types-on the left etc 😛)

This really hits the nail on the head.

The only people I see complaining about a language having semicolons are the ones who have pigeon-holed themselves into only using the same handful of mainstream languages that don't use them (Kotlin, Scala, Swift, Javascript/Typescript) using the same tired arguments that are subjective at best and betrays their inexperience at worst (it looks better, it's cleaner/decluttered, it's "modern", etc.). Instead of insisting that every language behaves like what you've convinced yourself is the "best", recognize that different languages are made by and for different mindsets and different practical uses and make yourself more flexible as a developer (which you should be doing anyway).

This is like complaining that Japanese is a dated, cluttered, or otherwise inferior language because "all modern languages use gendered nouns" (which is a feature of many European languages).

AlexanderFarkas commented 3 years ago

When you're constantly switching between plugins and dart code, it becomes hard to write semicolons in dart, while omitting them in Kotlin/Swift.

Abion47 commented 3 years ago

@SashaFarkas As someone who frequently switches between Dart, Kotlin, Javascript (with a semicolons-on style requirement), Python, Swift, and the occasional Rust and Scala for a living, no it doesn't. It's a learned skill called fluency, which you won't learn by just complaining about how hard it is and wishing every language was one way or the other.

godenji commented 3 years ago

are the ones who have pigeon-holed themselves into only using the same handful of mainstream languages that don't use them (Kotlin, Scala, Swift, ~Javascript~/Typescript).

If the value proposition of these languages were merely optional semi-colons, then I'd agree that yes, there's no advantage in using them over a language with required semi-colons. Obviously this isnt the case; otherwise this github repo wouldn't even exist -- in fact, most of the discussions by the language maintainers reference prior art (read: Scala, Haskell, OCaml, SML, TypeScript, etc.) when looking for ways to improve the Dart language.

Personally I've been writing Scala for nearly ten years, and in the last 3 years, TypeScript, both of which are, IMO, superior languages. The reams of boilerplate required to get anything done in Dart is truly astonishing, but when you're knee deep in it, after a while perhaps it starts to smell good?

Abion47 commented 3 years ago

If the value proposition of these languages were merely optional semi-colons, then I'd agree that yes, there's no advantage in using them over a language with required semi-colons. Obviously this isnt the case; otherwise this github repo wouldn't even exist -- in fact, most of the discussions by the language maintainers reference prior art (read: Scala, Haskell, OCaml, SML, TypeScript, etc.) when looking for ways to improve the Dart language.

You are replying on an issue thread titled "Terminating Tokens" where proponents of the change point to said languages as examples of good languages that do not use semicolons, thus implying that they are good languages because they do not use semicolons. If you think I am saying that those languages are bad languages, then you have missed my point by a wide margin. Those languages have a lot to offer in their own right, but so do languages that require semicolons. (You could say that the value proposition of Dart isn't just that it uses semicolons.)

There are plenty of features other than optional/absent semicolons that those languages have that Dart could benefit from. But seeing as this issue is focused on just one topic, those other features are irrelevant to the discussion here.

Personally I've been writing Scala for nearly ten years, and in the last 3 years, TypeScript, both of which are, IMO, superior languages. The reams of boilerplate required to get anything done in Dart is truly astonishing, but when you're knee deep in it, after a while perhaps it starts to smell good?

You are entitled to your opinion, of course, but I always get wary of someone's opinion when they start to throw out absolute terms like "superior" when referring to languages. But since you brought it up, here's my personal experience with those two languages.

Scala takes the JVM environment of languages and combines it with functional programming and ends up being much of the worst of both worlds. The idiomaticity of using pure functions and callbacks to control flow, scope, and state results in nested function calls which are a beast to read and maintain. The whole codebase gets bogged down as a result, and what productivity you save with features like union types and pattern matching gets lost in the muck and mire of "idiomatic Scala". Scala was a great flexible drop-in alternative to Java when it first appeared on the scene, but now that there are other options, Scala has no more reason to exist. (Seriously, Kotlin has just about everything that makes Scala great with virtually none of the things that make it terrible.)

Typescript is an interesting one because technically it's not a language in its own right, just a superset of Javascript that gets compiled directly into Javascript. The typing information naturally leads to a marginally safer codebase at compile-time, but that's pretty much it. It doesn't really offer any features over plain Javascript (because it can't), and it doesn't offer any form of runtime type protection whatsoever. It really only succeeds in two areas: self-documentation of the code and preventing obvious null/type-mismatch errors. And granted, that isn't nothing, but it's not enough to be able to replace the normal need for vigilance when dealing with Javascript in general.

I use Typescript because, for all its flaws, it's usually better than vanilla Javascript, while I wouldn't touch Scala with a ten-foot pole unless I had no other choice. How do they compare to Dart? They don't, because they are completely different styles of languages designed for different things and it's comparing apples to oranges (not to mention they are much older languages than Dart and have had much more time to work on features and gain maturity). It's pointless to compare languages to each other. What you do is compare languages based on their ability to perform certain tasks. I wouldn't use Dart to handle my backend, and I wouldn't use Typescript/Scala to write a cross-platform app. Both of those tasks are something all three could technically do, but use the right tool for the job.

hlung commented 2 years ago

I am sad to see this closed. Is there other way to not have to type semicolons after every statement? It may not be a big issue / only cosmetic change for someone, but it is a big issue for me. It is a subjective preference. I'm not saying to remove it (because it will cause big backward compatibility issues), but just make it optional or have compiler infer it.

srawlins commented 2 years ago

@hlung this issue is not closed.

Abion47 commented 2 years ago

@hlung this issue is not closed.

It's not officially closed, but it has been put on ice due to it requiring increasingly complex rule changes to the language syntax and thus requiring far more bandwidth on the team's effort estimate than they are currently willing or able to allocate in favor of other priorities. It may be revisited in the future, but it has been tabled for now.

Abion47 commented 2 years ago

but just make it optional or have compiler infer it

Making it optional is even more of an ask than removing it entirely, and both are bigger asks than you realize. Read the link in my other reply for details.