News for hackers. Stuff that matters.
Re:Swift System Is Now Open Source by wwright on Friday September 25, 2020 @03:56PM (#24593513)
I don't think Swift really competes with Rust or Go at all.

- Go aims to be simple enough for many engineers to be productive with little investment.

- Rust aims to be extremely reliable and efficient.

Swift is very complex, and makes many compromises away from reliability or efficiency in favor of application use cases.

Swift may fill an interesting role for a "native C#" that is mostly reliable, mostly efficient, and somewhat productive, but on the other hand, C#, OCaml, Java, Kotlin, and so on already have various answers to that, and they're only becoming better at it.

The only real advantage it has (as far as I can tell) is iOS (and TensorFlow almost as a knock-on of being the only serious language for iOS).

Re:Swift System Is Now Open Source by throw_m239339 on Friday September 25, 2020 @08:57PM (#24595542)
> - Go aims to be simple enough for many engineers to be productive with little investment.

Go isn't simpler, there is just a defered cost engineers pay later on when it turns out one cannot just do away with complexity by deeming it irrelevant.

Re:Swift System Is Now Open Source by higerordermap on Friday September 25, 2020 @11:26PM (#24596175)
But swift isn't as easy as python or javascript either. It is arguably more complex than Java, C#. And probably more complex than Kotlin. It is sure less complex than scala.
Re:Swift System Is Now Open Source by skohan on Saturday September 26, 2020 @04:46PM (#24601980)
IMO Swift is easier than JS or python for medium to large projects. Once you get to a certain scale of codebase where you can't keep all the systems in your mind at one time, weakly typed, interpreted languages start to reach a point of diminishing returns, and the inability to catch issues at compile time starts to be missed. You can mitigate this by writing a lot of tests, but this creates a large additional workload which more than outweighs the additional complexity you would have encountered working with a language like Swift in the first place.
Re:Swift System Is Now Open Source by higerordermap on Sunday September 27, 2020 @11:44PM (#24612756)
I know the advantage of static typing (see my other comments).

Swift just seems quite more complex for average programmer.

Re:Swift System Is Now Open Source by skohan on Monday September 28, 2020 @03:38AM (#24614010)
I think one advantage of Swift, as compared to say Rust, on this topic is that one of it's core values is the concept of "gradual disclosure". In other words, Swift is designed in such a way that you can start programming at a low level of complexity and produce functional programs, and over time you can introduce more complex and esoteric concepts into your code as you become more familiar with the language.

If you're jumping straight into a large, mature code-base I can understand how it might seem complex, but it's very possible to write Swift code which is as simple and readable as Go code. The same can probably not be said for C++ or Rust, where there's a certain baseline complexity which cannot be escaped.

Re:Swift System Is Now Open Source by Thaxll on Friday September 25, 2020 @09:26PM (#24595673)
Some FUD right there... What exactly is the deffered cost? Give real examples please.
Re:Swift System Is Now Open Source by earthboundkid on Friday September 25, 2020 @09:59PM (#24595840)
I love Go, but there is a strong case that Kubernetes has a messy codebase because Go didn’t have good dependency management or generics when they started it. The strength of the ecosystem in other areas let them get started and now they have the tragedy of success, a la Wordpress.
Re:Swift System Is Now Open Source by studmuffin650 on Friday September 25, 2020 @10:15PM (#24595907)
Part of the issues with Kubernetes is that it started as a Java project and then it became a Go project. If anyone started a large Go project with that mindset it would look messy no matter what you did.
Re:Swift System Is Now Open Source by bad_user on Saturday September 26, 2020 @02:05AM (#24596768)
Can you point to any large Go project that isn’t a mess?

I agree that from a single sample you can’t reach conclusions, but “it was their fault” isn’t a great defense.

Re:Swift System Is Now Open Source by mehrdadn on Saturday September 26, 2020 @06:44AM (#24597788)
Is rclone a mess? I don't do Go, but some glances at it don't scream "mess". https://github.com/rclone/rclone
Re:Swift System Is Now Open Source by jtlisi on Saturday September 26, 2020 @06:02PM (#24602524)
Re:Swift System Is Now Open Source by nix23 on Saturday September 26, 2020 @05:17AM (#24597467)
Can YOU point to any large project that isn’t a mess?
Re:Swift System Is Now Open Source by nojvek on Saturday September 26, 2020 @11:10AM (#24599379)
Isn’t mess relative to the beholder of the eye.

Many large projects may look like a mess but their success is because they got the high level architecture right and perhaps had the moat of a large tech behemoth behind them.

VSCode, Tensorflow, Kubernetes, Go, Typescript, React. These are a few that come to mind.

At a high level, they are all fantastic projects and perhaps messy in their own way, but they are absolutely fantastic, hardened proven codebases with ~millions of users.

Re:Swift System Is Now Open Source by oDot on Saturday September 26, 2020 @06:03AM (#24597626)
Servo
Re:Swift System Is Now Open Source by nix23 on Saturday September 26, 2020 @07:36AM (#24597999)
Ahh with 3250 open issues and 8k closed ones? With the main-driver being Mozilla?
Re:Swift System Is Now Open Source by Thaxll on Friday September 25, 2020 @10:52PM (#24596047)
There is one video about the Kuberentes code base: https://www.youtube.com/watch?v=4VNDjwzzKPo and it has nothing to do with Go language iteself, it's about organizing the repo and code strucutre.

Kubernetes is a complex distributed system with over 2M loc, not matter what the language you use there going to be some issues.

It's probably one of the largest open source project out there.

Re:Swift System Is Now Open Source by earthboundkid on Friday September 25, 2020 @11:04PM (#24596092)
2MLOC is too big for what it’s supposed to be doing. That’s a sign that something went wrong. I wouldn’t blame Go qua language per se, but the lack of generics and lack of dependency management (when they started) couldn’t have helped.
Re:Swift System Is Now Open Source by DelightOne on Saturday September 26, 2020 @07:06AM (#24597890)
Yeah lets just use Docker Swarm or Nomad. Or which features would you remove to make it less bloated?
Re:Swift System Is Now Open Source by johannes1234321 on Saturday September 26, 2020 @07:54AM (#24598089)
The argument - as I understood it knowing only little about Go and Kubernetes - wasn't about bloat in application features, but bloat caused by the language. The stated argument was "missing generics" - missing generics means that similar algorithms have to be re-created multiple times instead of being reused. Thus comparing this tonnaother language might be interesting.

For example C++ is extremely powerful in writing generic code: Make it a template and and provide a set of of traits to modify the behavior and you get a set of algorithms you can re-use for anything – at the cost of unreadable code in the impelemntation (if you aren't careful; with a chance of quite precise code on the call side) and of course with the bloated version in the resulting binary (after compiler instantiated and inlined (thus copied) everything; where the programmer typically doesn't have to care (till the binary is too large to handle) all of it)

Re:Swift System Is Now Open Source by DelightOne on Saturday September 26, 2020 @07:57AM (#24598110)
So the better question ist ... What code got duplicated exactly and if the one mentioning can't give examples which make a dent in 2MLOC then it is not due to the language in the first place.

I assumed it is about features because there are really a lot of features inside Kubernetes which are not available in Swarm or Nomad by default.

Re:Swift System Is Now Open Source by codeflo on Saturday September 26, 2020 @04:09AM (#24597192)
2 MLOC is insane. I assume some of that might be test code and other infrastructure, and it's basically impossible to compare apples to apples in terms of code size. But for reference, 2 MLOC is around the same code size as PostgreSQL, which is also a complex distributed system, has arguably a lot more user-exposed features and a long history, and is written in C of all things.
Re:Swift System Is Now Open Source by harpratap on Friday September 25, 2020 @10:54PM (#24596054)
Kubernetes is exception, not the norm.
Re:Swift System Is Now Open Source by fooker on Saturday September 26, 2020 @01:34AM (#24596682)
Because of no overloading and generics, you are often forced to repeat code or resort to unsafe runtime practices.
Re:Swift System Is Now Open Source by floatboth on Saturday September 26, 2020 @10:38AM (#24599169)
Everyone is posting some stuff about the kubernetes codebase, but:

https://fasterthanli.me/articles/i-want-off-mr-golangs-wild-...

The monotonic time thing is an especially good example.

Re:Swift System Is Now Open Source by kitsunesoba on Friday September 25, 2020 @04:06PM (#24593613)
I think one of Swift's advantages is its progressive disclosure. It can be written without using any of its more advanced features, making it approachable without limiting possibilities for more advanced users.
Re:Swift System Is Now Open Source by cylon13 on Friday September 25, 2020 @04:39PM (#24593870)
Can it be read without knowing about its more advanced features though? Production software is read much more often than it is written.
Re:Swift System Is Now Open Source by saagarjha on Friday September 25, 2020 @06:54PM (#24594908)
One of Swift's strengths is that most of its features really make sense if you read them, even if you aren't aware they existed. The entire language is optimized around readability. (No, I'm not counting the function builder fiasco.) For example, you may not know that Swift's loops support where clauses:

  for i in 1..<10 where i % 2 == 0 {
      print(i)
  }
But you can immediately understand how it works, because it's consistent with the rest of the language and reads well.
Re:Swift System Is Now Open Source by inopinatus on Friday September 25, 2020 @08:01PM (#24595273)
Any claim of the form "this language is magical! every statement is self-evident" has been bunk since the dawn of programming. The people making such claims are always already too close to the language to realise their own confirmation bias.

So, feedback, from someone whose exposure to Swift consists basically of this article but has eaten a metric crapload of many other braced languages over the decades.

What I can tell is that the programmer wanted to print 2,4,6,8. So the intentional readability is there. However when it comes to understanding how it works (i.e. the language mechanics delivering the intuitive reading) I had lexical concerns. I couldn't immediately tell whether the where-clause acts like a guard predicate in the for-statement or an unbraced if-statement i.e. equivalent to

    for i in 1..<10 {
        next if !(i % 2 == 0)
        print(i)
    }
or

    for i in 1..<10 { 
        if (i % 2 == 0) {
            print(i)
        }
    }
or even (let's hope not)

    if (i % 2 == 0) {
        for i in 1..<10 { 
            print(i)
        }
    }

and in a similar vein the lexical scope and binding of i was not clear to me; some languages bind the iterated variable at the level of the statement, others inside the iterated body (which may even be a closure for all I know), and this has implications particularly for the the value of i after the loop, for the binding of i in any function generated inside the loop (example: print could actually talking to an IO object that defers output by prepending lambdas to a chain - I've seen web containers deferring view rendering this way), for name masking, and for the consequences of any flow-control/continuation/exception mechanism that may cause an early loop exit.
Re:Swift System Is Now Open Source by saagarjha on Friday September 25, 2020 @08:13PM (#24595346)
I'm unsure what the difference is between the first two…are they not equivalent? The lexical scoping could be interpreted differently, sure (allowing your third example the benefit of the doubt) but this is where the "Swift is consistent" comes into play. You already know Swift's scoping rules, it's one of the first things you learn, so using that knowledge you can figure out this code as well.
Re:Swift System Is Now Open Source by inopinatus on Friday September 25, 2020 @09:25PM (#24595671)
No, they're not equivalent. See, that requires making an assumption that I didn't about lexical nesting. They merely do the same thing in this example.

I do not know Swift's scoping rules and having read through the introductory guide and the flow control chapter I still can't tell you if the loop variable remains visible after the loop, and what it is bound to if so.

No doubt that if I sat down with a REPL or an IDE it'd hopefully be evident by example within a few seconds, but the claim was about dry-reading, not interactive experience.

I'll leave it there with an admonishment against making assumptions/declarations about the obvious-ness of something you're already familiar with.

Re:Swift System Is Now Open Source by santraginean on Friday September 25, 2020 @10:26PM (#24595953)
In every language I’ve used with a for-in construct (or equivalent), the iterated variable is scoped to the loop. That seems to be implied by the syntax, too; it’s equivalent to “for all i in [1,9] where i mod 2 = 0”. If you saw that in a math context, you’d expect i to have no meaning beyond the iteration.

Is there a case to be made for other behavior? Or an example of a language that intentionally treats it any differently? (Unless you go out of your way to iterate over a variable you’ve declared in an outer scope in C, but then that’s not really a for-in construct.)

Re:Swift System Is Now Open Source by anonymoushn on Friday September 25, 2020 @10:58PM (#24596068)
Python and JavaScript are languages that do not behave the way you mentioned.
Re:Swift System Is Now Open Source by santraginean on Saturday September 26, 2020 @12:29AM (#24596421)
JS works that way with plain for loops, but not for-in or for-of. The following fails on the last line, for example:

  for (const i in [1,2,3,4]) {
    alert(i);
  }
  alert("i is now " + i); // ReferenceError
(Not that JS is exactly known for consistent and predictable behavior on edge cases, of course...)

Python I don’t have experience with, and it appears I stand corrected on that front! I wonder how intentional it is, and what sort of use case it enables (and if it’s considered good practice to use).

Re:Swift System Is Now Open Source by anonymoushn on Saturday September 26, 2020 @12:46AM (#24596499)
Python does this mostly because it doesn't have block scope, only function scope like JS's `var`. After using Python for a decade, I think this is mostly a mistake. I would configure (or edit) my linter to prevent me from using it if I needed to write a lot more Python.
Re:Swift System Is Now Open Source by lstamour on Friday September 25, 2020 @10:20PM (#24595935)
Lexical nesting? While I agree with the statement you’re making — that reading code requires you to understand more about what the code means, in that context/runtime, I also think the example you’re picking apart reminds me of the dangers of undefined behaviour in C++. If the language specification plus its test cases still has implementation-specific details, then while by all means measure or discover them, but I would both say this is not unique to Swift and is just part of the complexity that is not writing CPU instructions directly that target only one type of CPU design. Maybe I’m taking this too far, but my point I suppose is that I know what was intended by the swift code even if the exact details are optimized out from underneath me by a compiler or language library. Might as well argue that you should have full unit and integration tests for every target platform to ensure the code behaves the way you expect, and even then you’ll still hit platform-specific edge cases, particularly on the wide variety of platforms Linux supports... I do tend to trust Clang, but even it can vary greatly from (hopefully major) version to version.
Re:Swift System Is Now Open Source by inopinatus on Saturday September 26, 2020 @12:52AM (#24596522)
Yes, I'm definitely trying to point out the distinction between reading code and understanding its intention vs understanding implementation mechanics and awareness of the possible alternative behaviours. It's easy to point out that C++ is amongst the worst offenders in that regard, but even a language with a reputation for "programmer happiness" like Ruby (which I absolutely adore) is full of magic, almost every nontrivial expression glossing over a huge pile of conceptual and mechanical object-functional devices that beginners trip over quite routinely (don't even get me started on the thick layer of sorcery that Rails slathers over the top of that).

So I'm not actually calling Swift a major offender, but noting generally that I don't there's ever been a language in which the intuition gap between intention and mechanics was small enough to be irrelevant.

(something at the back of my mind is now whispering "Scheme", but too quietly to be taken seriously)

Re:Swift System Is Now Open Source by kbenson on Friday September 25, 2020 @07:54PM (#24595234)
A where clause on a loop is nice, but I think it's likely it will either be abused or be limiting. I've always favored systems that work well together to build something more than the sum of the parts. Perl is an example of that in many cases.

  for my $i ( 1..(10-1) ) {
    next if $i % 2 == 0;
    print $i;
  }
Here Perl's post-conditional syntax (which works only on a statement and not a block so it's more manageable) combines well with "next" (Perl's version of "continue") to very clearly convey intent without a lot of extra boilerplate. An additional clause is often just an additional line. Comments after each can provide additional context as needed. I think this is a more flexible way to accomplish the same thing, and more readable in all but the simplest of cases. And for those simplest of cases, I would use a grep, which is also useful in other parts of the language:

  for my $i ( grep { not $_ % 2 } 1..(10-1) ) {
    print $i;
  }
Any syntax learned that works as a special case to only a single structure is either a case of missed opportunity or a case of extra syntax that needs to be learned which shouldn't be, IMO.
Re:Swift System Is Now Open Source by saagarjha on Friday September 25, 2020 @08:08PM (#24595320)
That where is not a one-off construct, it's used with switch statements:

  switch i {
  case 1...100 where i % 2 == 0:
      print("\(i) is a small even number")
  case ..<0:
      print("\(i) is negative")
  default:
      print("I couldn't care less")
  }
Or generic constraints:

  struct Vector<T> where T: Numeric {
      // ...
  }
If you so wish, you can always use any of the functional constructs as well, as in

  for i in (0..<10).filter { $0 % 2 == 0 } {
      print(i)
  }
Re:Swift System Is Now Open Source by kbenson on Friday September 25, 2020 @08:52PM (#24595518)
So it looks like it's a general modifier to a range type, so can be used where those work. That's slightly better, but if filter exists, why not just use that?

One of the biggest criticisms that Perl gets is that there's so many different ways to do things, and that's somewhat deserved, so the question is what does "where" offer that "filter" doesn't other than another keyword and concept you have to learn to understand the language? What's the point if it's not really that much more expressive or clear?

> struct Vector<T> where T: Numeric

Is this really the same thing? This seems like a case where the same word is used to mean something else, even if they are loosely conceptually the same.

Re:Swift System Is Now Open Source by solidsnack9000 on Saturday September 26, 2020 @12:27AM (#24596412)
It isn't actually a modifier to a range type -- it modifies other constructs, like looping or conditionals. The examples don't show it but literally any condition can go in the where clause, even something like `where random() % 7 == 2`.
Re:Swift System Is Now Open Source by jiofih on Friday September 25, 2020 @09:00PM (#24595556)
Better learn a new, generic concept than obscure syntax I’ll see combined 1000 different ways on the same codebase.
Re:Swift System Is Now Open Source by fiedzia on Friday September 25, 2020 @09:26PM (#24595672)
I find this style (Rust)) more readable end easier to extend:

RangeInclusive::new(1, 10) .filter(|x| x % 2 == 0) .for_each(|x|{ println!("{}", x); });

(though you could write it the same way, for i in 1..=-10 { if .. { .. }}

Re:Swift System Is Now Open Source by viktorcode on Saturday September 26, 2020 @02:15AM (#24596799)
The same can be written in Swift as

(1...10).filter { $0.isMultiple(of: 2) }.forEach { print($0) }

Re:Swift System Is Now Open Source by nicoburns on Friday September 25, 2020 @05:24PM (#24594257)
I've been able to dip into Swift codebases with zero previous experience without too much trouble. I do have Rust experience which helps. But never-the-less everyday Swift seemed pretty readable to me.
Re:Swift System Is Now Open Source by cutler on Friday September 25, 2020 @07:55PM (#24595240)
Swift has some really clunky "features" such as dual-identifier parameters and escaped opening parens as identifiers for string templates. WTF! As if function/method declarations weren't complex enough in a statically-typed language which supports generics.
Re:Swift System Is Now Open Source by santraginean on Saturday September 26, 2020 @12:34AM (#24596438)
They’re not dual identifiers; one is an argument label and the other is the parameter name. Maybe it’s because I come from an ObjC background, but this is one of my favorite aspects of the syntax; IMO it makes code way easier to read without having to look up method definitions to figure out what each argument does.
Re:Swift System Is Now Open Source by dmitriid on Saturday September 26, 2020 @02:53AM (#24596938)
From State of the Platform this year: https://pbs.twimg.com/media/Ebb51t6XkAIF4YD?format=jpg&name=...

Which for is for and would work as for for?

Re:Swift System Is Now Open Source by cutler on Saturday September 26, 2020 @03:48AM (#24597118)
Madness.
Re:Swift System Is Now Open Source by factotvm on Saturday September 26, 2020 @11:01AM (#24599331)
As a disclaimer, I’ve written Swift, but this seems to be a simple concept. The first name is the interface and is used at the call site, and the second (optional) name is used within the scope of the function, should the developer want a more descriptive name.
Re:Swift System Is Now Open Source by pansa2 on Friday September 25, 2020 @08:16PM (#24595356)
> escaped opening parens as identifiers for string templates

Do you mean the use of “\(variable)” for string interpolation? What’s wrong with that?

Re:Swift System Is Now Open Source by cutler on Saturday September 26, 2020 @03:45AM (#24597113)
It's just downright clunky. What's wrong with ${variable} as in Kotlin and Javascript?
Re:Swift System Is Now Open Source by Someone on Saturday September 26, 2020 @09:52AM (#24598863)
I think that’s more a question of taste/what one is used to. I find that dollar sign a bit heavy, visually, but one could also argue that’s a plus.

Using backslash has the advantage that there’s only one ‘special’ character in strings, but of course, also has the problem can escape any character with a backsplash, except for opening parentheses.

Re:Swift System Is Now Open Source by mantap on Saturday September 26, 2020 @05:52AM (#24597586)
They had good reasons, it means there's only two substrings that need escaping: the backslash and end string sequence. In hindsight, it's ugly and hard to read. A case of optimising for the wrong thing.
Re:Swift System Is Now Open Source by coldtea on Friday September 25, 2020 @08:36PM (#24595442)
Totally. It's very easy to read.
Re:Swift System Is Now Open Source by mhh__ on Friday September 25, 2020 @04:44PM (#24593909)
Isn't that true of almost all programming languages? Or do you mean cleanly?

I think D has to be this idea (or disease depending on who you ask i.e. Go is based on the idea of only keeping the simple bits) taken to the extreme - you can quite happily write Java in D but also implement a Java in D all the way down to the metal (merrily metaprogramming all the way down)

Re:Swift System Is Now Open Source by rpastuszak on Friday September 25, 2020 @05:31PM (#24594312)
All of this sounds great but it doesn’t mean that the code written in it will maintain the same level of simplicity/approachability. Go has the advantage of enforcing it. Writing code is easier than reading it.

Don’t get me wrong, I love swift but I think that for what you’re talking about constraints are necessary because we naturally shift towards more complex ways of expression.

Re:Swift System Is Now Open Source by anoncareer0212 on Friday September 25, 2020 @05:35PM (#24594350)
Exactly, I was in love @ Swift 2, but as the language evolved to cover corner cases and enable things like SwiftUI, it became nigh-unreadable, there's simply too many 'dialects'.

Dart is the closest I've found to optimizing the surface area of a language while maintaining flexibility like ObjC.

Re:Swift System Is Now Open Source by sangnoir on Friday September 25, 2020 @08:32PM (#24595422)
This describes Perl - one could get very clever with it. As a recovering Perl programmer - that is a scary thing for a language to be, especially for large code-bases worked on by people with different skill levels as the code quickly becomes inconsistent, with mixed paradigms.
Re:Swift System Is Now Open Source by simonh on Saturday September 26, 2020 @03:19AM (#24597018)
I once came across a production bash script that contained sections in Korn syntax, others in C Shell syntax and yet others in bourne shell syntax. Lovely!
Re:Swift System Is Now Open Source by usmannk on Friday September 25, 2020 @04:08PM (#24593636)
I agree. I referenced this (perhaps a bit too implicitly) in a sibling comment. Swift's complexity is there but only when you need it.
Re:Swift System Is Now Open Source by a1369209993 on Friday September 25, 2020 @06:46PM (#24594860)
> It can be written without using any of its more advanced features

If anything, that's bad, because it invites projects to adopt a impoverished subset of the language that avoids those features, in which case they might as well not exist because you aren't allowed to use them.

Re:Swift System Is Now Open Source by saagarjha on Friday September 25, 2020 @06:51PM (#24594889)
I have yet to encounter a project that does not allow contributions that use advanced features.
Re:Swift System Is Now Open Source by rat9988 on Friday September 25, 2020 @06:49PM (#24594878)
I'm not sure where is the problem here for the team that doesn't use it.
Re:Swift System Is Now Open Source by youareostriches on Friday September 25, 2020 @05:11PM (#24594151)
>It can be written without using any of its more advanced features...

So can Perl.

Re:Swift System Is Now Open Source by renox on Friday September 25, 2020 @07:51PM (#24595219)
It can sure but I remember having to spend 2hours(with a reference manual open) rewriting two lines of Perl script that a sub wrote (after a colleague told me that he couldn't understand the script) into two lines that a Perl beginner could understand..
Re:Swift System Is Now Open Source by cutler on Friday September 25, 2020 @08:02PM (#24595283)
I've never understood this notion that a professional codebase should be dumbed down to the level of the beginner. In most professions the neophyte must jump though hoops to reach mastery yet in programming we seem to have turned this idea on its head. Whatever happened to mastering your tools? A seasoned Perl veteran should be able to play a damned good round of golf.
Re:Swift System Is Now Open Source by SiVal on Friday September 25, 2020 @08:56PM (#24595536)
We have too many different, interacting parts in most software systems these days to demand devs have pro-level expertise in every part they might have to deal with. If you can simplify the code (without significant harm to functionality) so that only 10% of your potential devs wouldn't understand it very well instead of only 10% would understand it well, you have just increased the value of the code.
Re:Swift System Is Now Open Source by _jal on Friday September 25, 2020 @08:34PM (#24595427)
It is an appeal to the artistry inherent in making the difficult as simple as possible.

Or the internalization of the managerial imperative for cheap labor, take your pick.

Re:Swift System Is Now Open Source by renox on Saturday September 26, 2020 @04:09AM (#24597189)
If the usage of more advanced concept helped reduce the number of lines, better maintainability or increased performance, you may have a point but notice that it was two lines replaced by two lines. I've always suspected the sub to increase artificially the difficulty of the code to ensure he was employed, this didn't work..
Re:Swift System Is Now Open Source by coldtea on Friday September 25, 2020 @08:39PM (#24595453)
>Whatever happened to mastering your tools?

Companies prefer a churn of cheaper juniors happened.

Re:Swift System Is Now Open Source by Andrew_nenakhov on Friday September 25, 2020 @07:34PM (#24595117)
I perled a bit in early 00s, and I never used any of those so-called advanced features, because it made the code totally unreadable.
Re:Swift System Is Now Open Source by coldtea on Friday September 25, 2020 @08:35PM (#24595439)
>Swift is very complex, and makes many compromises away from reliability or efficiency in favor of application use cases.

Swift is only complex if you need it, otherwise very easy, with few caveats.

And it's efficient enough for all application / cli etc use cases -- if Go can do it, Swift can do it even better.

It's not Rust in performance and low-levelness, but Rust is the "really complex" one in its semantics and learning curve.

Re:Swift System Is Now Open Source by mjlawson on Friday September 25, 2020 @08:49PM (#24595506)
> if Go can do it, Swift can do it even better.

This might be hyperbole, but if not I'd love to see some examples on how Swift can improve on Go's concurrency patterns.

Re:Swift System Is Now Open Source by NobodyNada on Friday September 25, 2020 @09:17PM (#24595632)
Swift currently has no language-level concurrency model at all (the only concurrency support available is through libraries such as pthread and libdispatch). However, real concurrency support is on the roadmap for Swift 6 [0] (probably based on some combination of async/await and an actor model), and the core team is expected to release an initial design document within the next few weeks.

[0]: https://forums.swift.org/t/on-the-road-to-swift-6/32862/

Re:Swift System Is Now Open Source by coldtea on Friday September 25, 2020 @09:06PM (#24595582)
It might not offer first class support for green threads like Go, but GCD is an even better imho model for 90% of concurrency needs of the average app:

https://developer.apple.com/documentation/DISPATCH

Re:Swift System Is Now Open Source by microcolonel on Friday September 25, 2020 @09:15PM (#24595623)
"concurrency needs of the average app" is different from what Go does well with green threads; this seems like something Swift does notably worse, but well enough that it doesn't annoy you in your use case. I feel like this is a different standard from "if Go can do it, Swift can do it better".
Re:Swift System Is Now Open Source by harikb on Friday September 25, 2020 @09:19PM (#24595644)
Isn’t that just a bridge to an existing OS level feature? Also is GCD green? (As in light weight, co-operative muti-threading)
Re:Swift System Is Now Open Source by coldtea on Friday September 25, 2020 @09:29PM (#24595689)
>Isn’t that just a bridge to an existing OS level feature?

Yes. A feature well designed for this very purpose.

>Also is GCD green?

GCD tasks are not green threads but they're not direct threads either (even though they're used under the hood). They're more lightweight and much faster to create (than direct OS threads).

Re:Swift System Is Now Open Source by neya on Saturday September 26, 2020 @12:30AM (#24596424)
> And it's efficient enough for all application / cli etc use cases -- if Go can do it, Swift can do it even better.

If you claim something like this, please obviously back up your claims or in the very least, cite a simple example.

Re:Swift System Is Now Open Source by abellerose on Saturday September 26, 2020 @01:15AM (#24596617)
What you're asserting could be said to the initial claim as well. Where are all the examples of why it's so much more complex than other languages.
Re:Swift System Is Now Open Source by Thaxll on Friday September 25, 2020 @09:46PM (#24595776)
Swift isn't good for backend services. Linux port is also average ect ...
Re:Swift System Is Now Open Source by usmannk on Friday September 25, 2020 @04:01PM (#24593565)
> Rust aims to be extremely reliable and efficient.

Fair point, Swift will never be as predictable or efficient as Rust (not a negative perse, just different goals). But I disagree on the complexity re: Go. What about Swift gives you the impression of extreme complexity? Go is definitely comparatively simpler but I do not think it is so much so as to put it in a different league.

Re:Swift System Is Now Open Source by novok on Friday September 25, 2020 @06:35PM (#24594809)
The type errors you start running into with generics with all of their weird limitations in swift can make things complicated fast. That and RxSwift.

Also swift as a language doesn't scale well. There are a lot of bottlenecks in the build process that doesn't let you scale simply amongst many cores like you can with C++, Obj-C & C and probably many other languages too. You're also effectively limited to xcode & apple desktops, so you can't go rent out a 100 core build server on AWS for builds like you can for every other platform out there, not that is matters much yet with swift's build scaling issues.

Also stuff like basic debugging often just... dies.

The more I work with a badly scaling language the more I appreciate a design decision like go made with building fast. I hope with generics in go v2 the boilerplate should reduce a lot.

Re:Swift System Is Now Open Source by vips7L on Friday September 25, 2020 @08:58PM (#24595547)
RxAnything makes any language unreadable. RxJava is the bane of my existence.
Re:Swift System Is Now Open Source by myko on Friday September 25, 2020 @09:11PM (#24595608)
I find Rx to be super clear usually. What problems have you run into?

Combine (Apple's Rx framework) is pretty understandable/usable as well.

Re:Swift System Is Now Open Source by vips7L on Friday September 25, 2020 @10:41PM (#24596010)
In my opinion it's just easy to do wrong. Most uses I've seen (at least in java land) are attempts at non-blocking io which ends up turning the whole application into observables from bottom up. Which in turn makes your app hard to debug and reason about.

When done right, when you actually need the observer pattern, and use it as an event queue I'm sure it's probably amazing though.

Re:Swift System Is Now Open Source by myko on Saturday September 26, 2020 @10:15AM (#24599020)
Those are good points but I agree with the other commenter that these are just difficulties with asynchronous programming generally. I like that Rx makes reasoning about those issues more straight forward and something you must handle instead of something that will bite you later if you didn't think through it.
Re:Swift System Is Now Open Source by nsonha on Saturday September 26, 2020 @12:30AM (#24596425)
this is the problem with async programming in general not just rx. Relevant read:

https://journal.stuffwithstuff.com/2015/02/01/what-color-is-...

Re:Swift System Is Now Open Source by vips7L on Saturday September 26, 2020 @01:00AM (#24596551)
Yes I know about colored functions. I'm looking forward to loom and virtual threads on the jvm to solve that.

BUT it doesn't change the fact that Rx is hard to implement correctly and is often misused when you don't need the observer pattern.

Re:Swift System Is Now Open Source by jshier on Friday September 25, 2020 @06:50PM (#24594882)
When was the last time you compiled Swift code? Xcode's new(er) build system has solved many of the scaling issues that affected the previous system, to the point where it scales linearly (on large enough projects) even on a 28/56 Mac Pro, and my 10/20 iMac. Additionally, with cmake's native Swift support in 3.18(?), the scaling should be more solved across platform as well. There's certainly nothing in the language itself that prevents scaling builds, only the compiler and build systems.

The debugger is still rough, true, but improving. Apple just isn't spending the resources needed to bring lldb up to a great experience in a timely fashion.

Re:Swift System Is Now Open Source by novok on Friday September 25, 2020 @08:21PM (#24595375)
Yesterday!

Swifts build system can split off enough threads to consume all of your CPU cores, and batch mode did improve things, but it's not actually doing so efficiently. There is a trade off between total compute time used and number of threads used. In compute time consumed, swift is the most efficient when it's single threaded in WMO mode, but this means you can only compile in parallel with separate modules that don't depend on each other. And even then it's not a very fast compiling language itself, multithreading issues notwithstanding

Maybe something has changed recently, but as far as Xcode 12 goes, I haven't noticed much of a difference. I last checked deeply with swift 4.

More details here: https://github.com/apple/swift/blob/master/docs/CompilerPerf...

Re:Swift System Is Now Open Source by viktorcode on Saturday September 26, 2020 @02:24AM (#24596827)
> You're also effectively limited to xcode & apple desktops

Swift supports LSP now, so you can use VS Code if that's your thing.

Re:Swift System Is Now Open Source by novok on Sunday September 27, 2020 @05:08AM (#24605275)
But what is going to build your iOS/macOS application, the application of %99.9 of swift code? It's only going to build on macOS unless you are willing to illegally virtualize macOS on non-apple hardware.
Re:Swift System Is Now Open Source by wffurr on Friday September 25, 2020 @04:17PM (#24593699)
Swift has almost seamless interoperability with existing C and C++ libraries and has much stronger safety guarantees than either of those languages. It's not on the same level as Rust, but ARC eliminates entire classes of memory safety issues.

The Swift runtime is large-ish, but not outrageously so, and is generally statically compiled-in to the binaries, so there's no dependencies on dynamic libraries.

It is, as you say, quite complex, but still an interesting choice IMO.

Re:Swift System Is Now Open Source by dagmx on Friday September 25, 2020 @04:33PM (#24593819)
Minor nitpick but it does not have seamless interfacing with anything other than Objective C.

C can be exposed as Objective C, but C++ has to go through C (potential objective C++) first.

This is really no different than most other languages.

What it does do is provide good auto binding tools however to expose classes and objects bidirectionally to objective C.

Re:Swift System Is Now Open Source by ladon86 on Friday September 25, 2020 @05:10PM (#24594128)
My understanding was that there is no need to involve Objective-C if you’re directly interfacing with C. That interop is direct/seamless, and works on Linux etc. even without Objective-C or Darwin [0].

But the C++ story is what you’ve described above.

[0] https://developer.apple.com/documentation/swift/imported_c_a...

and

https://developer.apple.com/documentation/swift/imported_c_a...

Re:Swift System Is Now Open Source by wool_gather on Saturday September 26, 2020 @12:40PM (#24600106)
I wouldn't say "seamless". Interacting with C directly from Swift is possible, and fine from a binary perspective, but quite clunky at the source level. (Which obviously is a motivation for the library that is being announced here.)

There are still assorted gaps in C imports -- a key example is forward-declared structs, that _all_ arrive in Swift as a _single shared_ `OpaquePointer` type: https://forums.swift.org/t/opaque-pointers-in-swift/6875

Re:Swift System Is Now Open Source by wffurr on Friday September 25, 2020 @09:38PM (#24595738)
I was thinking of Objective-C++ which can freely call into C++.

Swift seems to be one step removed from that. I guess you would have to write an Objective-C to Objective-C++ bridge to then use from Swift, ugh.

Re:Swift System Is Now Open Source by andrekandre on Friday September 25, 2020 @06:48PM (#24594873)
obj-c is a direct superset of c, so that interop already requires plain c capabilities right out of the box

and afair obj-c interrop is only available/supported on apple platforms

Re:Swift System Is Now Open Source by mhh__ on Friday September 25, 2020 @04:37PM (#24593855)
Swift can interface with C++? I've just done some googling but I cannot find any documentation at all relating to C++ interop. I make no assumption that I'm right but all I can see is interop via a C API

Seamless in my mind is what D has where name mangling, templates, and classes all work on Windows, Linux (possibly MacOS - I don't have one). Does swift have any of that?

Re:Swift System Is Now Open Source by rvz on Friday September 25, 2020 @05:23PM (#24594246)
> Swift can interface with C++? I've just done some googling but I cannot find any documentation at all relating to C++ interop.

It is not there yet but it is actually being implemented on a native level. A quick Google gave me this. [0] [1] [2]

The approach is first-party than what you get with Rust's third-party crates and tools like bindgen, cxx, etc. Swift's C-interop approach is built-in and much more seamless and automated than bindgen's toggles and switches and creating them by hand in with cgo in Golang.

[0] https://github.com/apple/swift/blob/master/docs/CppInteroper...

[1] https://github.com/apple/swift/pulls?q=label%3A%22C%2B%2B+In...

[2] https://forums.swift.org/t/manifesto-interoperability-betwee...

Re:Swift System Is Now Open Source by saagarjha on Friday September 25, 2020 @06:57PM (#24594927)
It's being worked on, but it's nowhere near being usable in any sense. Very fundamental things still need to be tied down and decided, much less implemented.
Re:Swift System Is Now Open Source by rvz on Friday September 25, 2020 @07:11PM (#24595007)
Well I did say it's 'not there yet' and it is 'being implemented' so of course it is not yet usable as of now. Your same point could be said about Dart C/C++ FFI, Rust async-await, etc.

The parent comment I replied to said: "...I cannot find any documentation at all relating to C++ interop." and this some kind of "documentation" that is related to 'C++ interop'.

Re:Swift System Is Now Open Source by jhatemyjob on Friday September 25, 2020 @04:42PM (#24593902)
On most platforms, if you can interface with C, you can also interface with C++. Usually you have to find the mangled symbol in the C++ binary using a tool like nm, and treat it like a C function with whatever ffi you're using.

If you are targeting multiple platforms this can get tricky because the mangled C++ symbol will (probably) be different for each platform, which can be solved with a good build system

Re:Swift System Is Now Open Source by jarjoura on Friday September 25, 2020 @05:22PM (#24594240)
C++ doesn't have a stable ABI, so if you target a C++ symbol manually like this, as soon as the compiler revs, to say, C++20, the ABI will change and you'll get a linker error.

Also, this may work for simple C++ methods, but once you cross over into vtable territory, you're going to be in a world of hurt.

Also as far as interoperability, I just don't see a smooth path forward between Swift and C++. Philosophically, much of the C++ code you write ends up compiling away or building specialized generated code at compile time. Anything written in C++17 and newer will also have a lot of constexpr code that generates immutable results baked into the final output.

I'd say, wrap your C++ in a simple C API and expose that to Swift (same would apply to Go/Rust or any other language honestly).

Re:Swift System Is Now Open Source by floatboth on Saturday September 26, 2020 @10:51AM (#24599262)
Hot take: ABI stability is overrated. How often do you need to relink specifically without recompiling everything? As an OS packager, it's no big deal to rebuild everything depending on a C++ shared library when that library is updated. For self-contained binary distributions, statically linking the C++ library or putting the shared objects together works fine still.

vtables are always a pain, but I think the Swift team had some cool ideas about vtables and other dynamic stuff across dynamically linked shared objects..

upd: https://gankra.github.io/blah/swift-abi/ this

Re:Swift System Is Now Open Source by jhatemyjob on Saturday September 26, 2020 @03:08PM (#24601331)
A good build system would solve those problems. Yes a C wrapper is way easier.
Re:Swift System Is Now Open Source by trasz on Saturday September 26, 2020 @08:47AM (#24598400)
Stable C++ ABI depends on implementation, it’s not inherent to the language.
Re:Swift System Is Now Open Source by mhh__ on Friday September 25, 2020 @04:48PM (#24593940)
Eek. I've done it but not exactly seamless as implied above! (feels Like using a landmine as a baking scale)
Re:Swift System Is Now Open Source by jhatemyjob on Friday September 25, 2020 @04:48PM (#24593945)
What issues did you run into?
Re:Swift System Is Now Open Source by mhh__ on Friday September 25, 2020 @04:56PM (#24594010)
I've only ever done it out of curious laziness but it's one of those things where it's theoretically clean enough to do right but if you do it wrong you might be fixing it all day. If something changes downstream or you make a mistake at 9AM you can end up with subtle non-failing garbage everywhere.

The only way I would do it and trust it, would be if the binding is generated and tested (separately) automatically, but at that stage why not just write one with a proper ABI.

Re:Swift System Is Now Open Source by moonchild on Friday September 25, 2020 @05:11PM (#24594153)
Good luck instantiating and using classes if you do it that way. You pretty much have to reimplement the itanium abi in whatever language you're using (hint: if your language doesn't already support it, then even implementing it in assembly would be easier).
Re:Swift System Is Now Open Source by plorkyeran on Friday September 25, 2020 @05:09PM (#24594119)
Swift has great C interop for a language that is not a C superset, but C++ interop is at best a thing you can theoretically do. In practice c++ interop is usually done via a wrapper.
Re:Swift System Is Now Open Source by jillesvangurp on Saturday September 26, 2020 @12:38AM (#24596459)
I think you are focusing on a bit artificial things here with things like intentions and other biases and notions.

Swift is a statically compiled, C like language, that can be used for system programming. Just like C, C++, Rust, Go, etc. This is not an accident. It was built from the ground up to do that.

The goal with this OSS library is literally making swift easier to use in projects where you'd otherwise reach for exactly those languages. So, whether you like it or not, it's competing (or at least trying to) in that space (i.e. system programming). Actually, Swift was designed to replace Objective C, which of course was the system programming language that Apple standardized on as an alternative to C decades ago. It's designed from the ground up to be a drop in replacement in any project where you'd previously be using that. So, it's a natural fit for any kind of project where you'd otherwise be considering things like Rust, C++, Go, C, etc.

Whether that makes sense or not in your context is of course up for debate and highly subjective.

Re:Swift System Is Now Open Source by webmobdev on Friday September 25, 2020 @04:40PM (#24593884)
Where do you think Ada - a mature and tested language - fit in between these 3 newbies?
Re:Swift System Is Now Open Source by ardit33 on Saturday September 26, 2020 @01:55AM (#24596735)
Ada is a superior language if you are trying to write safe code, but given that the tools (compilers and such) cost serious money, it will never get any adoption apart from avionics, defense contractors, and mission critical/safety type of software.
Re:Swift System Is Now Open Source by webmobdev on Saturday September 26, 2020 @11:40AM (#24599584)
Free Software Foundation's GNAT is FREE and has a GNU GCC frontend to compile Ada - https://gcc.gnu.org/wiki/GNAT .
Re:Swift System Is Now Open Source by wwright on Friday September 25, 2020 @05:37PM (#24594377)
I don't know Ada well personally, but from what I've read, it's a bit less advanced than Rust at static checks, a good bit simpler than Rust and Swift but more complex than Go, and a little bit old-fashioned in approach (verbose syntax and all that). But I'm not very educated.

I would say that Ada and Rust probably compete on some things, but given the history of Ada in industry, it's probably only in fields that already use Ada (aerospace and what-not).

Re:Swift System Is Now Open Source by pjmlp on Saturday September 26, 2020 @02:14AM (#24596796)
Rust lacks the formal specifications from SPARK.

And SPARK 2014 will support ownership specifications.

Rust is the less advanced one.

Re:Swift System Is Now Open Source by wwright on Saturday September 26, 2020 @10:05AM (#24598939)
Good feedback there :)
Re:Swift System Is Now Open Source by thesuperbigfrog on Saturday September 26, 2020 @04:14AM (#24597204)
>> I don't know Ada well personally >> But I'm not very educated.

If you don't know, please don't speculate.

I use Ada professionally and I am experimenting with Rust. Rust has great promise and I am interested to see where it will go, especially as an alternative to C++.

>> it's a bit less advanced than Rust at static checks

Ada 2012 has comparable and in many cases more advanced static checks than Rust with the exception of memory management. This is especially true of the Ada type system (https://learn.adacore.com/courses/intro-to-ada/chapters/stro...) and design by contracts (https://learn.adacore.com/courses/intro-to-ada/chapters/cont...).

If you use the SPARK subset of Ada, you can use advanced tools to prove the correctness of your program. See https://learn.adacore.com/courses/intro-to-spark/index.html

Rust's borrow checker approach to memory management is novel and SPARK is acutally adding similar concepts to the next version of SPARK (https://blog.adacore.com/using-pointers-in-spark).

>> a good bit simpler than Rust and Swift but more complex than Go

Ada is a large and fairly complex language because it was designed for hard real-time, safety-critical, embedded systems and it has been in real-world use for 40+ years. I don't think it is that simple, but judging simplicity is subjective: what one person sees as complex, another person might see as simple. You can browse the Ada 2012 Language Reference Manual and see what you think: http://ada-auth.org/standards/12rm/html/RM-TOC.html

>> a little bit old-fashioned in approach (verbose syntax and all that).

This comes from the Ada design philosophy to be explicit in everything and to prefer the use of keywords over symbols.

"Readability is more important than conciseness. Syntactically this shows through the fact that keywords are preferred to symbols, that no keyword is an abbreviation, etc." (See https://learn.adacore.com/courses/intro-to-ada/chapters/intr...)

Long-life programs tend to be read more than they are written. The Ada way is to make programs easier to read rather than faster to write.

>> I would say that Ada and Rust probably compete on some things, but given the history of Ada in industry, it's probably only in fields that already use Ada (aerospace and what-not).

This is largely true. Ada occupies a niche for aerospace and other safety-critical areas, but has not been widely adopted due to the "uncoolness" factor and the cost of most of the available Ada compilers and toolchains.

I think the popularity of Rust has peaked some interest in Ada as well, but I am not sure if it will cause any change it where either are used.

I would like to see Rust to continue to mature and get adopted for wide-spread use with multiple implementations and a language standard. As it currently stands, many aerospace and safety-critical spaces would not be willing / able to adopt Rust without a language standard and certifications. Here's hoping . . .

Re:Swift System Is Now Open Source by bilboa on Monday September 28, 2020 @10:23AM (#24616891)
>> This comes from the Ada design philosophy to be explicit in everything and to prefer the use of keywords over symbols.

This may be true, but it doesn't contradict the claim that Ada is old-fashioned in this regard. It was an old fashion in programming languages to prefer words over symbols, and to try to make programming languages look more natural language-like to make them more readable. See Ada, Cobol, Pascal or AppleScript for some examples. This is much less common with newer programming languages, where it's much more common to favor terseness and shortcut syntax. It's debatable whether this is better, but it seems undeniable that Ada-style verbosity is no longer in fashion.

Re:Swift System Is Now Open Source by c-cube on Saturday September 26, 2020 @10:53AM (#24599276)
The claim that more verbose, with keywords instead of braces/symbols is more readable is, imho, very subjective. It's easy to state "code is read more often than it is written" and jump to conclusions from there with no evidence that Ada is actually more readable.

An alternative syntax could be helpful for Ada to gain more traction.

Re:Swift System Is Now Open Source by wwright on Sunday September 27, 2020 @03:03PM (#24609261)
The “verbose syntax is good” stance seems to have been a lot more common back in 70s–80s language design, hence why I call it “old-fashioned” :-) not trying to make a judgement against the language (I personally love Cocoa-style method names, for example).
Re:Swift System Is Now Open Source by bilekas on Friday September 25, 2020 @10:52PM (#24596045)
I'll tell you: You're wrong, so is OP.

Benching languages against eachother is like pitting birds of prey against eachother, its pointless because they will hunt what they hunt.

This language/framework dispute I though was fever back in bad PHP days has not changed. I'm not saying; 'oh you kids dont know shit' I'm saying the language is not the problem, the problem is the problem, the right tool for said problem is the answer.

You find Swift complex and speak about why, you're not wrong with its application, iOS it does very well, therefore its a tool for an iOS job.

If I grew up just learning Swift and nothin else, I would say swift is the best . Plato's cave springs to mind.

We are all Engineers, Developers, Hackers, Designers and or Code Monkeys.. Don't try to pit against, know the right tool for the job, if you cant find it, make it. With people who can.

I though thats how we roll

Re:Swift System Is Now Open Source by wwright on Saturday September 26, 2020 @10:08AM (#24598965)
To be clear, that’s kind of what I was trying to say :) maybe the “only advantage” part at the end made that unclear.

I think the problems you’d want to use Go for, the problems you’d want to use Rust for, and the problems you’d want to use Swift for are largely non-overlapping (in spite of whatever similarities they do have).