Is the best code written in Swift beautiful? Does Swift as a language enable us to write the most beautiful code, better than any other language?

I think Swift is approaching the state where we can write the most beautiful computer code with the recent addition of variadic generic parameters, generalized existential, async/await/actor. We also have a wonderful swift community and ready made libraries that allows us to create our apps rapidly, library like Collections, Algorithms, Crypto etc: these libraries solve hard problem so we do not need to be domain expert.

Is Swift the best language currently?

1 Like

Clearly the most beautiful programs are written in Piet :P

The qualities of swift you mention don't make me think of beauty. Having to write async and await for example makes the code less aesthetically pleasing for me compared to hypothetical code that has it implicit.

The qualities you mentioned make swift a very nice and expressive language though


Piet is beautiful, but is not practical. You can't write an app for our Apple platforms. Or can it?

So you are saying multi-thread code can be implicit? Then why we don't do it instead of async/await? If the code is implicit, does that means the compiler can read your mind? How does it do this?

1 Like

I personally don’t disagree with explicit await, but Kotlin doesn’t require await in suspend functions, so why not?

Yeah, for example you can make all functions asynchronous, and every line behave as if there was an await there. Would it make everything harder to reason about? Yes. Would it make everything harder to optimize? Yes. Would it make swift a worse language? Yes. It would make the code more aesthetically pleasing, but it's not a good tradeoff.

You describe a lot of different qualities that are pretty independent from each other, and I would place other languages as better than swift in these categories:

  • beautiful: Piet
  • wonderful community: rust
  • ready made libraries: c++ or python
  • solving hard problems without being a domain expert: Microsoft Excel (Most people using it aren't even programmers!)
  • practical/best: this one is very much context dependent. If you're writing apps for apple platforms from scratch, then yeah. Swift is the best. But if you're enhancing linux kernel, then the most practical language is C. Android app - kotlin.

Swift is a very nice language all in all, probably my favorite, but there's still time and place for other languages