Project Ideas for GSoC 2024

This page contains a non-exhaustive list of potential project ideas that we are keen to develop during Google Summer of Code 2024. If you would like to apply to GSoC as a contributor, please follow these steps to get started:

  1. Read through this page and the Google Summer of Code guides,
  2. Identify, or come up with your own project ideas you find interesting.
  3. Check out the Development forum to connect with potential mentors.
    • Feel free to mention the project mentors on the forums, when starting a thread about your interest in participating in a specific project they are offering to mentor.

When posting on the forums about GSoC this year, please use the gsoc-2024 tag, so it is easy to identify.

Tips for contacting mentors

The Swift forums are powered by discourse, a discussion forums platform with spam avoidance mechanisms built-in. If this is your first time joining the forums, you may not be able to send mentors a direct message, as this requires a minimum amount of prior participation before the “send private message” feature is automatically enabled.

To start things off, we recommend starting a new thread or joining an existing discussion about the project you are interested in on the dedicated GSoC forums category. You should also tag your thread with the gsoc-2024 tag. It is best if you start a thread after having explored the topic a little bit already, and come up with specific questions about parts of the project you are not sure about. For example, you may have tried to build the project, but not sure where a functionality would be implemented; or you may not be sure about the scope of the project.

Please use the forums to tag and communicate with the project’s mentor to figure out the details of the project, such that when it comes to writing the official proposal plan, and submitting it on the Summer of Code website, you have a firm understanding of the project and can write a good, detailed proposal (see next section about hints on that).

If you would like to reach out to a mentor privately rather than making a public forum post, and the forums are not allowing you to send private messages yet, please reach out to Konrad Malawski at ktoso AT apple.com directly via email with the [gsoc2024] tag in the email subject and describe the project you would like to work on. We will route you to the appropriate mentor. In general, public communications on the forums are preferred though, as this is closer to the normal open-source way of getting things done in the Swift project.

Writing a proposal

Getting familiar with the codebase you are interested in working on during GSoC helps to write a good proposal because it helps you get a better understanding of how everything works and how you might best approach the project you are interested in. How you want to do that is really up to you and your style of learning. You could just clone the repository, read through the source code and follow the execution path of a test case by setting a breakpoint and stepping through the different instructions, read the available documentation or try to fix a simple bug in the codebase. The latter is how many open-source contributors got started, but it’s really up to you. If you do want to go and fix a simple bug, our repositories contain a label “good first issue” that marks issues that should be easy to fix and doable by newcomers to the project.

When it comes to writing the proposal, the Google Summer of Code Guide contains general, good advice.

Potential Projects

We are currently collecting project ideas on the forums in the dedicated GSoC.

Potential mentors, please feel free to propose project ideas to this page directly, by opening a pull request to the Swift website.

You can browse previous year’s project ideas here: 2023, 2022, 2021, 2020, 2019.

Create Real-World Swift Macro Examples

Project size: 90 hours

Estimated difficulty: Easy

Recommended skills

Description

Swift Macros offer a powerful way to transform source code during compilation, streamlining the code generation process and minimizing repetitive manual tasks. The swift-syntax repository features several examples showcasing Swift Macros. These serve as a foundational starting point, illustrating various types of macros. However, they often present scenarios that may not directly align with everyday use cases encountered in real-world applications. Additionally, there is notable variability in how these examples handle diagnostics, with some macros requiring more detailed feedback mechanisms for incorrect usage. This situation highlights a valuable area for enhancement, aiming to provide more comprehensive guidance and practical applications for developers.

This project is set to enrich the Swift community by enhancing the current suite of Swift Macro examples with real-world applicability and by introducing new, meticulously crafted examples. It will expand upon the foundational work in the swift-syntax repository, infusing it with comprehensive documentation and interactive tutorials created using DocC. Each example, both new and enhanced, will be carefully designed to showcase the use of different types of Swift Macros, equipped with practical diagnostics, unit tests, and detailed documentation. The initiative will also include the creation of DocC tutorials for some of the most sought-after and impactful Macros, providing an invaluable educational resource for the Swift community. Our aim is to illuminate the diverse capabilities of Swift Macros, highlighting their power and flexibility while sharing best practices for diagnostics, error handling, and testing. By building upon the existing examples and introducing new insights and techniques, this project promises to elevate the collective knowledge and utility of Swift Macros, fostering innovation and excellence within the ecosystem.

Expected outcomes/benefits/deliverables

Potential mentors

Lexical scopes for swift-syntax

Project size: 175 hours

Difficulty: Intermediate

Recommended skills

Description

Swift source code is organized into a set of scopes, each of which can introduce names that can be found in that scope and other scopes nested within it. For example, in a function like this:

func f(a: Int, b: Int?) -> Int {
  if let b = b {
    return a + b
  }

  return a
}

