7 ms·
Implementing parts of the Swift compiler in Swift
- kensai 4y agoHow’s this language doing? Any big projects on Swift in the last years?
- speeder 4y agoThe company I work for uses Swift a lot... that said, the performance sensitive parts of the code is still Cpp. Swift is nifty but still not Cpp I guess.
- asadlionpk 4y agoHow does it compare performance wise to cpp in real-life.
- Teknoman117 4y agoIs the company you work for mostly targeting Apple devices? I'd be interested to hear if there is any large scale Swift usage outside of the Apple ecosystem. If you are targeting Apple devices, was your performance sensitive code always written in Cpp or did you leave Objective-C for Swift+Cpp? Or, were the Cpp parts inherited and just wrapped with whatever your platform's encouraged language was? (I used to do contract iOS work but I stopped around the time Swift came out due to taking a rewarding full-time job, so I never really spent much time on Swift beyond "huh, neat")
- machinekob 4y agoStill macOS language, a lot of cool features but not enough community on linux and for sure windows :/
- andrewbarba 4y agoThis is a shameless plug, but I built Swift Cloud to help people build scalable backends in Swift: https://swift.cloud https://swift.cloud Behind the scenes we compile Swift to WASM and deploy to Fastly's edge network, Compute@Edge. At my day job we are using this in production and serving thousands of requests per second on our Swift app. Overall it's a lot of fun to deploy Swift on server, but the developer UX still leaves a lot to be desired. Running and testing locally is still non-trivial.
- pradn 4y agoThis looks great, good work! One tangential question: do you worry about using "Swift", which I assume is an Apple trademark, in the name of your product?
- andrewbarba 4y agoThanks so much. And short answer - Yes. My guess is it's a matter of 'when' I have to deal with this. I've had the domain for a while, and this is something I've wanted to build for such a long time. Things fell into place when I was able to build a Swift SDK for Fastly's platform back in January this year. The stubborn engineer in me went ahead and used the domain anyway and launched what you see today.
- pradn 4y agoGotcha, thanks for your answer :)
- danudey 4y agoI have no use for this project, but this seems super cool!
- sudoit 4y agoI already created an account! I’m definitely going to use this the next time I need a little cloud function
- andrewbarba 4y agoLove to hear that! Always feel free to reach out if you have any questions or run into issues.
- aaaaaaaaaaab 4y agoAFAIK most people have been moving away from it in favor of Rust and Zig. A lot of friends at FAANGs are still working in ObjC codebases, and probably gonna skip the whole Swift story by jumping straight to Rust when the time comes. But of course this could be just in my bubble...
- tambourine_man 4y agoIf you mean anything other than iOS apps, sure. But for this latter case, there’s no real alternative. An iOS app in Zig or Rust is in an extremely small niche.
- liuliu 4y agoWould be interesting to know the "moving away from Swift to Rust / Zig" story. My impression is that Swift not even in consideration in most projects with Rust / Zig.
- hot_gril 4y agoI can see some performance-sensitive projects being done in Swift, Rust, or Golang. Funny, the place I don't like using Swift is its main use case, high-level iPhone apps. It's overkill. The complex Stackoverflow answers for "how to do (simple thing like getting a substring) in Swift" say so.
- jarjoura 4y agoRust is taking over the tools space for sure, replacing important tools that need to run often and speed is king, replacing tools written in python and perl. Rust is also making its way into new core cross-platform libraries that need speed, instead of C++, however, no one is going to rewrite C++ libraries. No UI or product team is going to use Rust over Swift (or Kotlin) or whatever your stack currently depends on.
- pjmlp 4y agoSwiftUI and Metal look like big projects.
- tubs 4y ago95% of the underlying metal driver is written in cpp.
- pjmlp 4y agoOf course it is C++, that is what IO and Driver Kits use. App developers use the Objective-C and Swift userspace libraries. The newly released header only library for Metal in C++, is a poor man's binding, that wraps the C API of the Objective-C runtime, without the Metal frameworks written in a mix of Swift and Objective-C.
- chunkyguy 4y agoMetal shading language is C++14
- eob 4y agoWe use Swift on the server at Steamship. Our Swift project is a federated database for NLP data (query, training, inference, embeddings — the whole bit) I assume folks are familiar with the downsides of Swift on Linux so I’ll focus on what we like about it: - Fantastic type system - Good language extensibility (we use Swift to build ourselves a framework to develop Steamship more easily) - Good LLVM extensibility - Mostly performant - Compiled All in all, we're very happy with the choice. My biggest gripe is slow build & test times in GitHub actions. If Swift developers are out there and wanting to dig into more systems-style development, I'm happy to chat.
- liuliu 4y agoAssuming you have to do a lot of string processing (for NLP). Do you have any "shortcut" to do that in Swift? The API is thoughtful, but tedious to type, comparing to Python. It would be great if we have some semi-official "shortcut" libraries just for string processing (The recent RegEx literal is a welcome addition, but not enough).
- eob 4y agoThat's a very gentle way to describe the agony of string processing in Swift :-). We have written a few shortcut libraries ourselves, but we actually don't end up writing a great deal of string processing code in practice because most of our operations are expressed in a higher level query language that gets compiled down to lower-level operator implementations (which only get written once). The vast majority of our code (maybe like a lot of systems?) ends up being more about the management of the broader data & processing environment that coordinates everything.
- musicale 4y ago> Mostly performant I assume that means "efficient at runtime" - but by what metrics? CPU time? Memory usage? Power usage? Latency/responsiveness? Throughput? What are you comparing it against? > slow build & test times in GitHub actions What is the cause of this? Is the generated code slow or just the compiler?
- outadoc 4y agoSure, all recent iOS apps
- hot_gril 4y agoNot really, since so many are React Native. Technically still involves Swift, but eh.
- jonas21 4y agoApart from mobile apps? (some of which are among the most widely-used pieces of software in the world)
- wiseowise 4y agoYes, preferably those that run outside of iOS/Mac.
- tomovo 4y agoCan it get even slower?
- CharlesW 4y agoThan what? I'm looking at benchmarks vs. other modern languages and it doesn't appear to be slow.
- aaaaaaaaaaab 4y agoBe patient... We've seen how O(2^n) algorithms can be utilized in the Swift compiler, but it's still a long way to the Ackermann function... I have faith in them!
- humanwhosits 4y agoI'm surprised that they aren't making a bigger effort for Linux support. Last time I tried swift on linux it wasn't even packaged by ubuntu. If you `apt install swift` you get some object store tool.
- pjmlp 4y agoWhy should they? That isn't their target audience. Objective-C also has been available on Linux for about 25 years now, and it has hardly mattered.
- Kukumber 4y ago> Why should they? That isn't their target audience. Because they need it? Apple discontinued macOS server, i bet they use Linux in some of their servers All their networking related libs are available and tested for Linux [1, 2, 3] Let's not forget that they package Swift for Linux, and now also for Windows [4] Swift is a cross-platform language (you not wanting to understand it doesn't change this fact), it's not a macOS framework [1] - https://github.com/apple/swift-nio https://github.com/apple/swift-nio [2] - https://github.com/apple/swift-protobuf/blob/main/.github/workflows/build.yml#L14 https://github.com/apple/swift-protobuf/blob/main/.github/wo... [3] - https://github.com/apple/swift-distributed-actors/search?q=linux https://github.com/apple/swift-distributed-actors/search?q=l... [4] - https://forums.swift.org/t/announcing-swift-5-6-2-for-linux-and-windows/58167 https://forums.swift.org/t/announcing-swift-5-6-2-for-linux-...
- pjmlp 4y agoThat is charity to pay lip service to FOSS folks, just like the Darwin repos. Most of the work on Linux and Windows isn't made by Apple employees.
- Kukumber 4y agoSo you want a language fully owned by a company with 0 external contributors? History tells us that it is not a good idea ;) And your statement is not true at all, look at the commit history
- tempodox 4y ago> However, it would be a significant bump in requirements for using the compiler on macOS: currently, the compiler can run on macOS 10.9 or newer. This would move that requirement to macOS 10.15. Is this even relevant? For using a newer Swift with Xcode I'm forced to upgrade the OS anyway. Xcode absolutely refuses to be installed on previous OSes. Can you sensibly develop in Swift with anything else besides Xcode?
- danudey 4y agoIt's more a question of things like if you're building the Swift compiler in your CI system with macOS nodes less than 10.15, then you'll have to upgrade them. That can be problems if the build nodes you're building on are on hardware that doesn't support macOS 10.15. Now you have to buy a whole new Mac Mini or whatever just to continue building.
- jesprenj 4y agoWhat about virtualization? https://github.com/kholia/OSX-KVM https://github.com/kholia/OSX-KVM
- w10-1 4y ago> Can you sensibly develop in Swift with anything else besides Xcode kinda. I bring a throwaway laptop most everywhere which is enough to build swift packages and test using LSP-based IDE.
- AlexeyBrin 4y agoCan you sensibly develop in Swift with anything else besides Xcode? Kinda, you can install Swift Playgrounds on an iPad or Mac and develop apps with it. Not as powerful as Xcode, but you can use it.
- cguess 4y ago> Can you sensibly develop in Swift with anything else besides Xcode? JetBrains makes a fully-featured IDE for Objective-C and Swift. https://www.jetbrains.com/objc/ https://www.jetbrains.com/objc/
- pjmlp 4y agoGreat news, so the bootstraping process starts...
- abudabi123 4y ago[flagged]
- mathverse 4y agoIt is sad that this language is almost useless for anything else than osx/ios apps.
- Toutouxc 4y agoIs it, really? I mean, it's Turing-complete, nice to use, quite fast... I don't see a reason not to reach for Swift if I want to do some reasonably generic data crunching (instead of say, Java, C++, Crystal or similar languages).
- robertlagrant 4y agoFinally, a Turing-complete language!
- gh123man 4y agohttps://vapor.codes/ https://vapor.codes/ brings Swift to the server and it's quite good! Wrap that in docker and you can be running Swift anywhere pretty quickly.
- cvwright 4y agoAnd with async/await, server side Swift is really nice now. The old stuff with eventloops and SwiftNIO was painful. Now it feels almost like writing Python, only with a real type system and not slow.
- adenozine 4y agoIf they’d get cross compilation working and a better story for Linux, I’d be VERY interested in building things with it. Until then, it seems too impractical. I’m not sure who their dev audience is, but it’s surely not aimed at people like me.
- liuliu 4y agoThey do now offer more than Ubuntu (and now with arm64 on Ubuntu too, I guess for rPi) https://www.swift.org/download/ https://www.swift.org/download/. It is quite usable with SwiftPM or Bazel on Linux. And SwiftPM can also generate static binaries (packaged everything on Swift side up until Glibc). VS Code extension support is passable. It appeals to works between Rust and Python (i.e. application focused work that the default running speed is a plus not a requirement, also want to spend less time to think about object lifetime, more to think about the business logic).
- mbakke 4y agoI hope they follow Go's example and maintain a "bootstrap" branch that only need a C++ compiler, which can be used to build the latest version. Otherwise it will be a hard sell in distributions that don't want random binaries at the root of all Swift packages. Or at least make sure new versions can be built with the previous (Rust-style), and not require downloading new binaries for every release (looking at you, Mono). See Ken Thompsons now-infamous "reflections on trusting trust" and https://bootstrappable.org https://bootstrappable.org for why this is important. (I may come off a bit grumpy from recently trying to port old versions of JDK and GHC to a newer toolchain; yet consider myself lucky to have the privilege).