arvindf232's blog

By arvindf232, history, 20 months ago, In English

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.com/blog/entry/72941, https://codeforces.com/blog/entry/52225, https://codeforces.com/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.

 
 
 
 
  • Vote: I like it
  • +3
  • Vote: I do not like it

»
20 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by arvindf232 (previous revision, new revision, compare).

»
3 months ago, # |
  Vote: I like it +83 Vote: I do not like it

We want Swift here!

Spoiler
»
3 months ago, # |
  Vote: I like it +6 Vote: I do not like it

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.

  • »
    »
    3 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

    • »
      »
      »
      2 months ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      I think Swift will have more users than those languages

      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.

  • »
    »
    2 months ago, # ^ |
      Vote: I like it +13 Vote: I do not like it

    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.

    • »
      »
      »
      2 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      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.

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

you can use kotlin though it's the closest thing to swift

  • »
    »
    2 months ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    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.

»
2 months ago, # |
  Vote: I like it +1 Vote: I do not like it

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.

»
2 months ago, # |
  Vote: I like it +6 Vote: I do not like it

Swiftforces :)