@dgregor79@sfba.social avatar

dgregor79

@dgregor79@sfba.social

Dad, husband, Swift language designer and Swift/C++/ObjC compiler implementor, Author, Generic Programming aficionado. He/him.

This profile is from a federated server and may be incomplete. Browse more on the original instance.

dgregor79, to random
@dgregor79@sfba.social avatar

The fifth (and final!) episode of my guest appearance on the ADSP podcast is up! We talk about more , generics, Swift 6, and data race safety. https://www.adspthepodcast.com/2024/05/31/Episode-184.html

dgregor79, to random
@dgregor79@sfba.social avatar

I had some fun today adding "subcommand group" support to the argument parser library: https://forums.swift.org/t/grouping-subcommands/72219

dgregor79,
@dgregor79@sfba.social avatar

@siracusa YOU MAY NOT LIKE IT, BUT THIS IS PEAK MAN PAGE STYLING, JOHN

alexr, to random
@alexr@mastodon.online avatar

Can we convict him of insurrection and treason now, please?

And revamp Alcatraz just to hold him and the rest of his crime family associates?

dgregor79,
@dgregor79@sfba.social avatar

@alexr @schwa Just think of the tourist dollars it would bring in

mattiem, to random
@mattiem@mastodon.social avatar

A Swift concurrency pattern I’m seeing more and more is the “stateless actor”. This is fascinating, because it seems so counterintuitive. But I think people are reaching for this to get convenient access to background processing.

I don’t think this is “wrong”. But I think it is probably building bad habits. Local, private nonisolated methods are usually simpler and better long-term.

dgregor79,
@dgregor79@sfba.social avatar

@mattiem @dimsumthinking I agree! If you have some work you want to move off to the background, mark the function nonisolated but otherwise leave it in place.

dgregor79, to random
@dgregor79@sfba.social avatar

Part 4 of 5 on ADSP, this time talking about Swift! https://www.adspthepodcast.com/2024/05/24/Episode-183.html

jsq, to random
@jsq@mastodon.social avatar

“gasoline spaghetti” would be a great name for song

dgregor79,
@dgregor79@sfba.social avatar

@jsq can the song be about technical debt that’s going to cause your next deployment to go up in flames?

dgregor79, to random
@dgregor79@sfba.social avatar

If you’re not yet totally sick of hearing me talk… part 3 of my interview on the ADSP podcast is up, where we talk about variadic templates, std::variant, and (finally!) some Swift: https://www.adspthepodcast.com/2024/05/17/Episode-182.html

dgregor79,
@dgregor79@sfba.social avatar

I did a bit of digging on the digit separators issue, and I think I have reconstructed what happened. Digit separators came in to the meeting with a couple of different possible syntaxes: underscores (like Swift has) would have been preferred (e.g., 1_000_000), but they conflicted with user-defined literals on hexadecimal literals (0x1000_beef is ambiguous).

So the syntax changed to use spaces as digit separators (e.g., 1 000 000), and I think that’s what was coming up for a vote. Some Clang folks (including myself) noticed an ambiguity with Objective-C’s message send syntax while trying to implement it (yes, at or near the bar; compiler people are weird), and alerted the committee. Digit separators did not pass at that meeting.

Eventually, C++ got digit separators with the tick (e.g., 1’000’000). It’s unambiguous, albeit a bit ugly IMO. I don’t think I’ve ever seen them used in practice.

dgregor79, to random
@dgregor79@sfba.social avatar

2021 me did a quick temporary hack to unblock a critical feature.

2024 me just tripped over it in the dark and fell flat on his face.

2024 me is not amused with 2021 me.

Gandalf saying “I have no memory of this place”

finestructure, to random
@finestructure@mastodon.social avatar

Folks who squash their merges, I’m curious why you are making that trade-off. I’m guessing the pro argument is a cleaner merge graph?

The big argument against it for me is that you lose granularity for git bisect. I've often been able to narrow down breakage (sometimes long past the merge) due to individual commits in the merge. If I'd merged in a giant blob all I'd have had to go by is that giant blob. (1/2)

dgregor79,
@dgregor79@sfba.social avatar

@fabianfett @finestructure I recently landed a PR to SwiftPM where one commit in particular was of the form “temporarily work around a bug in an old Swift compiler.” The change was otherwise nonsensical and would have been reverted trivially in the future… except that it all got squashed together with a pile of good code because that’s how SwiftPM is configured. I hate the destruction of history like that; it makes it harder to undo parts of a change when that’s needed (which is common for us), and robs us of the logical flow of how a change was introduced. I cannot be convinced otherwise.

finestructure, (edited ) to swift
@finestructure@mastodon.social avatar
dgregor79,
@dgregor79@sfba.social avatar

@finestructure I used this recently to get Swift installed on a fresh Ubuntu and was up and running within 5 minutes.

stroughtonsmith, to random
@stroughtonsmith@mastodon.social avatar

Does Swift's MainActor annotation actually do anything at runtime to ensure code is called from the main thread, or is it entirely a compile-time sanity check that might not play well across opaque binary/framework boundaries?

dgregor79,
@dgregor79@sfba.social avatar

@stroughtonsmith There's a compiler flag -enable-actor-data-race-checks that enables additional runtime checking for actors in existing compilers. Swift 6 is getting an improved version that's documented at https://github.com/apple/swift-evolution/blob/main/proposals/0423-dynamic-actor-isolation.md

