Skip to content
0:00 / 0:00

#swift#c++#interoperability

Introducing a Memory-Safe Successor Language in Large C++ Code Bases - John McCall - CppNow 2023

CppNow

39K subscribers • 42 videos on Hallway • Conference channel

YouTube
  • Recommended by 4 people: 3 on Hacker News and 1 on Lobsters.
  • Presented by John McCall, Swift Core Team member at Apple
  • Linked in the descriptionboostcon/cppnow_presentations_2023
  • An opinion. It argues one side of a question engineers disagree on.

Advanced. Deep dive for people who know the field.

18K views3 years ago4 recommendations

Programming languagesSystems programmingSwiftC++Language design and type systems

John McCall explains how to incrementally introduce Swift as a memory-safe successor language into large C++ codebases using bidirectional interoperability.

cppnow.org linkedin.com/company/cppnow --- Introducing a Memory-Safe Successor Language in Large Code Bases - John McCall - CppNow 2023 Slides: github.com/boostcon/cppnow_presentations_2023 --- Interest in memory-safe programming has never been higher, but how can you adopt it in an existing, large C++ code base without rewriting massive amounts of code at once? One tempting approach is to incrementally improve C++ by bringing the ideas from memory-safe languages back to C++. However, this path has inherent hard limitations forced by the language and library design. New languages offer the chance to start fresh with a memory-safe model, providing language affordances to make memory-safe programming the ergonomic and high-performance default. But the introduction of a new programming language in an existing code base typically requires widespread rewrites or the creation of large stub libraries. Swift is a memory-safe, multi-paradigm programming language designed from the beginning with fast, native bidirectional interoperability with the C family of languages. Swift code can be introduced into an existing code base a single file at a time, allowing large code bases to adopt incrementally, for example by implementing new features in Swift or performing targeted rewrites of problematic or safety-critical code. This talk will explore the key design aspects of Swift that make it uniquely suitable for integration into existing code bases. It will demonstrate how we’ve made use of Swift’s nascent C++ interoperability feature to bring Swift’s safety and expressiveness to large, established C++ code bases without massive rewrites. Along the way, we’ll reflect on lessons learned from our rollout of a new, memory-safe language throughout a large software ecosystem, in the hope that it can help the C++ community chart a path forward to a memory-safe future. --- John McCall John McCall has worked on programming languages at Apple for fifteen years. He is a language designer for Swift, for which he serves as the Chair of the Language Workgroup in charge of language and standard library evolution, as well as on Objective-C and many of Apple's language extensions to C. He is also a compiler and runtime implementor on both Swift and Clang and is a code owner of LLVM IR generation in both compilers. John helped bring up C++ support in Clang, including implementing core language features such as access control and exceptions. He also led the design and implementation of a number of memory safety and security features, such as automatic reference counting (ARC) in Objective-C, Apple's ABI adoption of ARMv8.3 pointer authentication in C, Objective-C, and C++, and the basic implementation design of Swift. --- think-cell develops one of the world’s leading PowerPoint applications, with C++ at the core of everything we build, from layout algorithms to deep integration with Microsoft Office. Interested in working on challengi

Why it's here

4 people recommend this

What people say. Recommended for its insights into language interoperability and Apple's strategy for transitioning from C++ to Swift.

dfon Lobsters • Recommends

Introducing a Memory-Safe Successor Language in Large C++ Code Bases

pjmlpon Hacker News • Recommends

On “Show HN: C-ocoa, Write iOS/macOS apps in any language, with a generated C API”

…coa and Cocoa Touch developers the performance and power they demand." -- link Some of the information related their Safe C dialect, link "2023 EuroLLVM - Keynote: “-fbounds-safety”: Enforcing bounds safety for production C code" link Finaly a recent gem from CppNow 2023, "Introducing a Memory-Safe Successor Language in Large C++ Code Bases" link to this video…

pjmlpon Hacker News • Recommends

On “Interoperability: Swift’s Super Power”

On the same note, watch Apple's talk at CppCon 2023, "Introducing a Memory-Safe Successor Language in Large C++ Code Bases" link to this video

mannuchon Hacker News • Recommends

On “Memory safety is necessary, not sufficient”

I wonder what the author thinks about Swift’s new C++ interop story? Since the Swift compiler includes Clang, and can thus compile both your C++ and Swift into LLVM IR, without the need for an FFI later between the two, couldn’t this be the “Typescript for C++” that the author points out a space for? The Swift folks are very much thinking about Swift as a C++ successor that can be incrementally migrated to so I’m a bit surprised the author didn’t discuss it further — especially given Swift’s spiritual similarities to Rust. There’s a couple great talks on this by folks on the Swift team. John McCall at CppNow link to this video Konrad Malawski at StrangeLoop 2023 link

glhayneson Hacker News • Recommends

