Slashdot Mirror


The Swift Programming Language's Most Commonly Rejected Changes (github.com)

An anonymous reader writes: When Apple made its Swift programming language open source in early December, it opened the floodgates for suggestions and requests from developers. But the project's maintainers have their own ideas about how the language should evolve, so some suggestions are rejected. Now a list has been compiled of some commonly rejected proposals — it's an interesting window into the development of a language. Swift's developers don't want to replace Brace Syntax with Python-style indentation. They don't want to change boolean operators from && and || to 'and' and 'or'. They don't want to rewrite the Swift compiler in Swift. They don't want to change certain keywords like 'continue' from their C precedents. And they have no interest in removing semicolons.

24 of 339 comments (clear)

  1. People actually *like* Python whitespace? by Anonymous Coward · · Score: 5, Insightful

    Swift's developers don't want to replace Brace Syntax with Python-style indentation.

    I am appalled that enough people like the idea of significant whitespace in Python to actually ask for it as a feature.

    1. Re:People actually *like* Python whitespace? by mveloso · · Score: 5, Insightful

      Yeah, it's crazy. "Let's make some invisible character with a variable width significant."

    2. Re: People actually *like* Python whitespace? by BitZtream · · Score: 4, Insightful

      If you're using variable-width fonts for coding, you're doing it wrong.

      Also, in Python you indent the same way you should be doing anyway, just without the braces. Unless, of course, you're also doing indentation wrong.

      You're right, designing a language the fucks up based on different text editor default preferences makes the users that are complaining about that design decision wrong ...

      Please explain the advantage of white space sensitivity without sounding like a moron, go:

      --
      Persistent Volume manager for Kubernetes - https://github.com/dwimsey/openshift-pvmanager
    3. Re: People actually *like* Python whitespace? by Anonymous Coward · · Score: 5, Insightful

      because when i'm moving blocks around, whitespace changes turn my original program into a
      perfectly valid other program which has nothing to do with my original intent ..umm.wait...

    4. Re: People actually *like* Python whitespace? by TheRaven64 · · Score: 4, Interesting

      I'd object to it a lot less if it would either do the sensible thing and treat one tabulator as one indent level and erroring at parse time if a line contained any spaces before the first non-space character, or the slightly less sensible thing of treating n spaces as one indent level and erroring if the line contained any tabs before the first non-whitespace character. Allowing tabs and spaces to be mixed at the start of a line so that your code may look correct but is interpreted differently is annoying and is one of the many reasons why the only times I've ever written Python have been when I've fixed someone else's 'working' and shipped code. It's even worse than the semantics of else clauses on for loops for introducing subtle bugs.

      --
      I am TheRaven on Soylent News
    5. Re: People actually *like* Python whitespace? by Anonymous Coward · · Score: 5, Informative

      You're right, designing a language the fucks up based on different text editor default preferences makes the users that are complaining about that design decision wrong ...

      Please explain the advantage of white space sensitivity without sounding like a moron, go:

      The advantage of white space sensitivity is that it reduces the visual noise when producing and reading source code, and it helps build in a consistent look and feel for the language. For instance with F#, the designers are using white space sensitivity to remove a large amount of boiler plate syntax, which makes for a much more concise language. Conciseness is very important because you can fit complex data manipulations into small blocks of very readable code, which is the core of the design team's tenant of "Do more with less code".

      If you want to avoid, indentation errors you use the begin ... end blocks, but for most functions and types they are quite unnecessary. If you want to compress multiple assignments on a single line, use the let ... in ... syntax. F# also makes \t illegal when white space sensitive code is in use. With proper language design, white space sensitivity is a productivity advantage, and it does not sacrifice program readability.

      Does this mean that white space sensitivity is outright superior to visual token semantic block delimiters? No of course not, it does mean that there is a trade-off space for the feature within the language's design so some languages are designed better than others.

      There is also a trade-off space for using text editors instead of IDEs for programming. Sure you can stick to your favorite text editor, but you lose a large amount of useful information and features that IDEs that understand your programming language will give you, and since text editors are text editors and not program editors, they are completely correct when they display whitespace in semantically incorrect representations of the programming language.

      Some whitespace sensitive languages like Python have warts when you use a language unaware text editor because Python's design considerations did not standardize and enforce in the interpreter how to use whitespace from different text editors. However, if you are using a text editor for programming, you are in a sense "doing it wrong" for many programming languages. Maybe you are fine with your current language, but if you are going to try a different language you should use the appropriate tools for that language. Use the right tools for the job. You wouldn't try to cut a 2 by 4 plank with a jeweler's saw would you? If not, do not use a text editor that is Python agnostic to edit Python code. It is really that simple. If you are collaboratively creating Python programs with others, adopt PEP-8.

    6. Re: People actually *like* Python whitespace? by TheGratefulNet · · Score: 5, Insightful

      100% this!

      twice in the first few months of my learning python, I saw someone post code on a web forum that was impossible to know what the intent was; because the spacing was messed up (web forums do this all the time) and this, alone, proved to me how stupid this braceless style of space-sensitive indenting was.

      there are 2 things and they should NOT be combined! one is for the compiler to define what a block is. the other is documentation for humans, so we know what the block is.

      and yes, they do act differently. I can use white space to tell a HUMAN things but white space is quite a stupid way to talk to a computer.

      there's a lot I like about python, but guido is just plain wrong, here, and its frustrating that he won't admit it.

      --

      --
      "It is now safe to switch off your computer."
    7. Re: People actually *like* Python whitespace? by NostalgiaForInfinity · · Score: 4, Funny

      Please explain the advantage of white space sensitivity without sounding like a moron, go:

      if (flag)
          if (other_flag) do_this();
      else
          do_that();

    8. Re: People actually *like* Python whitespace? by cerberusss · · Score: 4, Informative

      For this reason, your editor should have a setting that visually displays tabs. Put the following line in your ~/.vimrc if you use that. It also shows trailing spaces.

      set listchars=tab:.\ ,trail:-

      Just posting to add this tip. I totally agree with you, that the above situation should be an error condition.

      --
      8 of 13 people found this answer helpful. Did you?
    9. Re: People actually *like* Python whitespace? by Xyrus · · Score: 4, Informative

      You're right, designing a language the fucks up based on different text editor default preferences makes the users that are complaining about that design decision wrong ...

      Please explain the advantage of white space sensitivity without sounding like a moron, go:

      The advantage of white space sensitivity is that it reduces the visual noise when producing and reading source code, and it helps build in a consistent look and feel for the language.

      Replace all punctuation in written English by varying white space demarcations. You know, like replace a comma by two spaces, a period by three, and exclamation point by four, etc. Would that improve the language, or make it painful to read, format, etc.

      Or how about something a little more relevant. Math has all kinds of logical demarcations. How about just replacing the parentheses with white space? Does that make it concise and easier to read?

      The number one source of errors I (and many others I have worked with) have come across in my years of dealing with Python have come from white space errors. Using white space as a significant demarcation instead of just a visual cue in a language (or just to make it pretty/readable) is beyond stupid, as literally every person and every editor have different preferences and ways of handling white space. Even changing fonts can screw it up.

      I can cut and paste C, C++, Java, etc. code from anywhere to anywhere and have it be interpreted in exactly same way as it was intended. You CAN'T do this with Python because you have no idea what white space characters you're actually grabbing, nor do you know how your particular editor/OS/etc. will attempt to format it.

      This should be obvious. Don't use an invisible and variable set of characters as logical delimiters.

      --
      ~X~
    10. Re: People actually *like* Python whitespace? by TheGratefulNet · · Score: 4, Interesting

      also, 100% this.

      I could care less what human-A did for his indenting, at least on C code. if the code works and compiles, I can FIX his indentation and not ruin a thing; only make it more readable.

      there is no concept of a re-indent or auto-indent (such as found in emacs, for example) for python. you can't do it. because as I posted before about this: there are 2 things and they should never be mixed. one is a cue to the compiler what a block is, and the other is a cue to the HUMAN what a block is. and combining them is what guido fucked up, on.

      in C, I can do whatever wild indenting I want and a re-indent can fix it so I can read it again. I got very used to that. code was ROBUST in this way, and humans can mess with the look of it without doing harm. if I move a block from some inline code to a nested routine, it always ALWAYS works. not so in python. in fact, I'm not even sure HOW to move a block from one level of indent to another with perfect safety. its just STUPID!!!! stupid beyond belief to those of us who have been writing code for decades (I'm mid 50's and have been doing software eng work since my teens).

      part of me wants to add a feature to the language so I can add braces back again, then preproc the source to remove it as a phase before running the code. I know it won't be accepted by anyone in my company but it would restore sanity to my own python projects, at least.

      imagine a source code control system where check-out gets you those braces, you do your edits and each time you save the file to local git or svn (etc) it removes the bad chars and makes it 'real python' again so you can run it. that way you kind of have it both ways and editing, at least, is now more safe.

      --

      --
      "It is now safe to switch off your computer."
  2. They're called architects by BitZtream · · Score: 5, Insightful

    The people who have their own ideas about how it should evolved are called architects, and they have their own opinion so that the language has some sort of coherency and isn't a complete and utter mess, which is what results when you do design committee.

    Nice inflammatory summary though, no bias.

    Swift's developers don't want to replace Brace Syntax with Python-style indentation.

    No shit, they aren't retarded. Have you people not learned how stupid that is yet, how many retarded bugs do you have to have from the wrong spacing before you get it through your heads that it was a stupid fucking idea?

    They don't want to change boolean operators from && and || to 'and' and 'or'.

    No shit, they aren't idiots.

    They don't want to rewrite the Swift compiler in Swift.

    No shit, they aren't retarded. Other than proving something, WHY WOULD YOU? NO ONE DOES THIS unless they are just trying to swing their dick around. You write your languages in C with ASM for the places it makes sense. Unless you just like to make yourself need two compilers, one to compile your language so you can build your compiler in your language. Again, retarded.

    They don't want to change certain keywords like 'continue' from their C precedents.

    No shit, they aren't idiots.

    And they have no interest in removing semicolons.

    No shit, they aren't idiots.

    If you had half a clue, or simply had read the second sentence under most of those things I wouldn't be the one pointing out that you're not qualified to be talking about language enhancements. Hell, as stated, almost all of these things are changes for someones personal pet preference, not because its useful for anything.

    Swift IS INTENTIONALLY C like, intentionally. ALL of those requests are utterly stupid when your talking about a language that is intentionally like C/C++. If you want python ... USE PYTHON.

    --
    Persistent Volume manager for Kubernetes - https://github.com/dwimsey/openshift-pvmanager
    1. Re:They're called architects by bill_mcgonigle · · Score: 4, Insightful

      Thank you.

      If I _had_ to write python, for some reason, I'd probably write a little pre-compiler to take something maintainable that I'd write and output whitespace-tokenized python.

      I don't see why the people who want Swift to be Python don't just write one of these of their own. They'd learn why nobody wants to use whitespace as a token separator but after that presumably they'd be happy in their mad little world writing code the way they want and finally compiling it with the Apple compiler.

      In the perl community we never told somebody they were crazy if they wanted to code perl in some insane, dead, or fictional, language -- just write a module for it and don't bother us with your dysfunction. What manager at Apple decided it would be a good idea to take feedback from the peanut gallery?

      --
      My God, it's Full of Source!
      OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
    2. Re:They're called architects by TheRaven64 · · Score: 4, Interesting

      The problem with this attitude is that compilers really should be written in a language that's good for writing compilers. This leaves you two choices:

      • Write your compiler in an inappropriate language.
      • Make your language good for writing compilers, at the expense of its intended uses.
      --
      I am TheRaven on Soylent News
    3. Re:They're called architects by Kohath · · Score: 5, Insightful

      As a python programmer for 15 years, I've never had a bug caused by indentation changing the logic.

      "It's never been a problem for me" is not an argument in favor of anyone using it except you.

      "My plan/software/language has a zillion failure modes and hidden quirks, but I have them all memorized and they don't cause me problems. Let's roll this out to the general public."

  3. Eminently Practical by SuperKendall · · Score: 5, Interesting

    The list and the explanations of why things were rejected really does a great job of illustrating why I like Swift - because the people behind the design have a great amount of practicality tempering the desire to include every modern language feature. It makes Swift nicer to work in, and in the long run will make it a LOT nicer to maintain.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  4. Re:Duh by JustBoo · · Score: 5, Interesting

    Don't like it? Fork it!

    Or don't use it. It is not as if we were short of programming languages.

    Perhaps you guys are not aware that Swift is a language to program Apple DuH-vices. iPhones, iPads etcetera. There are NOT a lot of choices of languages when it comes to that.

    But I am glad Apple is not buying the Script Kiddies Crap and 'dumbing' down the language. Python is the last language on Earth anyone should be modeling a professional language on. The Last.

  5. Channels that apply line.strip() for line in msg by tepples · · Score: 4, Interesting

    Also, in Python you indent the same way you should be doing anyway, just without the braces. Unless, of course, you're also doing indentation wrong.

    Several channels through which people discuss program code strip leading and trailing whitespace on each line. This transforms all programs passed through them into programs that are "doing indentation wrong." Yes, in theory, these channels are defective. Yet people work around these defects using tools such as GNU indent because a defective channel gets work done better than no channel at all.

  6. Re:Rust has made Swift obsolete already. by Anubis+IV · · Score: 5, Insightful

    [Rust] is the successor to Swift, and is an improvement in every way.

    By definition, how can Rust be a successor to Swift, when Swift wasn't even announced until 2 years after Rust's first release?

    I don't have a horse in this race, but statements like that one I quoted make it fairly evident that your comments carry a heavy slant. Moreover, given the pedigree of both Rust and Swift, it seems like a pretty bold claim to suggest that either one could be "an improvement in every way" over the other. That's made even more true by the fact that both are in active development with lots of changes happening and that both of them are borrowing the best ideas from the other.

    Choose the language that suits your task and platform best, whether that's Rust, Swift, Go, C++, Python, ASM, or something else entirely. Don't lock yourself down to one view for how all programming is supposed to work, since that's a quick path to obsolescence.

  7. Re:Python by cdwiegand · · Score: 4, Insightful

    It's called copy and pasting code. I don't want to have to worry about going over every line ensuring the indentation carried over and either adding or removing it to every line. If the language is brace-based, I can hit Format Document and it adjusts it. Without a delimiter like that, you can't "Format Document".

    --
    . Define sqrt(x) as something really evil like (x / rand()), and bury it deep. Watch your coworkers go nuts.
  8. Re:Python by JazzHarper · · Score: 4, Interesting

    In 1976, Stuart Feldman, the author of make(3) at Bell Labs, realized too late that using tab as a significant character (to distinguish recipes from rules) in makefiles was a Bad Idea. In an interview, he admitted, "And then a few weeks later I had a user population of about a dozen, most of them friends, and I didn’t want to screw up my embedded base. The rest, sadly, is history."

  9. Re:Duh by Anonymous Coward · · Score: 4, Informative

    Object Pascal and C++ and C# and JavaScript to name a few. You can program for iOS using any language which provides you with a toolchain to target iOS.

  10. Wrong, I don't by SuperKendall · · Score: 5, Insightful

    Indentation is how you communicate block structure to a human reader. You're going to indent your code anyway

    No, I am not. That's why I have a computer, to do tedious things for me - like correctly indenting code... pretty much every function I write I can write loosely and then simply tell the editor to re-indent my code correctly.

    And that is why Python and Fortran are really the only languages I dislike, because they are the only ones (that I have used anyway) where the code CANNOT BE FORMATTED, because you have to know what code does in order to format it. In Fortran a character being present at a certain indent level meant that line was really a comment - oops!

    But in Python you are far worse off, because the wrong indent changes execution, changes what you meant the program to do. There's no way for a formatter to guess how the code SHOULD be structured, so it cannot be - ensuring a life of tedium and very probable mistakes for coders that follow after the first one.

    Python is the Wolverine of coding languages, the ultimate loner language.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  11. Re:That's the whole problem by igloo-x · · Score: 4, Insightful

    That inability to choose how to sculpt the visual aspect of code in Python is a monstrous shortcoming

    No, I think it's perfectly in-keeping with the rest of the zen of Python. Namely, there should be one (and preferably only one) obvious way to do something.

    There's no bickering about bracing style, or special snowflake developers applying their own misguided style on everything. It discourages people from writing deeply nested, difficult-to-follow logic in favour of simple, flat code.

    And when everybody sticks to the same conventions, it magically becomes a lot easier to read, understand, share, work on, learn from and contribute to everyone else's code.