270 points · by Austin_Conlon · 6y ago · 72 comments
I've picked rust instead, it feels like the exact opposite of the single large actor supporting swift, instead it's a huge community effort with lots of use cases already being seen in many spaces. AND rust just got AVR support which I suppose swift could get pretty quickly with llvm as well
In theory, yes, but in practice I don’t see Swift going there comfortably. Its more dynamic runtime (compared to C or rust) needs more metadata, eating memory, which is precious on AVR (384 kilobytes, max, reading https://en.wikipedia.org/wiki/AVR_microcontrollers)
I think C# had that problem for a long time, but Microsoft did a great job / made a great strategic decision with .NET Core I think.
.NET was also available in other platforms where Microsoft saw commercial value, via partner agreements.
Swift was only publicly announced six years ago.
If you haven't seen it, check out the 2018 WWDC session "Embracing Algorithms" (https://developer.apple.com/videos/play/wwdc2018/223/). It's worth watching, even if you don't work with Swift.
In all seriousness, it feels like go's reputation of simplicity is at odds with its design. Instead of making a simple and highly generalized core from which anything can be composed, it has a specialized, familiar core that engineers are comfortable with.
When I take this question further, I begin to wonder why we even use text syntax for programming. What if we just had a graph structured programming "language" that is edited indirectly through different projected syntaxes that aren't necessarily monospaced text. Almost like lisp, but translated into different frontend languages, potentially graphical. (Maybe off topic but whatever)
more specifically, fairly basic operations on a list of data does not seem like it should call for the complexity of a DSL. IMO unless you need to do this quite a bit on random datatypes, copy & paste would probably be the better alternative. Unless you're referring to a DSL that looks exactly like Golang but with generics & monomorphism.... in which case ok I guess
https://blog.golang.org/generate
Now I'm wondering if you joke was not actually a joke.
For example Borland's BIDS 1.0 in Borland C++ for MS-DOS, it was based on the C pre-processor, as you would define a set of macros and then include the desired type, something like
#define LIST_T int
#include <bids/list.h>
#define LIST_T float
#include <bids/list.h>
and so on, however when BIDS 2.0 was released, there was already primitive support for the ongoing ISO discussions and it was rewritten to use templates.To be fair, Go generics seem to be finally on their way to be adopted into the language.
https://github.com/vasilevp/aboriginal
There is no engineering challenge that can't be overcome by ingenious thought!
So, you mean it's the job for generics. Which is a DSL for, well, generic types that compiles to final output. That way, the repeated code doesn't even exist, especially not in the code that humans actually write.
Right now, the Go spec + compiler chain are a lot simpler; adding generics would have made things a ton more complicated. Second, by first spending a lot of time perfecting the core language, understanding it, and resolving early issues, they have a much more stable base now to build generics on top of it. As the comment also implies, they take things slow and steady when it comes to Go; it's a language made to run core systems (e.g. at Google) for the next 30-50 years.
It's incredibly painful and off-putting to re-implement stuff you get for free in Python and Java when you're trying to learn everything else at the same time. Some companies give you the option to use whatever you want if you're applying for an iOS position (Google), and some don't (Apple, Facebook). But either way, if you do iOS, odds are you spend 99% of your time at work writing Swift and/or Objective-C, which means you'll have to put in extra effort in learning/re-learning Python or Java.
This is especially great for string algorithm problems. Manipulating strings in Swift in an interview is a traumatic experience if you haven't drilled it repeatedly, and you rarely need to do it during Real Work if you have functional backend developers.
That said, I love the language, and it's a big part of what motivates me to continue being an iOS engineer (I'm not sure I'd still be at if we had kept on with Objective-C).
I would love to see server-side Swift take off, but the ecosystem is still fairly new, so any large project would require you to roll your own solutions more often that you would need to in other languages. I was also excited to see https://www.tensorflow.org/swift — Swift being used for ML. Swift is working on support for differential programming, which is a cool development in the space. More info here: https://github.com/apple/swift/blob/main/docs/Differentiable...
Perhaps eventually there will be enough applications outside of the Apple ecosystem to reach a critical mass.
I think between Nodejs, Python, Go, (and maybe Rust), I can't really see much of a compelling usecase for Swift on the server. Even if you're developing a server component for an iOS app, I don't think it really is all that common to share a core between the two.
I agree that it’s not a language to adopt yet if you don’t also target apple platforms. Primarily I disagree with you about it not being good if you are developing a server component for an iOS app.
We don’t have the resources to currently target all three platforms, and we don’t have much hope for google frameworks as they tend to be changed/abandoned faster than we can afford to adopt them, and we can’t really rely on Facebook tech too much because of corporate ethics (I know it don’t make much sense, but it’s non-tech enterprise, this is probably the least weird ethics rule).
I mean, it doesn’t really have to be swift, it could be python, .net or kotlin, for all I care, but it’s probably more likely to be swift.
Android's NDK is quite limited, its main purpose is to implement native methods for Android Java/Kotlin, outside games, there is very little you can achieve without going through JNI or Android IPC into Java land.
It's a nice language though. I worry it's getting too complex, but the new features enable SwiftUI to work so I can't complain too much.
Other than that, outside Apple platforms is still in a worse state than clang Objective-C + GNUStep.
In RandomSample.swift:
// For log(_:) and exp(_:)
#if canImport(Glibc)
@_implementationOnly
import Glibc
#elseif canImport(Darwin)
@_implementationOnly
import Darwin
#endif
1. Why aren't those 'basic' functions already implemented in swift, and part of a math package (or in numerics)?2. Why release a package that does not support windows now that windows is officially supported?
- You can't use a for loop to loop over array elements by reference.
- Just look how to work with pointers in swift. There is nothing more to say about it. https://www.raywenderlich.com/7181017-unsafe-swift-using-poi...
A system programming language is a language in which you can write an memory allocator, or a function like dlopen(). While you can possibly do this in Swift, it would be much easier even in C.
I don't want to say swift is bad. The design desicions are ok for an application programming language.
How much more efficient are Apple’s algorithms over what was generally accepted as the best prior open source version?
Were these algos already a standard set for Apple engineers internally?
It seems like customers win if Swift apps are more efficient and less error prone.
Whether C++ is a good model to follow is another question entirely, of course! But at least Swift isn’t being completely idiosyncratic in its naming choices.
Of course technically any part of a program is an algorithm, but usually (like here) we reserve the name for general things like here (from path and graph to partition and search algorithms), not for our "business logic" algorithm.
This is exactly what algorithms are at the level of almost any language's included libraries. The name seems spot on.