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

CppNow · 18K views · 2023 · 1:22:21

Open on YouTube

C, C++, Rust, Go & systems languagesProgramming language designSecurity & hackingtalkdated

Why Hacker News recommends it

Used as the primary source for Apple's stated plan to make Swift its successor to C++ and for how interop supports gradual transition.

What it is

John McCall of Apple's Swift team presents at CppNow 2023 on introducing a memory-safe successor language into large C++ code bases. He argues incremental improvement of C++ hits hard limits and explains Swift's C++ interoperability for gradual migration.

Recommended by 3 HN commenters across 3 different months, 2023 to 2025.

What Hacker News said

Recommends pjmlp · 2023-09 · on “Show HN: C-ocoa, Write iOS/macOS apps in any language, with a generated C API”

Java also compiles to native code on Android. Try to write an iOS application using only C and C++, instead of either Objective-C or Swift. "Swift was designed from the outset to be safer than C-based languages, and eliminates entire classes of unsafe code" -- [LINK] "Swift is a successor to the C, C++, and Objective-C languages. It includes low-level primitives such as types, flow control, and operators. It also provides object-oriented features such as classes, protocols, and generics, giving Cocoa 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 b

Recommends pjmlp · 2023-09 · 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" [this video]

Recommends mannuch · 2023-12 · 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 [this video] Konrad Malawski at StrangeLoop 2023 [LINK]

Recommends glhaynes · 2024-06 · 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) [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]

Cites pjmlp · 2023-09 · 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" [this video]

Cites pohl · 2023-09 · 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: [this video]

Cites stephen_g · 2023-09 · 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 - [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.

Cites pjmlp · 2023-10 · 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" [this video]