dgregor79,
@dgregor79@sfba.social avatar

@stroughtonsmith it emits a check on entry to a synchronous, actor-isolated function that ensures it’s running on the right actor. The check itself is fairly cheap, but could add up in a. Tight loop. The Swift 6 implementation should have lower overhead, because it can limit checks to those places where it is interfacing with code that isn’t statically checked.

dgregor79, to random
@dgregor79@sfba.social avatar

It’s been about 15 years since C++0x Concepts were removed from the draft that became C++11. I sat down with Conor and Bryce to talk through the goals and design of C++0x concepts, and some of the similarities and differences with the C++20 feature that bears the same name. https://www.adspthepodcast.com/2024/05/03/Episode-180.html

paris, to random
@paris@hachyderm.io avatar

if you go to Paris and don’t take a cheesy pic to send to me, are we really even friends?!

🤪

dgregor79,
@dgregor79@sfba.social avatar

@paris “Hey Siri, when I arrive in Paris, remind me to send a picture to Paris.” (I have no plans to go to Paris, but I’ll hedge my bets)

dgregor79, to random
@dgregor79@sfba.social avatar

I’m proud of my friends, former colleagues, and the students of Indiana University Bloomington for standing up and making their voices heard in peaceful protest. I’m also terrified for them, because Indiana has always been a deeply red state that shows serious fascist tendencies, and these (as-yet unconfirmed) reports of snipers on the roof of academic buildings is an unnecessary, dangerous escalation on the part of the state. Stay safe out there.

dgregor79, to random
@dgregor79@sfba.social avatar

My more-than-a-decade-old Brother monochrome laser printer finally failed, so alas, I must replace it. With another Brother laser printer, of course. But this one has color! And was manufactured after AirPrint so I can print from my iOS devices. This is Progress!

dgregor79, to random
@dgregor79@sfba.social avatar

Every time I get a chance to use it, the swift-argument-parser library sparks joy: https://github.com/apple/swift-argument-parser

stroughtonsmith, to random
@stroughtonsmith@mastodon.social avatar

One of the big worries I had with Swift from the very start was how long it would take me to get back to building cross-platform apps and games if I adopted it.

Well, we're here, ten years later. Swift is robust, portable, and with C++ support easily handles Windows, the Windows App Platform, and now game dev through the magnificent work of @Migueldeicaza and SwiftGodot. I can build a game in Xcode and Godot that deploys to Windows, Linux and Android using Swift, and that's pretty f-ing cool

Little demo project, built with Swift and Godot, running on Windows 11. A character moves in 2D, a sprite sheet updates based on that movement, and there’s a text label that shows the Swift source file that its compiled from

dgregor79,
@dgregor79@sfba.social avatar

@Migueldeicaza @stroughtonsmith This documentation does appear on the Swift Package Indez, though, unless you’re talking about something else: https://swiftpackageindex.com/migueldeicaza/SwiftGodot/0.41.0/documentation/swiftgodot

dgregor79, to random
@dgregor79@sfba.social avatar

Hello C++ folks! I've started a blog series aimed at C++ programmers who are interested in learning #SwiftLang. It teaches the breadth of the Swift language, but anchored in the features and idioms of C++. So if you know your Rule Of Fives and your SFINAEs and think you might be interested in Swift, I'd love to hear what you think. Part 1 is something you know of from C++ that Swift takes a bit further: value types. https://www.douggregor.net/posts/swift-for-cxx-practitioners-value-types/

dgregor79,
@dgregor79@sfba.social avatar

Part 2 explore's Swift's reference types and optional types. These notions exist in C++, but Swift has a different take on them: https://www.douggregor.net/posts/swift-for-cxx-practitioners-reference-types/

dgregor79,
@dgregor79@sfba.social avatar

Part 3 explores Swift's "extensions", something I dearly miss in C++. Member-or-free-function should be a syntactic choice, and no more. Details at https://www.douggregor.net/posts/swift-for-cxx-practitioners-extensions/

dgregor79,
@dgregor79@sfba.social avatar

Part 4 covers #SwiftLang generics, whose design was inspired by the ideas of Generic Programming that had their first successes in the C++ Standard Template Library. Swift generics are separately-typed and a joy to use, but you'll have to leave template metaprogramming behind... more at https://www.douggregor.net/posts/swift-for-cxx-practitioners-generics/

dgregor79,
@dgregor79@sfba.social avatar

Part 5 covers type erasure. If you've used std::any or std::function (or their Boost predecessors), you know what type erasure is. In #SwiftLang, it's part of the language and integrated with the generics system. Also along for the ride are "metatypes", i.e., types that are expressed as values, allowing for runtime discovery and computation. Details at https://www.douggregor.net/posts/swift-for-cxx-practitioners-type-erasure/

dgregor79,
@dgregor79@sfba.social avatar

Part 6 covers error handling. The throw/catch approach will be familiar to C++ practitioners, but most of the defaults are different in Swift from C++. Also, the 'Never' type is really quite something... https://www.douggregor.net/posts/swift-for-cxx-practitioners-error-handling/

  • All
  • Subscribed
  • Moderated
  • Favorites
  • megavids
  • thenastyranch
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • ngwrru68w68
  • provamag3
  • magazineikmin
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • JUstTest
  • All magazines