Chris Lattner left Swift core team
forums.swift.org
forums.swift.org
As someone who was heavily invested in Swift, and an active member of the community from around 2015-2019, I'm a bit sad to see the direction the language is taking.
From the time I started experimenting with Swift, I absolutely loved the philosophy of the language. It seemed to really prioritize having a set of well-factored systems, each with their own very rationally designed interfaces, which could be composed to do really powerful things. It was an incredibly expressive language which allowed for writing code with an incredible level of clarity - when writing Swift code I always felt I was writing at the level of the problem domain, not writing syntax. At the same time it offered really nice features for ensuring safety and correctness, like ADT's and best-in-class nullability syntax.
It was a language which sometimes seemed to move at a glacial pace, but the implicit tradeoff was that when a feature landed, it was for the most part very well thought out, and would add to the language with minimal negative impact.
A few years ago that seemed to start to change. From my perspective, some of the features added to the language to support SwiftUI - specifically property wrappers and function builders - very much felt rushed and forced into the language based on external deadlines. And imo they have a largely negative impact on the language: it used to be the case that you could look at a piece of Swift code and roughly understand how it would compile to assembly pretty easily, but with these new features there's a ton of compiler magic going on behind the scenes.
For all the critique of java, I think this is the one thing java got correct. It is (no matter how verbose or clunky) still easy to read and understand.
The best part was the perfect C/C++ interop. When I was working on iOS apps in Objective C, I found myself writing a lot of pure functional code using C and it was pretty neat to be able to integrate that with the OO stuff from Obj C so easily and with a clear dividing line.
Of course one can't make them understand as they are just following "best practices" enforced at employers.
First of all, in most IDEs, it's very quick to jump to a function's actual definition to investigate such questions as "What if both of the arguments are < 0?" or "Is null an acceptable argument?". With annotations, you'll often go-to-definition and be staring at an almost empty class that hopefully has a docstring. This is because the annotations, themselves, don't actually do anything- you have to go find the code that actually checks for the annotation and does stuff.
In my experience, the docs are often not good enough when I run into a problem. I was wrestling with some strange behavior with JacksonXML some time ago, and I had a very hard time figuring out what went wrong because Jackson has so many options and they don't actually all compose well, so it's not even about figuring out what one option/annotation does- it's about figuring out what happens when I set OptX=1 and OptY=4 at the same time. Unfortunately, the docs only tell me what is supposed to happen when OptX=1 and what's supposed to happen with OptY=4, but nobody has decided to document every single combination of every single setting in the library.
And I would add that Go is obviously easier than Java here by design, but anyone could write a horribly over-abstracted Hello World or Fizz Buzz in any language given the motivation.
Nothing in golang makes it easier to understand compared to Java by design, and the opposite is actually true (e.g. no proper enums, no records, no pattern matching, etc.) make it more verbose and harder to get to the underlying logic.
That being said, you should see some of my employer's golang code with their web framework that they wrote and the 80+ line stack traces.
Could you give an example for your point?
It was impossible to properly trace any behavior through. Every method zigged and zagged through the inheritance hierarchy multiple times as you traced deeper. And so:
> It is (no matter how verbose or clunky) still easy to read and understand.
The sentiment is taken well, but it's just not true. Credit your fellow engineers for the positive experience, not any particular language.
I think that this comment was written with a positive spirit, but that quote-chopping is incredibly meaning-distorting in a way that counters your point. The original poster stated that Swift "used to be the case that you could look at a piece of Swift code and roughly understand how it would compile to assembly pretty easily" -- you chopped after "understand". There are very few languages where it's /harder/ to understand how they compile to assembly than Java. The JIT compilers are both incredibly complex and incredibly varied, and almost all of them have multiple possible compilation outputs for the same code.
Java, as a language, has been relatively successful in making it easy to understand programmer intention when reading code, as your chopped quote implied -- but the same could be said of Python, Julia, and plenty of others. Swift is in the much smaller category of languages where you can understand how the code will /run/ -- along with C, etc. One could argue that Swift's greatest virtue is that it falls into both categories, but that's another discussion.
Not many people these days can read and fully understand the 64-bit assembly code generated by llvm. I think it is less than 1% of Mac developers.
C++ also have a lot of magic going on. Even C can be tricky with an optimizing compiler.
I don't know what percentage of developers can read assembly, but the popularity of tools like Godbolt strongly suggest it's non-zero. In my own experience, all of the most skilled developers I've worked with have been comfortable digging down to the necessary level -- and doing that in Java, or most other JIT'd languages, is just not fun.
You'll notice that I very much didn't put C++ on either the "easy to understand intent" or "easy to understand behavior" lists -- while it's my preferred language and my primary language, ease of understanding is not its virtue. And while I agree that C compiled with a minimally optimizing compiler (CompCert, clang -O1, etc) is easier to understand than optimized code (for me, the sweet spot for understanding is as compiler that does good register allocation and constant folding, but only really does instruction reordering for memory ops), it's pretty rare that I look at the output of highly optimized code and am surprised or find it hard to follow. Some constructs (medium sized switches, for example) can be pain points... but most often reading assembly output from optimized C is either "yeah, that's about what I would have written" or "close, but you missed this optimization/intrinsic, I'll do it myself."
Yep. If anyone had doubts that the language was no longer the one Lattner designed, SwiftUI should've put the nail in that coffin.
Swift is an imperative, statement-oriented, language. In fact, I get kind of frustrated when writing Swift after spending some time with Rust: I just love writing `let x = if foo { 1 } else { 2 }` or `let x = match foo { ... }`, and it's ugly as hell to try to assign a variable from a switch statement in Swift, etc. BUT, that's okay- I'm almost sure that zero programming languages were written with my opinion in mind, and Swift is Swift.
But, SwiftUI is declarative, which just doesn't work with literally the entire rest of the language. So they added result builders and these weird, magical, annotations just so we can have a UI DSL.
Error handling is now inconsistent and annoying, too. The original approach was to use this quasi-checked-exception syntax where you mark a function as `throws`, and all callers are forced to handle the possibility of failure. The difference between this and Java's checked exceptions is that the specific error type is not part of the signature and therefore the caller only knows that they might get an Error, but not what specific type of Error.
They even have a mechanism for higher-order functions to indicate that they don't throw any of their own errors, but will re-throw errors thrown by function arguments. Clever.
Okay, fine. Pros and cons to that approach, some like it, some don't, etc, whatever. Except then they realized that this approach falls flat in some scenarios (async/promises), so we really just need to go back to returning error values. So they stabilized a Result type.
So, now we need to figure out when we're writing a function if we want to return a Result or make it throw. And, even more annoyingly, Result has a specifically-typed error variant! It's actually a Result<T, E>. Which is it, Swift team? Should immediate callers care about specific error types or not?
Just recently, they landed the async and Actors stuff. Async is fine and great, and is consistent with the imperative syntax and semantics of the language, and it even supports `throws`, IIRC. But Actors? What the hell is that? That's totally out of left field for the rest of the language.
I used to really enjoy Swift in the 2.x to 3.y days, but it really seems like it doesn't even know what it wants to be as a language anymore, which is a real shame- it had a real shot to take the wind out of Rust's sails, IMO (The number one "scary" part of Rust is lifetimes and borrow checker. Swift has CoW structs and auto-ref-counted classes, instead, which can be seen as more appropriate for higher level tasks than writing system libs, etc).
That said, I'm really not sold on actors. I think CS as a whole hasn't really landed on the right abstraction for concurrency yet, actors seem a bit experimental, and GCD is plenty good enough in most cases.
I think the main issue with GCD is the potential for deadlocks in serial queues (which it doesn’t really help you with), and the related problem of thread explosion in concurrent queues.
Actors make protecting shared mutable state really easy, solving a big chunk of the reason you’d want to use semaphores and serial queues in the first place. If you stick with async/await/Task{}/actors, you’re guaranteed to only have the optimum number of threads that can saturate cores, and won’t have deadlocks. If you use Sendable properly and heed all the warnings, you’re a good way towards the kind of “fearless concurrency” that Rust gives you. It really is pretty great IMO compared to GCD.
I’m actually happy with this decision… it was very much done intentionally to prevent the kind of thread explosion that is all too common in GCD. The criticism of GCD I linked to was very skeptical of actors for this reason; if the implementation decides to add more threads to avoid deadlocks, you get the same performance pitfalls as in GCD, and thankfully that didn’t happen.
In practice, I’ve found that avoiding deadlocks is as simple as grepping for `DispatchSemaphore|DispatchGroup` in your codebase and eliminating them with extreme prejudice. If you stick to Tasks/TaskGroups/Task.sleep, there’s no real possibility of accidentally introducing deadlocks unless you try really hard to do so.
And yeah, logical races can still happen in actors, but it’s easy enough at a glance to tell whether you’ll run into one… if you avoid using `await` in a section of code that needs to run exclusively, you’ll be fine. (Even with `await` calls you may get lucky if there’s no actual suspend point happening, but a quick and dirty rule is just “don’t call await and your code will never be run concurrently.”)
You’d think so but then you realize that framework code you call into might decide to do this and you wouldn’t know until it deadlocked. On a 6-core iPhone 13 this is probably not going to be noticeable, but that’s probably not true on a 2-core iPhone 6s…
But if you’re calling into framework code which is using GCD, the queues it dispatches into will be run on a separate GCD thread pool. If said framework code is using a semaphore or lock to block your calling (Concurrency) thread, then it stands to reason there’s another thread in the GCD pool which will eventually unlock it. (Or else it’s a deadlock no matter what you do.)
I haven’t come across any framework code which violates this, although maybe you’ve run into problems I haven’t.
I would almost never write C++ (in the context of low level and performance-relevant code; I write a lot of things for a lot of stuff) if the type system was a touch more rigorous (why can't I specify, and have the compiler yell at me if I don't properly handle, "this pointer may never be null"? TypeScript can do this kind of type narrowing in its sleep!) and if error handling/lifecycle cleanup wasn't hazardous (I'm not even saying exceptions and try-catch, just make it easier to guarantee that a cleanup clause gets called when leaving scope, like Ruby's def-ensure-end).
As it is, whenever I finally hit the breaking point with C++ (which I write mostly from inertia because I know it pretty well) it's probably Rust for me.
I am a fan of Rust, but I am not 100% sold on it. The safety features and ADT's are nice, but I find it quite clunky in practice, and it is just such a huge language full of so many features. It almost feels more like a test language to try the concept of static memory management than a properly designed language in some ways.
I feel it's missing the quality from C/C++ that they are a very thin abstraction over assembly.
Read [0] for a comparison among Zig, D, Rust, and C++, and read [1] for a deeper look at the language's goals. I personally really love Zig's type system [2], with a system for generics that is very simple and consistent.
[0]: https://ziglang.org/learn/why_zig_rust_d_cpp/
[1]: https://ziglang.org/learn/overview/
[2]: https://nathancraddock.com/blog/consistency-in-zigs-type-sys...
We knew about many of these features then, when C was created - but it wasn't until the 2000's really where computing horsepower caught up to be able to use them in a universal way.
I think this statement implies that it’s clear and obvious what assembly will be generated from a snippet of C/C++ code. But few people can understand everything that optimising compilers and modern processors do to normal looking code. An example of this lack of knowledge is seeing people disagree on if a snippet contains UB or not.
If C is so simple, why do people struggle to write it?
Well when I'm talking about an abstraction over assembly I'm not talking about optimizing compilers. That's another topic entirely. What I mean is, if you look at a block of C code, it's very easy to understand what the machine is doing.
> If C is so simple, why do people struggle to write it?
Do they? I think people struggle to write correct, bug-free code in C, but that's because it doesn't save you from yourself, and it's happy to let you do whatever the hardware will do. That's a much larger programmable space than the set of all safe correct programs.
But I don't think people in general have difficulty looking at a snippet of C code and understanding it.
So they simultaneously understand what the machine is doing but don’t know what assembly will be generated? Both can’t be true.
If everyone understood what the machine was doing, everyone would be able to look at a snippet and agree - “that’s UB, let’s not do that”. But they can’t agree. Because few people understand what the compiler and the processor will do.
The “thin layer of assembly” was true for the first generation of C compilers. But it hasn’t been true for a long time. It’s a complete black box now. Anyone who thinks that it’s straightforward isn’t being upfront with themselves.
I mean I can understand a reasonable mapping to what the un-optimized assembly would be. Compiler optimization is very complex, and is going to obscure the results in every language.
> If everyone understood what the machine was doing, everyone would be able to look at a snippet and agree - “that’s UB, let’s not do that”. But they can’t agree. Because few people understand what the compiler and the processor will do.
What? I think everyone can agree that UB is much harder to detect in assembly than in higher level languages than assembly, and assembly gives the most clear view of what the machine is doing. It's a very complex topic to create a system which detects and disallows UB automatically in the compiler - this requires a lot more complexity than a simple mapping of high level instructions to machine instructions.
> The “thin layer of assembly” was true for the first generation of C compilers. But it hasn’t been true for a long time. It’s a complete black box now. Anyone who thinks that it’s straightforward isn’t being upfront with themselves.
I don't know, seems pretty straightforward to me: https://godbolt.org
Can you look at a non trivial C code base and make such an assertion? You can’t. Even simple looking C code could be translated into problematic assembly because such a transformation is technically valid. And it’s beyond the ability of anyone but an expert to guard against that.
C is a very useful language. Very important. Very fast. A great tool in the right hands. The world wouldn’t run without it. And it will remain useful and important and fast for decades to come, certainly. But it’s not simple and hasn’t been for a long time. Let’s acknowledge that.
Do you agree that this statement implies 2 things
1. The compiler isn’t doing anything unusual or unexpected. It applies only basic, easily understandable transformations from C to assembly
2. An intermediate C programmer would be able to guess correctly most of the time what the generated assembly would look like. And thanks to this, such a programmer would be able to avoid most footguns.
But the compiler does unusual/unexpected things, and it’s hard to guess what assembly will be generated or what that assembly does, it’s not a “thin abstraction”. Would you agree?
I think a better metric is: an average CS grad with a little bit of background in compilers and assembly could reasonably be expected to be able to write a naive C compiler which covers say 80% of the footprint of the core language on their own in a matter of weeks.
What do you think is the size of the cohort of people who could write a naive Rust compiler, with borrow checking, ADT's, traits and non-lexical lifetimes? Even without some of the fancy bits like async you're already talking about grad level CS topics at the very least.
I don't find the idea of a new non-memory-safe C replacement in 2022 very exciting. We should be moving away as an industry from non-memory-safe languages, for the obvious security and productivity reasons.
And if you index into an array in C, that's basically like saying `root memory location + stride * index`. In Rust it's calling a trait function which could be doing arbitrary work.
Rust and C++ are on similar levels of abstraction, but C is much, much simpler.
And it's certainly true that Rust has overloading and C doesn't, but that wasn't what I was getting at. The point is that C is defined in terms of the C virtual machine, not the underlying hardware. The C virtual machine is quite far from the actual CPU instructions.
Rust is clearly not at a higher level of abstraction than C++, yet in your own argument you've put C and C++ on the same ground…
> I feel it's missing the quality from C/C++ that they are a very thin abstraction over assembly.
> Rust and C++ are on similar levels of abstraction, but C is much, much simpler.
We can argue the thinkness (or the thinness) of the abstraction until cows come home, but
while (*dst++ = *src++) ;
is a direct abstraction over L1:
movb @(r0)+, @(r1)+
tstb (r0)
bne L1
(assuming «src» and «dst» are both «char *» and addresses are loaded into «r1» and «r0» registers, consequently) in the PDP-11 architecture that C was designed on and for. The instruction sequence is exactly 4x 16 bit words long. As well as *ptr &= 1;
becoming and #1, (r0)
and being 2x 16 bit word instruction (assuming «ptr» is an «int *» and is loaded into «r0»). Pointer arithmetic and array design in C as we know them today was highly influenced by the addressing modes existing in the PDP-11 ISA, with many C abstractions having to a direct correspondence to specific sequences of PDP-11 instructions.C++ is much less of a hardware abstraction, specifically when it comes to the higher level language features.
Or 8 bit CPUs like 6502 and Z80 that aren't even able to fully support C.
Yes – historically – C has never been a perfect fit for 8-bit architectures as it had been conceived for a 16-bit architecture. So what? There are C compilers for 68HC08 68HC11 MCU's as well.
Yet, C has outlived «many languages offering the same "low level" capabilities of C».
You can do so easily. A reference is a pointer that is never null.
>I would almost never write C++ …
Edit: nevermind, I missed the point! GP is saying he wouldn’t write C++ if C supported these features.
This isn't even theoretically true:
void blah(int &x) { x++; }
int main() {
int *x = NULL;
blah(*x);
}
You can definitely write a smart pointer that more or less provides some kind of guarantee about this (with a combo of runtime checks and typefoo) but references only provide a guarantee that they are not statically initializable to null, which is very different.So it will crash, whether that's undefined behaviour or not. The thing at issue here is that other languages have reference types that are more strictly statically guaranteed to be non-null. My point is that references are not a substitute for those, because holding them wrong is not only easy, it's extremely likely to happen in code of any reasonable complixity that mixes pointers and references (ie. almost all production C++ code).
C23 is about to
- add keywords that was valid identifiers before
- remove K&R parameter syntax
- change semantics of the most popular function argument list declaration
- forbid representations other than 2's complement
You can call it a moot point since the amount of what you can do in pure C today is very limited - you have to use at least a few libraries to do anything remotely useful even on very light systems, but in today's fast developing tech world it's one of these things that really stand out.
You might find this an interesting perspective:
There's just so much prior art out there.
Having a core language helps a lot too. E.g. I don't expect Rust to go off the rails.
For instance sync rust is mostly nice to work with, but async is another story entirely. I have the impression that it was somewhat rushed into the language due to community demand, but it's not really a fully solved problem.
My understanding is this is a FUD meme that has been passed around. Async isn't finished yet, but was debated for years and considered with incredible care and input from the community.
more context in the comments here: https://news.ycombinator.com/item?id=26406989
specifically https://news.ycombinator.com/item?id=26407565
Surely you want to use the pure rust async aware postgres client and the pure rust grpc implementation, but with async that's not a free choice.
You now have to deal with the fact that these (actually often quite well written) reimplementations often lag quite a bit in functionality.
For example you think you can just use some boring technology like a RDBMS but then you discover that pgbouncer doesn't really work well with sqlx. Similar stories for gRPC and other stuff.
Don't get me wrong, I'm not saying that's because async implementation is bad or it hasn't been well thought out. Other languages make other tradeoffs (e.g. Go detects blocking syscalls and increases the size of the thread pool, which makes it a bit easier to accomodate blocking FFI with the core async model, but that comes with a price).
What I'm saying is that in practice async rust feels like another language, a language built on top of rust, that looks like rust, that can call rust, but effectively creates its own ecosystem. The problem is compounded by the fact that it's still called rust, and often you can write libraries that can do a bit of async or not based on optional features.
It's probably all unavoidable and for the better, but it does add a source of fatigue that must be acknowledged and not dismissed as FUD.
I'm not sure what the GP meant, to be honest. Async "colored" code does have an tendency to "infect" more and more of your codebase, but you can still write and integrate big chunks of non-async code (e.g. a parser or a network protocol) if you're mindful about your design.
I could be wrong though. The reason I like to discuss these things here is the opportunity to be proven wrong by someone who knows more and offers a counter-example
https://docs.rs/tokio/latest/tokio/task/fn.spawn_blocking.ht...
But you need to know when you must call this and when it's ok to not call it.
The type system won't help you with that. But if you forget to call it you can cause starvation and if you call it too often you may create too many threads.
What I see in the ecosystem is that such tricks are perceived as hacks and that it would be just better if one could just write a pure rust reimpl.
Surely there are enough reasons that drive people to reimplements stuff in rust. I think this aspect of async nudges people even further into that though.
In return, of course, you get a style of concurrency that tends to be much easier to reason about and much less prone to subtle bugs than traditional preemptive multitasking.
Whether that tradeoff is worth it is obviously very dependent on the particular situation.
Still, the fact that Rust has MIR I think very much limits the damage premature async can do. If we get something better, it should be quite possible to extra "Rust - today's async" to recreate it.
Conversely, I wouldn't be surprised if many of the misfeatures in Switch are in impossible to extricate.
[^1]: https://blog.rust-lang.org/inside-rust/2022/02/03/async-in-2...
Unless the rails are too rusty :-)
You would have 2 lines of code per property but one fewer concept—and I think that is a much more important factor. To me—this was not the right way to add sugar.
When I started, I thought it would be some complicated beast, but no - its a reasonably simple and elegant C superset with the only disadvantage of some extra verbosity. (but Apple API's suffer from verbosity as a principle)
I have to wonder: why did Apple create Swift ? Objective-C is quite nice, especially for C/C++ programmers. With Objective-C++, interop with C++ libraries is also terrific. Swift offers nothing like this yet.
They wanted a safe, performant language that interoperates with Objective-C. Safety gets them fewer vulnerabilities, interoperability means they can gradually decrease (Objective-)C usage.
Also:
- opinions on the nicety of Objective-C differ (but the only arguments I’ve heard why it would be bad more or less are “I don’t like the syntax” and “it’s verbose”, both of which, IMO, are weak. Both, IMO, are acquired tastes. I don’t think anybody is born preferring terse K&R C, for example.
- as you probably know, work is being done on C++ interop (https://github.com/apple/swift/blob/main/docs/CppInteroperab...), so that may improve.
I asked this many times over the years, even in this thread [1]. Still no concrete answer. I still think overall it is a distraction.
So Apple needed a nice language with C-like syntax to woo developers.
NSString *string1 = @"Some";
NSString *string2 = @" string";
NSString \*string3 = [string1 stringByAppendingString:string2];
Not to mention it didn't have ARC back in the days.For sake it was built nearly 40 years ago. Not sure if there's any room to question why Apple and devs wanted a new language.
I was amazed why anyone would want to use this language before Swift but people didn't have a choice.
There were efforts like MacRuby.
https://www.mikeash.com/pyblog/friday-qa-2015-11-06-why-is-s...
It is amazing that people forget to simply use the right tool for the right job and blame the PL instead.
Because a dependent type is a type that represents a computation. A word that symbolises a computation, a word which can be manipulated by hand and assured by machine – and vice versa.
Software is automation. Types are signifiers of meaning. Dependent types are the automation of the automation.
Using a dependently-typed language feels like handling a machine which is the result of having closed a fundamental loop of expression vs. meaning. And that is what it is.
It’s very philosophical-sounding! It has its roots in philosophy – in intuitionism, where math dug down and met philosophers who had dug down from the other side. Kind of.
Practically, the upshot is that things actually become simpler. Kind of because you can grip the tool everywhere. Un-dependently typed languages feel kind of like they’re part tool, part void. You usually can’t express things relating the context you’re in, or looking at.
(As I see it – at least these days – dependent types just are. It’s very, very nice to just have higher-order unification and the things that sort of fall naturally out of having it.)
I found this talk from Xavier Leroy a while back too: http://www.cs.ox.ac.uk/ralf.hinze/WG2.8/26/slides/xavier.pdf. He is the main person behind CompCert, the formally verified C compiler. They do that verification in Coq, so I was expecting him to be a believer of dependent types. But he had this to say:
“ Dependent types work great to automatically propagate invariants
- Attached to data structures (standard); - In conjunction with monads (new!).
In most other cases, plain functions + separate theorems about them are generally more convenient.”
For that reason I prefer Isabelle/HOL as a theorem prover. The core logic is simpler, but you can express whatever you want as a theorem, without worrying about phrasing it within the type system. It feels a lot more natural.
That’s not without downside either of course. Proofs in Isabelle notoriously must match the structure of the code being verified, so changes to the code require proof changes. Liam O’Connor wrote an example of where they he feels dependent types are better here: http://liamoc.net/posts/2015-08-23-verified-compiler/index.h....
Even with that, I’d rather have simple code plus simple propositions with complexity at the proof level. This will likely be another eternal holy war though.
It helps me see what I think I’m seeing, or rather to define it. It also has helped me to perspectives I hadn’t seen.
I’m coming to dependent types from here: “simple, clear code good yes program program argh I can’t express a very distinct thought without escaping to another language layer or generating code using string concatenation”, and from here: “my data structure is simple and clear but argh it needs a handwritten parser and serializer and it needs to be maintained and argh why am I writing a parser AND a serializer it should be just one bidirectional definition? and argh why do I need to write it for each output/input format?”, and from here: “my code is simple and clean and my variables are well named and my tests are well defined and my documentation is well written but argh why can’t I just fold the mechanics that the tests define into the code? as proofs? (and… argh? why can’t my variables and documentation and method names be checked against the code?)”.
It’s metaprogramming that I’m thinking about. And most programming ought to be programming. But we definitely need metaprogramming, and it needs to be understandable and composable and simple and clear. And I don’t know if dependent types are a complete solution to that, but I do think that they are necessary for it.
That-which-is dependent types, which by definition is a computation of what it is and is a proof of what it is. Those philosophical terms finally become practically grounded and practical help in a lot of the work I find myself doing.
I’ll certainly look for the false idol too! My sincere thanks.
> Software is automation.
software is a lot more than just automationWider question: How can a language and its core library stand still? To me, standing still is death for any computer programming language ecosystem. Many languages are just getting started on the idea of "green threads" and "colours" (sync vs async). Some of this can be done purely with a core library using existing language features, but some evolutions are better done with language features.
> How can a language and its core library stand still
I guess by having a more abstract foundation and relying less on adding hacks like colored function? Haskell seems to be like that.
Another thing is language extensions that you have to turn on to use. This makes deprecating stuff easier in the future, so languages can trim itself instead of keep growing.
Looking forward to C# 11 code.
This happens with all corporate software, as people compete to (for instance) foist their new videoconference system into your calendar flow. That's sort of tolerable for end-user software, but horrible for programming languages where feature-feature interactions grow as N^2.
One notable remaining exception to this trend is Go. They are committed to the "simplicity" mantra and so far they have stuck to carefully weighing and discussing any feature added to the language. I know that some consider it too simple and the "glacial" pace of development not exciting enough, but I personally appreciate it...
Apple it seems does well w/ a Scott Forstal or a Bertrand Serlet running cover for their engineers. maybe not so much if there's a giant committtee....
And before that Avie Tevanian.
After that it was Craig Federighi. And I dont like the decisions and directions since then to say the very least.
Sometimes I still think about Bertrand Serlet leaving, the year that Steve passed away or 6 months after Steve took leave of absence. I wonder if he saw what was coming and simply decided it was time to leave.
And this is pure kremlinology at this point, but I feel like Apple Music, at least the client part, has to go back under Craig and not Eddy....
Committees work when they have a shared vision, and a base strong enough to keep them on that path.
It’s clear from Lattner’s statement that Apple have moved that vision, have not brought the group along with that change and the result is wasted effort and a passive aggressive approach.
I would posit that rather than operate as a committee, instead that leadership is being exercised by a limited few and the structure is being retained as a fig-leaf :(
But I think it's over-sold as a systems/low-level language. Relying on ARC for all reference types creates a significant floor in terms of performance which makes it unsuitable for a lot of systems programming applications - unless you resort to unsafe Swift, in which case you're not really writing Swift.
A good deal of bad code design comes down to not being able to predict what a bit of code is going to do without stopping everything, unrolling whatever built up state you had in your mind (from the thing you were actually trying to do) and sit and become one with the code for a time. But at least when you’re unsure what the code is doing you have a suspicion that is the case. The worse sin by far is misdirecting you into thinking it does one thing when it does something else, or even the opposite.
We like to complain about extroverted business people interrupting us, but we seem to have very little guilt about doing it to each other by leaving these sorts of time bombs in our code.
What do you think the ratio between people who want to understand what the assembly will look like, to people who want a simple and powerful way to write apps? I think it's very close to 0.
>After several discussions generating more heat than light, when my formal proposal review comments and concerns were ignored by the unilateral accepts, and the general challenges with transparency working with core team, I decided that my effort was triggering the same friction with the same people, and thus I was just wasting my time.
I stopped paying attention to Swift for this exact reason. I have actually submitted and implemented a feature in Swift and I think it was one of my most frustrating experiences with open-source projects. It seems that almost every thread in this forum devolves into people fighting over the most irrelevant details, and my proposal specifically took months to be submitted into review because a couple of users simply refused to back down from how they personally wanted it to work, ignoring the actual problem the feature aimed to solve. After a long time deflecting the comments, the feature was accepted the way I originally intended and I never entered the forum again.
Example aside, it doesn't take a proposal to see that almost every thread in the forum looks like this. Open sourcing Swift has benefits, but I think when it comes to the actual progress of the project, this particular democratic process was a mistake.
(I wouldn't count C as actively developing, even though it is moving glacially slow, I'm thinking of things like Python, etc. Or other languages that aren't "done.")
Apple's marketing around Swift advertises the "open source" aspect, and there's a lot of money to be made making iOS apps, so there's naturally going to be a lot of noise around proposals/developments.
Mozilla has a long tradition of "open source" that Apple does not. So Mozilla were able to cultivate a community around Rust, where Apple laid down a lot of astroturf...
I like swift enough I’m learning it to build my own personal tech nerd ideal podcast client because I own apple devices and want an app that works between macOS, iOS, iPadOS, tvOS,and watchOS. but I doubt I’ll ever use it for anything beyond this one personally motivated project. Even if i release it as an app on the store for download or purchase I don’t know if I will ever be motivated enough to build anything else using it. Because the scope is too narrow. Business work is converging on open stacks like react, and angular, and the dark horse of C# with its latest release supporting WASM web components backed by GRPC-web and a C# function driven stack from front to back, even without SQL Server costs this is a compelling ecosystem backed by PostgreSQL and other completely open source tools.
But Swift remains Apple’s language for apple stuff and… while a profitable niche, it’s still a niche.
Edit: typo fix.
No matter how much apple market share in whatever market grows, developers want to be able to switch platforms and not have to think about the language.
The primary goal should be to maximize value, and within that a balanced tension between maximizing delivered value vs maximizing captured value. It's reasonable to be compensated for the value you add, but it needs to be in service of maximizing value in general. If the correct hierarchy of goals is inverted and capturing value becomes the primary aim then it inevitably devolves into this antisocial, monopolistic, lock-in behavior.
If it was a closed process where neat stuff just dropped out of the sky each year, that would be fine. When features drop out of nowhere each year and then get laundered through ex post facto public "review", then I take issue.
If it was a closed process then we would expect that only features coming from Apple would exist. In a truly open process there would be facilitation for contributions from people outside the organization. In the Swift project as it is currently run, those contributions have withered on the vine; the core team doesn't particularly welcome or support anything that didn't originate internally.
And it doesn't sound like you're actually following Swift Evolution. A) Most of what happens is done in public, only rarely do they hide stuff until the last minute, like result builders for SwiftUI. B) As far as I know, they have never claimed that it's going to be completely open and 100% community controlled. The core team is mostly Apple employees, that is not a secret.
Nope, you're completely wrong about that.
> In the Swift project as it is currently run, those contributions have withered on the vine; the core team doesn't particularly welcome or support anything that didn't originate internally.
It's also a very niche objection to complain that it's neither fully open nor completely closed. Most people are totally fine that the development is mostly open, with some new features kept hidden for business purposes. The vast majority of Swift users see it as a tool, a tool mostly to write Apple software, and they are more or less pragmatic. Almost all additions to Swift have been very positive for people that use it in their day job.
My current concern right now with swift is the impossibility to use any code on android in an officially supported way.
You're also pretty much on your own with the library ecosystem.
I agree that it's not apple's interest. But that's part if the problem : this language didn't start with the goal of being just an apple language.
Objective-C has served them for over 40 years, building several different OSes over a multitude of CPUS and platforms.
If anything, Swift would welcome a repeat of this history.
That alone does not make it good.
It would have been much more productive to team up with the C# team as C# is a mature language, and a combined Apple + Microsoft would have been able to compete against java (esp. with Oracle as owner of java).
Obviously iOS platforms are much less constrained today, but not having to run a GC is a pretty nice thing.
Maybe C# could've been extended into that universe (I know Midori had their own variant but don't know much about it) but it seems daunting to then make that compatible.
The modern GC in java is amazingly fast and with a few tricks likely to be good enough.
Sounds like a lot of armchair generals debating in hindsight about any problem in anything that fits their dislike bias rather than fore-sighting about the specifics before it has happened.
No wonder that is the reason why they are preferring to moving everyone to use Dart / Flutter in their future operating system instead of continuing to use Java.
It is like as if Android was designed to be a disaster.
It's evident that Google and many developers have had enough of it from the runtime, Java, JDKs and the whole system. Otherwise, why on earth are they planning to move away from it all in the first place?
Once again, from the perspective of the user or the app developer, they don't care, Android still just doesn't cut it against iOS. No wonder Android is always second place.
If you scroll to the top of the page with Chris' comment, this point is being addressed:
>In the coming weeks, we hope to introduce a new language workgroup that will focus on the core of the language evolution itself, splitting off this responsibility from the core steering of the project. The intent is to free the core team to invest more in overall project stewardship and create a larger language workgroup that can incorporate more community members in language decisions.
C touches much more than telephony
Oof. Yeah, that’s relatable. It’s hard to continue contributing volunteer efforts to projects you care about when you’re getting shouted at all the time.
So maybe one the problems is that at this point, he's no longer getting the deference from other community members that he feels he's still owed?
> For context, I left Apple over five years ago and the only constant in my life is that I'm always "very busy" :smile:. That said, Swift is important to me, so I've been happy to spend a significant amount of time to help improve and steer it. This included the ~weekly core team meetings (initially in person, then over WebEx), but also many hours reading and responding to Swift Evolution, and personally driving/writing/iterating many Evolution Proposals 19. As such, my decision to leave the core team last summer wasn't easy.
Call it Bird or Goose or something.
Pull out SwiftUI and keep it simple. Focus on the server market more.
In that case, you'd be writing mostly functional Swift code with sparing use of reference types, which would mean you wouldn't hit ARC at all and you'd have static memory management similar to Rust.
That, along with Swift's expressiveness, ADT's and awesome type system in general would make it a great experience.
Kind of like the ergonomics of Python with an actual good compiler eliminating obvious mistakes like Rust.
Perhaps, but that's not server software, is it?
Happy to read up on this if you don't have the time to type it up.
In practice, compiler optimizations reduce the amount of retain/release pairs emitted, but I have no idea how the resulting performance compares to GC languages.
Related thread on Swift forums [1] seems to suggest that the latest Swift compiler would generate code that performs a lot better than the Swift 4.2 version. I'm interested in checking that for myself.
You can write shared-nothing algorithms using ARC objects that are local to a single thread or core, and while it will be slightly more expensive than RC objects, the N^2 effect of sharing between N cores won't occur.
There is some neat stuff that you can do with it in docker https://hub.docker.com/_/swift
I'd cast my vote for Crested Shriketit. Or maybe Mionectine Flycatcher? Many-Coloured Rush Tyrant?
Incidentally, Wikipedia's list of birds is truly a wondrous place: https://en.wikipedia.org/wiki/List_of_birds
I don't really know what Apple can do per se to turn this ship around, but Swift "as a brand" has definitely lost its luster. I'd considered wading back into Apple app development when SwiftUI was first introduced (at the time I hadn't touched any of the dev tools since early-era Mac OS X Cocoa/Objective-C), but I have no interest at this point. (The App Store being a real s**show also doesn't help matters!)
This puts a bullet in my hopes for Swift. Why on earth would Apple not support this obvious A-Team player?
There's two sides to every story?
There are some exceptionally capable people who simply cannot work together on the same idea/problem in my experience. This doesn't necessarily mean that one or the other is inherently bad.
Ben then goes on to call another one of Chris' posts as representative of a part of a broader trend of "performative misunderstanding", basically calling Chris and others disingenuous.
He then dismisses Chris' concerns out of hand as "a possible but frankly implausible misinterpretation", and says that his behavior is a "real problem" that worsens the goodness of other proposals.
I'm not saying that either party here is in the right, or that the discussion as a whole is in Chris' favor, but I would say this thread is definitely not an example of healthy debate. You don't call your interlocutor disingenuous in healthy debate hyperbolically nitpick their posts as hyperbolic. That's not debate, it's squabbling.
Yup, hot take: SwiftUI is hot garbage.
Declarative rendering is the worst rendering: it's code written that doesn't have to be written. The beautiful thing about UIKit, NSLayout, and Storyboards, is that when used effectively, not much UI code has to be written, and when it does, it matters.
Now everything has to be written to hells end. And not only do I need a mental diagram of my UI in rendered state, I need it in code state as well.
If someone could enlighten me, I would gladly take the lesson.
Edit: I'm very happy I posted this to learn. I used UITextViews extensively in my only app development, and was extremely frustrated with SwiftUIs readiness on that front.
That said, I still like that my code can reflect the 'flow of thought' rather than the strictness of the UI when developing. I guess a lot of the property wrappers got to me too
And all the improvements given to declarative rendering could be embodied in updates to Storyboards and the like.
The criticisms I’ve heard of SwiftUI come from a guy who absolutely loved React. I think the problems are unrelated to the overall idea of declarative rendering being flawed.
Since I wrote it (about 10 years ago), I've spent a fair bit of time writing React(and Vue) code and about 90% of the issues would've gone away (and no, this isn't just hindsight, I would've probably re-created many of the same issues and spent a big chunk of time on tedious code if I used the same framework again).
Sadly, the options for something that supports OpenGL and works with declarative rendering are slim on the desktop.
The only comparable thing in UIKit is UIStackView. In fact, UIStackView was clearly added to reduce the explicit constraint layout code required for simple layouts. While you don't "write" UI code with Storyboards, it's certainly there, just encoded into a non human readable format.
SwiftUI has many problems (mainly bugginess and missing APIs) but I don't see how the old APIs required "not much UI code ... to be written". If anything, this is one of the primary benefits of SwiftUI: getting to remove most of the explicit layout code and complex type system required to do basic layout tasks with UIKit or AppKit.
Also I think the decision to make combine a core building block of Apple UI development is a huge mistake. FRP is a plague on the industry, and everyone is going to figure that out in a couple years.
Why is FRP/Combine bad? What is better?
Not that it can't be handled well or used to good effect, but the idea of wandering into an unfamiliar FRP-based codebase which has been in the hands of multiple non-expert maintainers over a couple years is really the stuff of nightmares.
edit: answering what's better
Normal flow of control is better. You want to be able to look at a function, and see which functions are called from inside that function. And you want to be able to search all instances and see every place where a function is used.
You don't want to have some black-box scheduler who's calling all your functions for you. That's how you end up with mysterious action at a distance, becuase you didn't know about the extra subscriber your colleague put on a publisher somewhere else in the codebase, or something strange happening because of an order-of-operations issue which is difficult to understand.
I kinda agree that SwiftUI runtime uses a lot of opaque magic and documentation is still under-par. However, I am very glad Apple went the React way – I tried UIKit after I was writing React for few years and it felt very dated and laborious. Yeah, React isn't FRP, but declarative UI with code FTW.
But to be fair, the comment you linked is not a prophecy it was a lamentation
I would imagine a few years after SwiftUI becomes the primary UI stack used by iOS developers, many of them will be cursing Combine's name, as it will be clear most of the problems making iOS developers' lives difficult will be coming from FRP.
Edit: Is it Factory Reset Protection?
What you are referring to with UIKit, NSLayout, and Storyboards is in fact declarative rendering, but the layout code can only be modified with a point and click editor. In most people's opinions, editing code directly is much more controllable and works better for systems like Git.
Instead of the native app world, I stuck to web front ends and managed that awkward transition from jQuery to Angular to React. These models for UI made increasing amounts of sense — instead of fiddling with weird lines a slop gui, I could just tell the system what I want and get it!
Then SwiftUI came along, and lo, I get all the goodness of React in iOS and even MacOS! My first native app in years is coming along swimmingly, and it’s even cross platform!
(yes, I did do an app in React Native, and found it gross for reasons that I can’t put my finger on)
The syntax is incomprehensible and inconsistent, the documentation is ridiculous, the feature set is severly lacking, and worst of all it's unbelievably slow. I have the fastest processor that Apple sells and a proof-of-concept app that I made in a few hours that consists of three Swift files takes 30 seconds to compile. I can't imagine what building non-trivial apps with it wouldbe like.
> I can't imagine what building non-trivial apps with it wouldbe like.
lets just say you will be making quite a few pots of coffee...What do you mean? You can build desktop Windows WPF or Winforms apps with the new .NET. There's also MAUI for cross-platform desktop apps.
What would have been ".NET Core 5" is just ".NET 5", and that's when the bulk of the desktop framework compat came online.
Microsoft <3 Linux
I think this comes down to Chris being a very busy person who has better things to do with his time than argue about the direction of a project he no longer controls.
>Go has community contributions but it is not a community project. It is Google's project. This is an unarguable thing, whether you consider it to be good or bad, and it has effects that we need to accept. For example, if you want some significant thing to be accepted into Go, working to build consensus in the community is far less important than persuading the Go core team.
https://utcc.utoronto.ca/~cks/space/blog/programming/GoIsGoo...
>In the coming weeks, we hope to introduce a new language workgroup that will focus on the core of the language evolution itself, splitting off this responsibility from the core steering of the project. The intent is to free the core team to invest more in overall project stewardship and create a larger language workgroup that can incorporate more community members in language decisions.
So overall things balance out even if not big win for either.
Swift: Close process + big funding -> fast implementation / less feedback Rust: Open process + little funding -> slow implementation / lot of feedback
Also even with lot of feedback many community members in Rust are already claiming very new features like Async in Rust are deficient in parts and feels rushed.
It's too bad Swift is straying from his original vision but that's the tradeoff of designing a new language with a large company. Not blaming Apple or anything, kudos for them putting so many resources in an experimental new language, and LLVM wouldn't be where it is today without them (which I think is enabling a sea change in engineering), but at the end of the day there's only one use case for swift that matters.
Sometimes organizations just grow to be too large and too remote to sustain a productive and respectful environment. I don't think anyone is necessarily at fault here.
Seems incredibly disrespectful.
In any event though not good.
It's also possible that there are people who feel that yelling is an acceptable part of debate.
Misguided people, sure, but they do exist.
The probability is unusually high that they personally yell at people in collaborative meetings.
Many have been taught by abusive parents or figures of authority, or whatever shit television, that it's normal. "Some 'light' yelling is to be expected.", "Different styles of management/debate", "whatever works for them, I'm sure everyone does it a bit". What next? Corporal punishment? Like in the old days, when kids really respected their elders - or else - and were taught /right/ and women stayed in their place?
Those people need to be taught that no one, ever, should have yelled or should ever yell at them for being wrong or just disagreeing. It's not OK, it never was, it never is. Parents, friends, teachers, colleagues.
You spend 8 hours a day at work, if it's not a safe place, and you can find another job, GTF away as fast as possible, or have the perpetrators get the hell away, if you have this power.
I'm sorry we even have to say that.
However, the claim being made was that this yelling was a trap that was intentionally set to drive Chris out and not just a case of someone who thinks yelling is acceptable behavior.
Anything else is just accepting sociopathic mind games. 'oh he shouldn't have felt threatened by violence and unchecked unacceptable behaviour! he was so naive, toxicity is not objective, suck it up'. WTF. I'm all for hearing the other side of this story but please, everyone (not you, GeekyBear!) stop defending sociopaths (or violent people) being sociopaths, and blaming victims not being sociopaths themselves.
The late Pieter Hintjens' writings on psychopathic behaviour needs a re-reading...
Engineers letting technical disagreements turn personal.
And Chris himself said he disagreed with the technical direction of the project.
Just sounds to me like he felt like he was wasting his time.
Playing devil's advocate here, but we should hear the same history from the other side, more so if these "insulting and yelling" happened more than once with different team members.
I don't know any details to question legitimacy of the issue, however in my experience I am constantly surprised how many times it is just communication breakdown or gap in what each party perceives.
Also the pandemic has made things more stressful for everyone and outbursts do happen with more frequency perhaps it is easier virtually to shout at some one i suppose.
Torvalds was known for his infamous roasts on LKML, he only goes on a triade when he feels the situation warrants and person should know better. That doesn't make it right , but someone had to really explain it to him before he toned it down recently. I don't think his intent was ever to be toxic or aggressive.
Effectively communicating problems can be hard.
Seems to me to probably reflect a high degree of insecurity: if you're not secure and feel the need to protect your position I can imagine some people reacting this way if Chris is telling everyone he thinks your idea is a bad one.
Not sure if Apple silo-ing off teams lets this perpetuate, but then again, it's not like Google or FB have their own share of toxic groups.
You'd think something like that whole Apple university MBA program would figure out better ways of managing large numbers of people with commensurate egos, but it seems like an unsolved problem.
Apple's management culture is they're basically running an army of orcs. Anyone who threatens the authority of the mid-level bureaucrats - they'll sic the orcs at you.
And since he's not naming names, he's being professional about it, but pointing out that the bad behavior isn't for him.
It is about as good as a response that can be considered, given the circumstances.
Just FYI, you want:
> It is about as good a response as can be considered
(Incidentally, I couldn't agree more with your comment. It was a very magnanimous response that he gave.)
In my own experience… Apple is a large company, with a huge variety of teams with different accepted standards of conduct.
But the Swift language is also an open source project, so this is a pseudo-open dev community so I’m not sure if Apple’s internal corporate culture even has a strong hold over this mailing list and those WebEx meetings that probably include volunteers, not just Apple employees.
That said you are right; you should also raise the issue to upper management. You have more options than just speaking to them directly.
So in practice, yeah you leave.
I do wonder how many people prefer Obj-C to Swift. Philosophically speaking, Chris Lattner's ideal of Swift could replace PL from Javascript to C, while a noble goal was a big no no for me. I often think Swift is an unnecessary distraction in the overall Apple ecosystem.
And I do notice programming language design and usage tends to get very heated in discussions. And there is a growing charm in ugly language ( so to speak ) that shuts up and get the job done.
But a disagreement is one thing, being shouted at during an online video meeting? That is some level of aggression. Although there is always two side of the story.
Sorry to hear about Chris Lattner's woes with Swift team. I only know of his reputation so I'm confident he will find a new, happy and appreciative, home for his talent.
It sucks that we keep enabling abusers. I don't begrudge Mr. Lattner his decision, but why should he be the one to have to leave?
Perhaps Chris is letting bygons be bygons, and going bye-gone?
(Part of sticking up for his team means pushing back against idiocy in the upper tiers of management, which isn't always popular!)
I do not see an obvious solution to this other the somewhat untenable goal of restricting discussions to email only.
To me, as an outsider, the only interesting question remaining is, what ideas, if any, from Swift are good enough to adopt into other languages that seem to have legs?
More interested in what good ideas we might be able to take from Swift.
Pjmlp's list does not include any unfamiliar from other languages.
This sounds particularly deluded:
> as an outsider I have never understood how anybody thought Swift had a future.
The objective fact is that there are a million or so working developers happily using Swift. And there are also lots of people that dislike it, but clearly it's very useful and popular.
And in what sense would Swift be "walled garden"? Very few languages were constructed for philosophical purists like you.
Either my actual question has meaningful answers, or it doesn't. Thus far it seems the answer is "none"; that would be the least surprising answer. And the evidence thus far suggests you would like to distract us from that fact, if fact it is.
The first Swift build tools beta was downloaded ELEVEN MILLION TIMES in the first month alone. I would be surprised if that is not some kind of record. And it was the most loved language on SO already in 2016.
We're talking about a language powering the favourite devices of the richest 20% of the world population, a language that is extremely actively supported by the richest company on the planet. I think any reasonable person would conclude that it "has a future".
Apparently the answer is, No features in Swift should be of any interest to anyone else.
And, again, how many NOSES APPLE HAS BROWNED is still of no interest whatsoever. Shame on you. Your behavior is reprehensible, but not unrepresentative; it reflects badly on Apple.
Not that it's wrong or that it can't possibly work, it's just not how Apple rolls.
If not Lattner, what figure or faction is now in control of steering the future of the language?
And at the end if the language is inadequate for something then simply use something else that fits better, there is no reason to force all languages be gigantic kitchensinks.
I've seen this happen many times, particularly with projects that started out in Python. Eventually the codebase and teams get too big, and managing a large codebase in a language with Python's type system becomes very cumbersome. Type annotations were a reaction to that, and adding them to the language has probably enabled a lot of teams to continue using Python.
Off the top of my head, other examples of good changes include NIO and better concurrency primitives/lambda syntax in Java, generics in Go, and async/await in several other languages. All of those solved pain points for developers that might have otherwise been solved by switching languages.
Why does this matter? First of all, it's a lot of work to rewrite products in different languages. Also, while it sounds attractive to pick the right language for the task every time, in practice it is difficult to run a coherent engineering organization if every product or team uses a different language -- it's hard to build good shared libraries and app frameworks for every language in use, and if someone leaves the company it can be hard to transfer their projects to other engineers. Most of the time, as an engineering org matures it eventually settles on a few "blessed" languages, invests in good frameworks for them, and requires all the teams to use them. Out of necessity, those tend to be the "kitchen sink" variety.
On the other hand, it also shows some of the disadvantages - for example, there is no multi-threading support of any kind in the Common Lisp standard, because this was not a common feature at the time the standard was created; neither is there Unicode support. Of course there are libraries that implement these things, even portably (and this being CL, the difference between library and core langauge is minimal), but it's still a point some hold against it.
https://news.ycombinator.com/item?id=27782864
It's definitely an unusual approach for authors to consider software "done", and Clojure apparently gets close to it (?)
Not surprisingly, that kind of stance also generates controversy ... you can't win :)
> As mentioned earlier, releases was the last planned feature for Elixir. We don’t have any major user-facing feature in the works nor planned. I know for certain some will consider this fact the most excing part of this announcement! [0]
[0] https://elixir-lang.org/blog/2019/06/24/elixir-v1-9-0-releas...
Though I'm on the fence, that they end run around the pressure to evolve, by just inventing new DSLs via gobs of macro magic for some of the newer stuff. Whereas a language like Swift keeps leaning on the compiler to respond to evolving demands.
I was deeply disappointed a few years ago when the TensorFlow in Swift project was scrapped.
That project had a ton of potential, but it seems like it lacked buy-in from the industry, and the team working on it seemed to lack leadership as little progress ever seemed to get made.
Here is a real method signature under Swift:
public func index<Elements: Collection, Element>(of element: Element, in collection: Elements) -> Elements.Index? where Elements.Element == Element, Element: Equatable {
// Function body got is here
}It looks like you are doing SQL statement in just a method signature, which is just insane.
The Swift Team really needs to take a step back, and actually start removing features and simplifying the language drastically if they want it to succeed. At his point there is a great chance that Swift is becoming a liability for Apple and it may actually impact its app ecosystem negatively in the long term.
I hope they make a drastic change to it. Java was able to turn around, and start becoming a better language, I hope Swift does to, by simplifying and removing features and not just piling stuff into it.
The SQL analogy is a good one– what the function signature is doing is specifying a constraint between 2 otherwise unrelated values. Otherwise you could call the function with an array of `String`s an ask it for the index of an `Int`.
So. This. I have been a long time Apple fan. I noticed many years ago that they had a disproportionate representation amongst creative programmer types. I was intrigued and have come to understand why. It's not perfect, and Apple pisses me off some days, but overall the ratio of "It Just Works/WTF?" has been higher for me than other platforms.
As a Smalltalk guy, Objective-C was tragically comic, but nevertheless effective. It was like talking cavemen with your partner, and giggling about it, but you could still get stuff done.
When they announced Swift as "without the C", I was originally excited/intrigue. Despite some original surprises, I soon told peers "I've always hated C++, this feels like a decent compromise that I could like."
For quite some time, I've prototyped first on iOS, refined, and then replicated in Android. Because it was easier/better in Apple's stack than it was in Android.
At this point, I've given up. It's as complicated as C++, maybe more so. The Android development story is not all that much easier (Kotlin improves some things, but it's still Android), but Apple has actively lost their edge (for me) due to the added complexity.
I still write Swift on a pretty regular basis (I maintain/evolve 3+ apps with it). But to the point, I no longer want to. I'm actively interested in an alternate method of writing app UIs.
I don't use Swift full time and I had no problem reading that method signature.
This is something that you would write if you were a library author interested in providing generic and flexible data structure. The part after "where" expresses a non-trivial idea: "the type of the first element parameter should be the same as the inner element of the homogenous collection (second parameter), and we need to compare elements to other instances of its type but other than those constraints this code will work on any element and collection". It does that in about 6 swift terms, and the compiler has a full understanding of what you meant and will prevent errors that violate these constraints. Notice that you never have to write this type of code if you're using the library. Swift has decently organized progressive disclosure of language features. For example I never had to write unsafe pointer arithmetic or interop with C, but I'm not going to complain the feature is there for those that need it.
Or maybe because I'm saying this because I'm already acquainted to the evil monstrosities of C++. Here's the same function: (and this is even with C++20 concepts on):
// Yes, you need to include some headers to get even the most basic features! Typical C++.
#include <type_traits>
#include <optional>
template <Collection Elements, Equatable Element,
typename = std::enable_if_t<std::is_same_v<typename Elements::Element, Element>>>
std::optional<typename Elements::Index> index(Element element, const Elements& collection) {
// Function body
}Aside from the `where` keyword, I don't see much similarity with SQL. That said, I'm a big fan of SQL, so I might be blind to the issue.
Several other people have already said it, but I find that definition pretty easy to read, and I've never been paid to write a line of Swift. The most confusing part for me was the fact that the argument names seem to have spaces in them. The type constraints look pretty nice to me, to be honest.
I prefer
Language Design Team, Compiler (Backend/Frontend)? Team and similar more
But there has to be some mechanism for overall coordination, and with Rust that's the Core team.
The people that actually do the work on Swift are those that control the language and its destiny. You could fork it, but without a similar amount of effort behind your fork there's no way you can convince people to switch from the mainline.
While Swift can be used for linux desktop or as a backend language, what mostly matters for practical projects is the libraries, and I think for those cases the better libraries are on other languages.
Are you writing something else? Then, it's probably not the best investment to learn Swift.
I propose learning Kotlin if you want something syntactically similar but with broader set of usecases or Rust if the lack of runtime with modern syntax is what is appealing to you.
The question more is, is bothering to learn native smartphone app development a bad investment of time now that the low hanging fruit is gone and we're due for a new platform paradigm?
UPDATE: very good points below about the internet mob that would attack in response. Sad, but true.
This is a post to the internet, and I don't think having someone get flamed by a bunch of people online is a conducive way to settle a disagreement, whether they were being unprofessional or not.
> Maybe they'd learn and work on their behavior if someone told them?
I think the problem here is that there would be an online mob constantly telling them.
At least that’s the positive angle. The negative one is they are some kind of scumbag with enough leverage to keep their ass covered and picked a fight they thought they could win, but didn’t win enough to avoid consequences, just not public consequences.
Especially since words once said/written can never be taken back.
but when the same thing happen for rust, it's censorship, nobody talks about rust's internal problems
that's part of the reason i choose to not give rust another chance
the sectarian aspect of it is disgusting, to say the least
You clearly can see through the bias in HN, and each project has its controversies. Out of any project that I have seen that has had drama like this, the one that is more of a cult and has its problems hidden from view is most definitely Rust.
Just look at how this one went [0] or the level of discussion that is going on in [1] and [2]. The way the foundation was setup seems to be heading into another disaster, which even the main promoter of it is starting to distance away from it after getting upset about Amazon [3].
I won't be surprised to see the next controversy in Rust hidden away from view vs the controversies in other communities.
[0] https://news.ycombinator.com/item?id=29501893
[1] https://news.ycombinator.com/item?id=29306845
without parameter names, something like `func range(int, int)` can become dangerous because you dont know if the first parameter is the start and end or is it start and length?
`range(start: int, end: int)` makes it clear at the call site what is going on and gives your brain enough info to not mess up the parameters (especially when refactoring or fixing bugs in existing code)
Why can't I have a variable that has a protocol as type?
Why can't I pass a substring to a function that wants a string?
Why is string parsing so much harder than it should be?
Mike Ash answered[0] this question back in 2015.
[0] https://www.mikeash.com/pyblog/friday-qa-2015-11-06-why-is-s...