There is a scope for the outermost curly braces of the function, in which the parameters a and b are visible. There’s another scope introduced for the if let inside of that scope, which introduces a new name b (different from the parameter b) that is only visible within that if let. A lot of aspects of compilers and compiler-like tools depend on walking the scopes to find interesting things—for example, to figure out what names are introduced there (for name lookup, i.e., what do a and b refer to in the first return statement?), determine where break or continue go to, where a thrown error can be caught, and so on.

This project involves implementing a notion of lexical scopes as part of swift-syntax, with APIs to answer questions like “What does b refer to in return a + b?” or “What construct does this break escape out of?”. These APIs can form the basis of IDE features like “edit all in scope” and are an important step toward replacing the C++ implementation of scopes within the Swift compiler.

Expected outcomes/benefits/deliverables

Introduce a new library for the swift-syntax package with an API to implement name and scope lookup for a given syntax node, with lots of tests for all of the fun corner cases in Swift (e.g, guard let, implicit names like self, error in a catch block, newValue in a setter). From there, the sky’s the limit: there are many scope-based queries to build APIs for, or you could start building on top of these APIs for something like IDE support in SourceKit-LSP.

Potential mentors

Code Completion for Keywords using swift-syntax

Project size: 175 hours

Estimated difficulty: Intermediate

Recommended skills

Description

The swift-syntax tree has structural information about Swift’s grammar. For example, it knows all the different declaration nodes and which keywords they start with. This should allow us to perform code completion of keywords (such as struct) and punctuation (such as ->) by determining the cursor’s position in the syntax tree and figuring out the possible keywords at that position by iterating the syntax tree’s structure. For example, when invoking code completion at the top level, code completion should determine that a declaration is allowed at the top level, iterate over all the declaration nodes and collect the keywords they start with.

The tricky part is that the SwiftSyntax tree is an over-approximation of the Swift language. For example, accessors such as get { 42 } are modelled as declarations, but are only valid inside accessor blocks. We should need to perform some filtering and prevent get from being suggested at the top level.

swiftlang/swift-syntax#1014 is a draft pull request that implements the collection of possible keywords but performs none of the filtering. The project’s goal is to determine the contextual filters that need to be added to get good results with few or no invalid suggestions. Additionally, it should connect the new keyword completion implementation with sourcekitd to provide these results to Xcode, SourceKit-LSP.

The advantage of keyword completion based on swift-syntax is that its results are produced by the syntax tree’s and are thus guaranteed to be complete. It removes the need to manually maintain a list of keyword completions and provide previously missing completions like -> after the parameters in a function declaration.

Expected outcomes/benefits/deliverables

Provide all keyword or punctuator completions that are valid at a certain position in a SwiftSyntax tree with a very low ratio of invalid completions.

Potential mentors

Expansion of Swift Macros in Visual Studio Code

Project size: 175 hours

Estimated difficulty: Intermediate

Recommended skills

Description

Swift Macros allow the generation of source code at compile time. While this provides concise code and avoids repetition of common paradigms, understanding the source code can become harder if it is unknown what the macro expands to.

Visual Studio Code using the Swift Extension currently has limited ability to show the code generated by a macro by invoking a code action that replaces the macro by its generated code inside the current source file.

The project’s goal is to implement a code action to show the macro-generated code without modifying the current source file. This includes the implementation of a request in sourcekit-lsp to compute the contents of the macro expansion and support in the Visual Studio Swift Extension to display that content. Some initial discussion of how the design could look like can be found in this thread.

As a stretch goal, Visual Studio Code should also offer semantic functionality like jump-to-definition inside the macro expansion and allow the expansion of nested macros.

Expected outcomes/benefits/deliverables

An end-to-end implementation that allows the display of a macro’s contents in Visual Studio Code.

Potential mentors

Introduce Swift Distributed Tracing support to AsyncHTTPClient

Project size: 90 hours

Difficulty: Intermediate

Recommended skills

Description

During an earlier Summer of Code edition, the swift-distributed-tracing library was kicked off. The development of the library continued ever since, and now we’d like to include support for tracing in some of the core server libraries.

The recommended HTTP client for server applications in Swift is async-http-client, and this project is about introducing first-class support for distributed tracing inside this project. The work needed to be done is going to be similar to the work done in swift-grpc.

Distributed tracing allows correlating “spans” (start time, end time, and additional information) of traces, made across nodes in a distributed system. In HTTP, this means attaching extra trace headers to outgoing HTTP requests.

As an end result, the following code should emit trace information to the configured backend:

import AsyncHTTPClient
import Tracing

let httpClient = HTTPClient(eventLoopGroupProvider: .singleton)

try await tracer.withSpan("Prepare dinner") { span in
  let carrotsRequest = HTTPClientRequest(url: "https://example.com/shop/vegetable/carrot?count=2")
  let carrots = try await httpClient.execute(request, timeout: .seconds(30))

  let meatRequest = HTTPClientRequest(url: "https://example.com/shop/meat?count=1")
  let meat = try await httpClient.execute(request, timeout: .seconds(30))

  print("Dinner ready: \(makeDinner(carrots, meat))")
}

