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.
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.
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:
- I didn't put much time into thinking of my implementation or design details. I just wanted to code.
- That made me take more time to fix issues with my code that made me even more behind schedule.
- 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:
- The idea of strong referencing. I.e. a lot of objects were getting released before I expect them to.
- Getting to understand that C++ works in scopes, so after each scope, the values in it will be released from memory.
- The difference between returning a reference or a copy from a function.
Finally, the important takeaways from this IMO is that:
- Focus on what you have, don't overthink what will happen after GSoC.
- Enjoy your time learning and contributing to Swift. It's all about your learning journey IMHO.
- If your mentor told you that you should take your time with something and not rush it... you probably should.
- 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.
- For contributing, I was building with
ninjaand 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.
- 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
- If you don't want to do the project setup yourself, you can clone it from here as I already uploaded it to my GitHub.
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.