Hi! I am relatively new to competitive programming , taken parts in GCJ for 2 years (with Swift). I am certainly new to CodeForces.
I want to use Swift for solving problems on CodeForces, and I am slightly surprised that this isn't an option. If I were to guess, I would say maintaining another language could be costly. But searching through other blogposts (Say https://codeforces.me/blog/entry/72941, https://codeforces.me/blog/entry/52225, https://codeforces.me/blog/entry/67751), it looks like it just wasn't discussed seriously. Also, I couldn't find any general guidelines for suggesting a new language, so it looks like it was just never discussed seriously.
In view of this, I wish to make a feature request about if it is possible to include Swift (Swift 5.1 by Apple) as a language for codeForces.
I will go through some reasons why it is very reasonable to use Swift for CP.
1) Main Reason: It is a Developed modern language that is decently popular
Swift is a modern language, that has been out since 2014. Basic Object oriented, try/catch features exists. Swift also does a lot of modern features quite well: First class functions, Generics, strong inferred typing.
Swift is consistently within the top 10 most popular language, whichever source I find.
2) Reason for CP: Very clean syntax
Unlike the the Apple predecessor Objective-C , which is very archaic and clunky in its syntax. The whole Swift is built from ground up keeping clean syntax in mind. Clean syntax is one of the promise of the Swift language. A few things that worth mentioning:
- No ; , () , and "return" whenever unambiguous
- Inferred typing, but still type safe
- The syntactic sugar of optionals (? and ! operators, guard statement in Swift)
- Many shorthands for closures (Pure functions in some languages): Any of these can be used for sorting: {a,b in return a<b},{return $0 < $1} , {$0 < $1} ,<, and of course .sorted() if it is a standard type.
And some very versatile features that is helpful for large projects, but are conceivable to develop a CP framework out of: Generics, and Protocol with associated types And latest features in Swift 5: Functional builder and property wrappers
Certainly some of these features will be present in some other languages. I don't know about all languages, I am only certain these are not in Python, for example.
The point is not that all these can be reasonably applied in CP, rather, that this set of tools is adapted to some CP tasks, so this option should exist.
3) The language isn't slow, it is still a statically typed compiled language after all.
4) Also , not a good reason by itself but still worth mentioning: Google Code Jam has Swift as an option.
I will admit, I like using Swift because I come from industry programming, and a large portion of popularity is due to it being the native language for Apple developments. However, I firmly believe that as explained above, it is a very serious language that is competitively viable.
Therefore, I wholeheartedly wish that I can use Swift for CodeForces. I hope this can be considered seriously.
Auto comment: topic has been updated by arvindf232 (previous revision, new revision, compare).
We want Swift here!
Not to create a new blog, I decided to bump this. I agree with him.
I have never seen anyone outside of Apple's "developer ecosystem" ever use Swift. So I don't know how much support you'll get from Mike.
It's right that Swift lives in macOS, but the thing is it's a very cool programming language. Also if we have D, Go, Haskell, OCaml, Delphi, Ruby, Rust, Scala, then I think Swift will have more users than those languages although they are useful or were at least at the early days of Codeforces.
Getting Swift added at Codeforces would be useful. But there's no need to make guesses. We can easily check the number of accepted problem A submissions from the last AtCoder ABC contest in Swift, D, Go, Haskell, OCaml, Pascal, Ruby, Rust, Scala.
At least Rust, Ruby and Go seem to have a lot more users than Swift on the AtCoder platform. Yes, you can say that Swift (12 users) is somewhat more popular than D (6 users), Haskell (6 users), Scala (4 users), OCaml (1 user) and Pascal (1 user). Still they are all pretty much at the bottom of the barrel.
Personally, when I need to learn a new language, I start by solving a lot of CF problems with it. So if adding it is an "easy" thing to do, it might be helpful to people who know of CF and need to practice for some iOS development for their job or personal projects perhaps.
Learning a language this way is somewhat like speedrunning Duolingo: fun but pretty much useless. I mean, all basic features like arithmetic, array access, and so on, are the same or very similar in all non-esoteric languages. By solving problems you do learn the basic syntax of the language, but you still know nothing about its type system, paradigm, standard libraries (except for reading/writing numbers and maybe strings). Unless you're going to be writing purely computational software, you will need to learn those to write code that does something real.
Bump! 👆
you can use kotlin though it's the closest thing to swift
Why not just compile the code offline, and put it in a large asm() block in a language that has those?
And to avoid "obfuscation" claims, put the original source in the comments.
Swift is in the top 20 Top Computer Languages. The majority of the common CP data structures are now available in Swift. Plus, it is supported by AtCoder, LeetCode, and others. It would be a wise decision to attract all the iOS development world into the wonderful world of CP.
Swiftforces :)
It seems like once every half a year-ish this blog will gets revived when someone wants Swift in Codeforces. I decided to leave something here for all future visitors, and provide some additional context.
I posted this blog when I was unrated. Obviously, on CF, no one would care, so understandably nothing changed.
This is my first blog post when I was unrated, looking to enter CodeForces and competitive programming in general with a language that I was familiar with. Not finding Swift, I did not start my journey in programming. 6 months later, I decided it is worth the effort to learn a different language to take part in competitive programming. Initially, I used Python, but after a few bad TLEs I learnt and switched to Kotlin.
Two years later, I had just become LGM with Kotlin. And still there is no Swift.
If you are considering Swift, you should definitely consider Kotlin. Almost all nice things (including everything in this blog) I like about Swift can be found in Kotlin. There are some bad things in Kotlin that swift does not have. Most of them are inherited from Java (such as the scuffed IntArray vs List) , some are unfixable by language designs (object overheads, no access to pointers).
Should there be Swift on codeforces? I think so. Even if Kotlin fulfils the same niche as Swift, and even if I think Kotlin may be better, having more options is always nice. I probably won't even experiment with Swift having being so committed to Kotlin, but I am sure someone else would.
Which one is better; Swift or Kotlin? I already forgot everything about Swift. So, I don't know. Though, here are some points that are worth mentioning. (Please correct me if I am off at anything about swift)
LGM in 3 years, has anybody reached to this level this fast?
In recent years, Swift has expanded its platform compatibility, including to Windows. I think it should be a lot easier for Codeforces to support Swift now, compared to when this blog was first published.
I also agree with many of the points in this blog and comments section about Swift having a lot of potential as a competitive programming language.
Tagging MikeMirzayanov to reconsider.
https://www.swift.org/install/windows/