On “Swift Static Linux SDK”

I'm not a (direct) user of the C++ interop, but everything I've heard about it has been quite positive. A few hopefully relevant resources, first a couple of videos: - "Introducing a Memory-Safe Successor Language in Large C++ Code Bases" (John McCall; CppNow 2023) link to this video - "Swift as C++ Successor in FoundationDB" (Konrad Malawski; Strange Loop 2023) link And then a series of blog posts by Doug Gregor: - "Swift for C++ Practitioners" link And finally: - "Mixing Swift and C++" (Swift.org) link

pjmlpon Hacker News • Mentions

On “Show HN: C-ocoa, Write iOS/macOS apps in any language, with a generated C API”

As mentioned on the Swift talk at CppNow 2023, most of the C bindings are actually C++ with extern "C", and Apple would rather write less of them than more of. "CppNow 2023:Introducing a Memory-Safe Successor Language in Large C++ Code Bases" link to this video

pohlon Hacker News • Mentions

On “Interoperability: Swift’s Super Power”

Don’t forget that this interoperability was put in place to support a specific engineering goal: to make it possible to slowly (over decades, probably) transition from 4 different languages (C, ObjC, C++, ObjC++) at every level of Apple’s stack towards a single successor language. Would you recommend they wait for some weird Java-esque 100% Pure implementation within the compiler itself before they can begin that work? The ideal you’re suggesting is actually made more possible by this work. One can imagine a Swift LLVM/Clang now. See: link to this video

stephen_gon Hacker News • Mentions

On “PostScript’s Sudden Death in Sonoma”

Apple have chosen to go all in on Swift for their first-party code, from the kernel to the libraries to the apps. Even things running on microcontrollers (but there’s no official or standard embedded Swift subset yet). It’s quite interesting actually that they’ve very intentionally focused on building transition layers so they can start gradually integrating Swift into C, Objective-C, and recently new support for C++ and Objective-C++. See this talk for the details on that - link to this video So don’t expect to see any Rust code from Apple, although of course they might ship third party things written in it at some point.

pjmlpon Hacker News • Mentions

On “Bare-metal Rust in Android”

Apparently people keep forgetting Swift exists. "CppNow 2023:Introducing a Memory-Safe Successor Language in Large C++ Code Bases" link to this video

pjmlpon Hacker News • Mentions

On “Apple's use of Swift and SwiftUI in iOS 17”

On the same subject, some talks from Apple folks, "Introducing a Memory-Safe Successor Language in Large C++ Code Bases" link to this video "Swift as C++ Successor in FoundationDB" link

stephen_gon Hacker News • Mentions

On “Apple's use of Swift and SwiftUI in iOS 17”

In the recent talk about the new Swift to C++ bidirectional bridge 1 the presenter from Apple says that they intend to eventually use Swift for basically all their first-party code from embedded code on microcontrollers, to the kernel, libraries and apps. There will be language subsets for embedded and kernel development, not all features would be able to be used at the lower levels. 1. link to this video

nrron Hacker News • Mentions

On “Swift was always going to be part of the OS”

…lutely ham on it in their branding, but the momentum unceremoniously fizzled out before Server 2003 went RTM.) That said, apropos .NET fitting into Windows, the work on Singularity2 by MSR had a lasting impact. I'm told that there is in use a System C# dialect that generates native object code via a more production grade version of Bartok3. 0: link to this video 1: link . 2: link 3: link…

stephen_gon Hacker News • Mentions

On “Operation Triangulation: What you get when attack iPhones of researchers”

…en for things much, much less complex than WebKit, you can have a team working for three years working on a replacement and it’ll have less features than the original had when you started). They’re even working on an embedded subset for embedded devices so things like microcontrollers like battery management, the Secure Enclave etc. can run it. 1. link to this video…

stephen_gon Hacker News • Mentions

On “Apple hiring compiler developers for improving Swift / C++ interoperability”

They definitely have opened some things up, like a full C++ interface to Metal. I think the idea with this current effort is kind of the opposite though - not to encourage more use of C++, but to start writing new features of C++ projects in Swift (the presenter at the C++ Now 2023 talk 1 goes into this). I expect WebKit is a big target for them, I think they eventually want to replace all their C++ with Swift gradually (instead of trying to do ground-up rewrites, where you dedicate a team to doing that for years and you have a replacement at the end with fewer features than the old project). 1. link to this video

pjmlpon Hacker News • Mentions

On “The Case for Rust in the base system”

Apple's John McCall makes a picture of where they are going with Swift in "Introducing a Memory-Safe Successor Language in Large C++ Code Bases" link to this video

pjmlpon Hacker News • Mentions

On “The Case for Rust in the base system”

Apple's John McCall makes a picture of where they are going with Swift in "Introducing a Memory-Safe Successor Language in Large C++ Code Bases" link to this video