The above should result in 3 spans being recorded:

You can read more about tracing in the documentation of these libraries: swift-distributed-tracing, swift-otel.

Expected outcomes/benefits/deliverables

Potential mentors

Re-implement property wrappers with macros

Project size: 350 hours

Estimated difficulty: Intermediate

Recommended skills

Description

Property wrappers feature is currently implemented purely within the compiler but with the addition of Swift Macros and init accessors it’s now possible to remove all ad-hoc code from the compiler and implement property wrappers by using existing features.

This work would remove a lot of property wrapper-specific code throughout the compiler - parsing, semantic analysis, SIL generation etc. which brings great benefits by facilitating code reuse, cleaning up the codebase and potentially fixing implementation corner cases. Macros and init accessors in their current state might not be sufficient to cover all of the property wrapper use scenarios, so the project is most likely going to require improving and expanding the aforementioned features as well.

Expected outcomes/benefits/deliverables

The outcome of this project is the complete removal of all property wrappers-specific code from the compiler. This benefits the Swift project in multiple areas - stability, testability and code health.

Potential mentors

etcd client

Project size: 175 hours

Estimated difficulty: Intermediate

Recommended skills

Description

etcd is a strongly consistent, distributed key-value store that provides a reliable way to store data that needs to be accessed by a distributed system or cluster of machines. It gracefully handles leader elections during network partitions and can tolerate machine failure, even in the leader node. Furthermore, etcd is a CNCF graduated project powering Kubernetes which stores all cluster information in etcd.

Swift is a great programming language for implementing complex distributed systems and having an etcd client enables such systems to store their data reliably. The latest revisions of etcd exposes a gRPC API that clients can use to communicate with the etcd server to update and query stored data.

Expected outcomes/benefits/deliverables

Potential mentors

Add a deploy SwiftPM plugin and a Swift-based DSL to the Swift runtime for AWS Lambda deploy SwiftPM plugin and a Swift-based DSL to the Swift runtime for AWS Lambda section" href="#add-a-deploy-swiftpm-plugin-and-a-swift-based-dsl-to-the-swift-runtime-for-aws-lambda">

Project size: 90 hours

Estimated difficulty: Intermediate

Recommended skills

Description

AWS SAM templates provide a short-hand syntax, optimized for defining Infrastructure as Code (IaC) for serverless applications.

I started exploring the possibilities to represent a SAM template in Swift, using a DSL. The current code has three components:

The existing code has a significant challenge: to be useful for developers, the set of data structures and DSL must be aligned with the SAM template definition.

This project is aimed at simplifying the alignment with an ever-evolving SAM template definition by writing a code generator. The code generator will consume the SAM template definition and generate an API-stable set of Swift data structures. As a second step, a manually designed and coded DSL would consume these data structures to generate the YAML SAM template from the DSL.

Expected outcomes/benefits/deliverables

Potential mentors

Building Swift Macros with WebAssembly

Project size: 350 hours

Difficulty: Intermediate

Recommended skills

Description

Swift macros are built as host programs that make use of the swift-syntax package to process Swift syntax and produce new syntax. One of the downsides of this approach is that the build process for each macro can take a significant amount of time, and pre-building macro binaries is complicated by the fact that the binaries need to be built for multiple host platforms (e.g., Linux, Windows, and macOS) and architectures (e.g., x86 and ARM). Moreover, macros are aggressively sandboxed to prevent errors in macros from affecting the Swift compiler itself.

WebAssembly provides a portable compilation target that can be executed on any platform and architecture. SwiftWasm can compile Swift to WebAsssembly, and WasmKit provides a runtime that can execute WebAssembly programs. WebAssembly could provide a way to build Swift macros into binaries that can be distributed and run anywhere, eliminating the need to rebuild them continually. This project involves getting swift-syntax and macros implemented on top of it building to WebAssembly, teaching the Swift compiler to communicate with these macro implementations, and extending the Swift Package Manager with support for building and using macros with WebAssembly.

Expected outcomes/benefits/deliverables

The ideal outcome of this project would be for Swift macros to be able to opt into being built with WebAssembly and have the Swift Package Manager do so without further intervention from the user.

Potential mentors

Project topic proposal template

Project name

Project size: 90 hours / 175 hours / 350 hours

Estimated difficulty: Easy / Intermediate / Hard

Recommended skills

Description

Brief description of the project, its goals and what areas of the Swift project it relates to.

Expected outcomes/benefits/deliverables

Description of expected outcomes, like some specific feature being implemented, a performance improvement, or a guide being written. This will be the basis for passing the Summer of Code assignment and the final submission of the project.

Potential mentors