My GSoC Experience

Hi everyone! Last year I was a GSoC student here at Swift. I worked on Localization of Compiler DIagnostic messages. Feel free to check my last project here.

I was getting a lot of messages about my GSoC experience lately, and I wanted to write a blog about my experience, what I did wrong, and what I wish I knew before starting.

My experience

Last year, when I found out that Swift is going to be at GSoC, I decided to apply... it's important to note that the main reasons I applied at Swift were because I wanted to make connections with people working at Apple, and get more involved with the Swift community outside of my country. That means I didn't have any experience with compiler development nor C++ (other than some C++ for competitive programming which is far from C++ written here, tbh).

The experience that I had was really good, I learned a lot every single day. For example, I learned a lot about:

  • Developing my critical thinking skills, and taking my time to think about my implementation before writing code.
  • Git commands... like rebase, and cherry-picking.
  • As a beginner, a lot of times I was almost always stuck in the tutorial trap. But GSoC really helped me getting out of it, by learning how to read documentations, other PRs, and tests to understand and/or implement something.
  • One of the best learning experiences that I had was with every PR review. I remember that one of the PR reviews helped me a lot to understand OOP concepts.
  • I also learned how to navigate a huge file of 5000 lines of code or more and not get intimidated by it.
  • Finally, I made some really good connections and got to know really great people. :slight_smile:

However, the experience was great, it was stressful mainly because I was stressing myself out and not enjoying my time. For example, I was starting my GSoC with the mentality of "I must do a great job and hopefully, impress my mentor so I can ask him if he can refer me to get a job at Apple". Because of that, I was almost always in a rush and want to finish quickly so I can prove myself. Of course, I wasn't able to finish quickly because everything was new to me so I kept stressing myself out more, and that didn't translate very well. As:

  1. I didn't put much time into thinking of my implementation or design details. I just wanted to code.
  2. That made me take more time to fix issues with my code that made me even more behind schedule.
  3. Finally (starting from wanting to finish GSoC with doing a great job), at the end of GSoC I was just hoping to pass the evaluation!

As a new compiler contributor, one of the biggest hurdles wasn't getting to know the basics of how compilers work. There were and still are a lot of resources online. I did however struggle with C++ concepts. The problem was that I thought I knew C++ because I did competitive programming, implement some algorithms, and data structures. Then I came to realize that nobody actually knows C++.

I struggled a bit to understand how memory management work in C++ for example:

  1. The idea of strong referencing. I.e. a lot of objects were getting released before I expect them to.
  2. Getting to understand that C++ works in scopes, so after each scope, the values in it will be released from memory.
  3. The difference between returning a reference or a copy from a function.

Finally, the important takeaways from this IMO is that:

  1. Focus on what you have, don't overthink what will happen after GSoC.
  2. Enjoy your time learning and contributing to Swift. It's all about your learning journey IMHO.
  3. If your mentor told you that you should take your time with something and not rush it... you probably should. :slight_smile:
  4. Don't be afraid to ask questions. For me, I just wanted to try to know everything on my own-- because I thought that way I'll be leaving a good impression. It's important to note that it's impossible to know everything on your own and you have to get used to the idea of asking questions and asking for help.

My workflow

  1. For contributing, I was building with ninja and using Xcode as an editor. That way I was able to do definition jumps which is extremely important IMO.
$ .utils/build-script --skip-build-benchmarks  // To build using Ninja.
$ .utils/build-script -x --skip-build // To only generate the Xcode project.
  1. I sometimes needed a playground-like project in which I can test and try various LLVM APIs. So, I created a C++ Xcode command line project for this.
  • Firstly, you will need to install LLVM via homebrew.
$ brew install llvm
  • Secondly, add /usr/local/opt/llvm/bin/ to your $PATH environment variable.
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
  • Finally, create an Xcode project to use LLVM APIs. You will need to change the C++ target's other linker flags and add LLVM's lib to its search paths.
-lz -ltermcap -lc++ -lLLVMCore -lLLVMSupport -lLLVMTransformUtils -lLLVMBitReader -lLLVMAnalysis -lLLVMDemangle // Other Linker Flags

/usr/local/Cellar/llvm/10.0.1_2/include // Header Search Paths
/usr/local/Cellar/llvm/10.0.1_2/lib // Liberary Search Paths

Conclusion

Overall, I really encourage anyone who is interested in applying to Swift to apply! It's the best learning experience that I have ever had thanks to my mentor @xedin and the Swift community. It really prepared me well for the job that I currently have. I'm so grateful for everything.

If anyone has any questions or comments, please feel free to write them down. :slight_smile:

25 Likes

Thanks for the great writeup Hassan :slight_smile:

This definitely can be useful to first time students participating in GSoC this year.

Just wanted to second everything you wrote here, but from a mentor's perspective :+1:

The most important thing is communication: let your mentor know if you're stuck or confused or unsure about anything. Don't be shy to ask questions or double check if you understood feedback correctly. The mentors and wider community are here to you help and all are great, helpful, nice people willing to help :slight_smile:

Other things:

  • It is useful to set up a weekly or bi-weekly call / sync-up just to also bring some human element to the interaction -- it is easy to lost that if only communicating with text chat or email. Maybe you misread a short reply as something harsh, but actually the other person just was on a phone and couldn't reply with a longer message etc, having some facetime during the project is useful to connect as a "coworker" basically :wink:
  • And yes, while GSoC is a great way to get in touch with Apple engineers and the Swift ecosystem, don't please don't go into it assuming that it will end with a job offer. GSoC isn't a sneaky recruiting plan, although yes of course it helps if you at some later point apply for a job it is a good positive signal that you participated in it :slight_smile:

Thanks again and best of luck to this year's projects!

5 Likes

Hey Hassan, thank you so much for writing this up, it really is very helpful!!

2 Likes

Thank you so much! I'm glad I can help. Best of luck!

1 Like

Thanks for sharing your experience. It's really helpful to me. I'll keep these in my mind.

2 Likes

This is a congenital problem among developers. Every dev in the known universe believes that they know almost everything and the things they don't know they can figure out in a reasonable period of time.

let timeToAsk = [.hour, .day, .week, .month, .year, .yourWholeLife].randomElement()

The time to ask may vary depending on circumstances but shorter is better, especially when there is someone that knows the answer.

Terms of Service

Privacy Policy

Cookie Policy