{"success":true,"data":{"title":"New Job, New Programming Language","slug":"new-job-new-programming-language","excerpt":"Practical advice on switching programming languages mid-career, drawn from ten years of PHP and a move into Ruby. Covers approaching the job hunt honestly, how core engineering principles translate across languages — comparing PHP interfaces with Ruby duck typing — making the most of code reviews as a learning tool, and why comments matter more than ever when you're new to a codebase.","has_code_sample":true,"published_at":"2019-11-01T11:20:00.000Z","content":"\u003cp\u003eFor the last ten years, I’ve used PHP as my language of choice but in July I started a job where I’d be learning a new programming language — Ruby. It’s been a wild ride! I’ve learnt so much and on the way, I’ve cobbled together a few tips on how to make learning a new programming language at a new job as smooth as possible.\u003c/p\u003e\n\n\u003ch2 id=\"the-job-hunt\"\u003eThe Job Hunt\u003c/h2\u003e\n\u003cp\u003eIt’s common not to have all the skills a modern tech job asks for, but if you think the job fits and you’re willing to learn then why not take a shot? Good companies will be able to look beyond what skills you may be lacking and see the enthusiasm you have. This is something that can’t be taught and is always a brilliant asset to have on a team.\u003c/p\u003e\n\n\u003cp\u003eThe most important thing is to be upfront. Many experienced developers are polyglots so knowing you need to learn their language won’t be offputting. Knowing early on in the process will help tailor the interview and onboarding processes.\u003c/p\u003e\n\n\u003cp\u003eIn interviews, it’s important to be positive so acknowledge you have things to learn but highlight examples from your experience where you’ve had to adapt to new techniques or pick up new skills. You may already know a second language; maybe you’ve taught yourself something that could benefit the team, like \u003ca href=\"/2019/01/webpack-and-wordpress/\"\u003eWebpack\u003c/a\u003e 😉?\u003c/p\u003e\n\n\u003ch2 id=\"good-code-is-good-code\"\u003eGood Code is Good Code\u003c/h2\u003e\n\u003cp\u003eThe principles of software engineering are language agnostic, the difference between languages is in how you apply them. Let’s take The \u003ca href=\"https://en.wikipedia.org/wiki/Liskov_substitution_principle\"\u003eSubstitution Principle\u003c/a\u003e as an example.\u003c/p\u003e\n\n\u003cp\u003ePHP has interfaces that allow you to define how an object is used, but not how it’s implemented. Using Type Hinting and Dependency Injection you can pass instances of an interface to a class which can then use them. This class is not concerned with how its dependent is implemented as long as it conforms to the interface; the dependent class can then be substituted with a different implementation of the interface without having to modify its usage of it.\u003c/p\u003e\n\n\u003cdiv class=\"language-php highlighter-rouge\"\u003e\u003cdiv class=\"highlight\"\u003e\u003cpre class=\"highlight\"\u003e\u003ccode\u003e\u003cspan class=\"cp\"\u003e\u0026lt;?php\u003c/span\u003e\n\n\u003cspan class=\"kd\"\u003einterface\u003c/span\u003e \u003cspan class=\"nc\"\u003eRacingCar\u003c/span\u003e\n\u003cspan class=\"p\"\u003e{\u003c/span\u003e\n    \u003cspan class=\"k\"\u003epublic\u003c/span\u003e \u003cspan class=\"k\"\u003efunction\u003c/span\u003e \u003cspan class=\"n\"\u003eignition\u003c/span\u003e\u003cspan class=\"p\"\u003e();\u003c/span\u003e\n\u003cspan class=\"p\"\u003e}\u003c/span\u003e\n\n\u003cspan class=\"kd\"\u003eclass\u003c/span\u003e \u003cspan class=\"nc\"\u003eFerrari\u003c/span\u003e \u003cspan class=\"kd\"\u003eimplements\u003c/span\u003e \u003cspan class=\"nc\"\u003eRacingCar\u003c/span\u003e\n\u003cspan class=\"p\"\u003e{\u003c/span\u003e\n    \u003cspan class=\"k\"\u003epublic\u003c/span\u003e \u003cspan class=\"k\"\u003efunction\u003c/span\u003e \u003cspan class=\"n\"\u003eignition\u003c/span\u003e\u003cspan class=\"p\"\u003e()\u003c/span\u003e\n    \u003cspan class=\"p\"\u003e{\u003c/span\u003e\n        \u003cspan class=\"c1\"\u003e// Start the Ferrari.\u003c/span\u003e\n    \u003cspan class=\"p\"\u003e}\u003c/span\u003e\n\u003cspan class=\"p\"\u003e}\u003c/span\u003e\n\n\u003cspan class=\"kd\"\u003eclass\u003c/span\u003e \u003cspan class=\"nc\"\u003eMcLaren\u003c/span\u003e \u003cspan class=\"kd\"\u003eimplements\u003c/span\u003e \u003cspan class=\"nc\"\u003eRacingCar\u003c/span\u003e\n\u003cspan class=\"p\"\u003e{\u003c/span\u003e\n    \u003cspan class=\"k\"\u003epublic\u003c/span\u003e \u003cspan class=\"k\"\u003efunction\u003c/span\u003e \u003cspan class=\"n\"\u003eignition\u003c/span\u003e\u003cspan class=\"p\"\u003e()\u003c/span\u003e\n    \u003cspan class=\"p\"\u003e{\u003c/span\u003e\n        \u003cspan class=\"c1\"\u003e// Start the McLaren.\u003c/span\u003e\n    \u003cspan class=\"p\"\u003e}\u003c/span\u003e\n\u003cspan class=\"p\"\u003e}\u003c/span\u003e\n\n\u003cspan class=\"kd\"\u003eclass\u003c/span\u003e \u003cspan class=\"nc\"\u003eDriver\u003c/span\u003e\n\u003cspan class=\"p\"\u003e{\u003c/span\u003e\n    \u003cspan class=\"k\"\u003epublic\u003c/span\u003e \u003cspan class=\"k\"\u003efunction\u003c/span\u003e \u003cspan class=\"n\"\u003e__construct\u003c/span\u003e\u003cspan class=\"p\"\u003e(\u003c/span\u003e\u003cspan class=\"kt\"\u003eRacingCar\u003c/span\u003e \u003cspan class=\"nv\"\u003e$car\u003c/span\u003e\u003cspan class=\"p\"\u003e)\u003c/span\u003e\n    \u003cspan class=\"p\"\u003e{\u003c/span\u003e\n        \u003cspan class=\"nv\"\u003e$this\u003c/span\u003e\u003cspan class=\"o\"\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=\"n\"\u003ecar\u003c/span\u003e \u003cspan class=\"o\"\u003e=\u003c/span\u003e \u003cspan class=\"nv\"\u003e$car\u003c/span\u003e\u003cspan class=\"p\"\u003e;\u003c/span\u003e\n    \u003cspan class=\"p\"\u003e}\u003c/span\u003e\n\n    \u003cspan class=\"k\"\u003epublic\u003c/span\u003e \u003cspan class=\"k\"\u003efunction\u003c/span\u003e \u003cspan class=\"n\"\u003estart\u003c/span\u003e\u003cspan class=\"p\"\u003e()\u003c/span\u003e\n    \u003cspan class=\"p\"\u003e{\u003c/span\u003e\n        \u003cspan class=\"nv\"\u003e$this\u003c/span\u003e\u003cspan class=\"o\"\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=\"n\"\u003ecar\u003c/span\u003e\u003cspan class=\"o\"\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=\"nf\"\u003eignition\u003c/span\u003e\u003cspan class=\"p\"\u003e();\u003c/span\u003e\n        \u003cspan class=\"c1\"\u003e// ...\u003c/span\u003e\n    \u003cspan class=\"p\"\u003e}\u003c/span\u003e\n\u003cspan class=\"p\"\u003e}\u003c/span\u003e\n\n\u003cspan class=\"nv\"\u003e$cars\u003c/span\u003e \u003cspan class=\"o\"\u003e=\u003c/span\u003e \u003cspan class=\"p\"\u003e[\u003c/span\u003e\u003cspan class=\"s1\"\u003e'McLaren'\u003c/span\u003e\u003cspan class=\"p\"\u003e,\u003c/span\u003e \u003cspan class=\"s1\"\u003e'Ferrari'\u003c/span\u003e\u003cspan class=\"p\"\u003e];\u003c/span\u003e\n\u003cspan class=\"nv\"\u003e$car\u003c/span\u003e \u003cspan class=\"o\"\u003e=\u003c/span\u003e \u003cspan class=\"nv\"\u003e$cars\u003c/span\u003e\u003cspan class=\"p\"\u003e[\u003c/span\u003e\u003cspan class=\"nb\"\u003emt_rand\u003c/span\u003e\u003cspan class=\"p\"\u003e(\u003c/span\u003e\u003cspan class=\"mi\"\u003e0\u003c/span\u003e\u003cspan class=\"p\"\u003e,\u003c/span\u003e \u003cspan class=\"nb\"\u003ecount\u003c/span\u003e\u003cspan class=\"p\"\u003e(\u003c/span\u003e\u003cspan class=\"nv\"\u003e$cars\u003c/span\u003e\u003cspan class=\"p\"\u003e)\u003c/span\u003e \u003cspan class=\"o\"\u003e-\u003c/span\u003e \u003cspan class=\"mi\"\u003e1\u003c/span\u003e\u003cspan class=\"p\"\u003e)];\u003c/span\u003e\n\u003cspan class=\"nv\"\u003e$driver\u003c/span\u003e \u003cspan class=\"o\"\u003e=\u003c/span\u003e \u003cspan class=\"k\"\u003enew\u003c/span\u003e \u003cspan class=\"nc\"\u003eDriver\u003c/span\u003e\u003cspan class=\"p\"\u003e(\u003c/span\u003e\u003cspan class=\"k\"\u003enew\u003c/span\u003e \u003cspan class=\"nv\"\u003e$car\u003c/span\u003e\u003cspan class=\"p\"\u003e);\u003c/span\u003e\n\u003cspan class=\"nv\"\u003e$driver\u003c/span\u003e\u003cspan class=\"o\"\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=\"nf\"\u003estart\u003c/span\u003e\u003cspan class=\"p\"\u003e();\u003c/span\u003e\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003c/div\u003e\n\n\u003cp\u003eIn the example above the \u003ccode\u003eDriver\u003c/code\u003e object does not care what car it receives, it is only concerned that it implements the \u003ccode\u003eRacingCar\u003c/code\u003e interface. Ruby doesn’t have interfaces, it uses Duck Typing. Duck Typing states that “if it walks like a duck and it quacks like a duck, then it must be a duck” — if the class being used behaves as expected then it can be assumed to be what we want.\u003c/p\u003e\n\n\u003cdiv class=\"language-ruby highlighter-rouge\"\u003e\u003cdiv class=\"highlight\"\u003e\u003cpre class=\"highlight\"\u003e\u003ccode\u003e\u003cspan class=\"k\"\u003eclass\u003c/span\u003e \u003cspan class=\"nc\"\u003eFerrari\u003c/span\u003e\n  \u003cspan class=\"k\"\u003edef\u003c/span\u003e \u003cspan class=\"nf\"\u003eignition\u003c/span\u003e\u003cspan class=\"p\"\u003e;\u003c/span\u003e \u003cspan class=\"k\"\u003eend\u003c/span\u003e\n\u003cspan class=\"k\"\u003eend\u003c/span\u003e\n\n\u003cspan class=\"k\"\u003eclass\u003c/span\u003e \u003cspan class=\"nc\"\u003eMcLaren\u003c/span\u003e\n  \u003cspan class=\"k\"\u003edef\u003c/span\u003e \u003cspan class=\"nf\"\u003eignition\u003c/span\u003e\u003cspan class=\"p\"\u003e;\u003c/span\u003e \u003cspan class=\"k\"\u003eend\u003c/span\u003e\n\u003cspan class=\"k\"\u003eend\u003c/span\u003e\n\n\u003cspan class=\"k\"\u003eclass\u003c/span\u003e \u003cspan class=\"nc\"\u003ePolestar\u003c/span\u003e\n  \u003cspan class=\"k\"\u003edef\u003c/span\u003e \u003cspan class=\"nf\"\u003emove_electrons\u003c/span\u003e\u003cspan class=\"p\"\u003e;\u003c/span\u003e \u003cspan class=\"k\"\u003eend\u003c/span\u003e\n\u003cspan class=\"k\"\u003eend\u003c/span\u003e\n\n\u003cspan class=\"k\"\u003eclass\u003c/span\u003e \u003cspan class=\"nc\"\u003eDriver\u003c/span\u003e\n  \u003cspan class=\"k\"\u003edef\u003c/span\u003e \u003cspan class=\"nf\"\u003einitialize\u003c/span\u003e\u003cspan class=\"p\"\u003e(\u003c/span\u003e\u003cspan class=\"n\"\u003ecar\u003c/span\u003e\u003cspan class=\"p\"\u003e)\u003c/span\u003e\n    \u003cspan class=\"vi\"\u003e@car\u003c/span\u003e \u003cspan class=\"o\"\u003e=\u003c/span\u003e \u003cspan class=\"n\"\u003ecar\u003c/span\u003e\n  \u003cspan class=\"k\"\u003eend\u003c/span\u003e\n\n  \u003cspan class=\"k\"\u003edef\u003c/span\u003e \u003cspan class=\"nf\"\u003ego\u003c/span\u003e\n    \u003cspan class=\"vi\"\u003e@car\u003c/span\u003e\u003cspan class=\"p\"\u003e.\u003c/span\u003e\u003cspan class=\"nf\"\u003eignition\u003c/span\u003e\n  \u003cspan class=\"k\"\u003eend\u003c/span\u003e\n\u003cspan class=\"k\"\u003eend\u003c/span\u003e\n\n\u003cspan class=\"c1\"\u003e# Ducks.\u003c/span\u003e\n\u003cspan class=\"n\"\u003eferrari_driver\u003c/span\u003e \u003cspan class=\"o\"\u003e=\u003c/span\u003e \u003cspan class=\"no\"\u003eDriver\u003c/span\u003e\u003cspan class=\"p\"\u003e.\u003c/span\u003e\u003cspan class=\"nf\"\u003enew\u003c/span\u003e\u003cspan class=\"p\"\u003e(\u003c/span\u003e\u003cspan class=\"no\"\u003eFerrari\u003c/span\u003e\u003cspan class=\"p\"\u003e.\u003c/span\u003e\u003cspan class=\"nf\"\u003enew\u003c/span\u003e\u003cspan class=\"p\"\u003e)\u003c/span\u003e\n\u003cspan class=\"n\"\u003emclaren_driver\u003c/span\u003e \u003cspan class=\"o\"\u003e=\u003c/span\u003e \u003cspan class=\"no\"\u003eDriver\u003c/span\u003e\u003cspan class=\"p\"\u003e.\u003c/span\u003e\u003cspan class=\"nf\"\u003enew\u003c/span\u003e\u003cspan class=\"p\"\u003e(\u003c/span\u003e\u003cspan class=\"no\"\u003eMcLaren\u003c/span\u003e\u003cspan class=\"p\"\u003e.\u003c/span\u003e\u003cspan class=\"nf\"\u003enew\u003c/span\u003e\u003cspan class=\"p\"\u003e)\u003c/span\u003e\n\n\u003cspan class=\"n\"\u003eferrari_driver\u003c/span\u003e\u003cspan class=\"p\"\u003e.\u003c/span\u003e\u003cspan class=\"nf\"\u003ego\u003c/span\u003e\n\u003cspan class=\"n\"\u003emclaren_driver\u003c/span\u003e\u003cspan class=\"p\"\u003e.\u003c/span\u003e\u003cspan class=\"nf\"\u003ego\u003c/span\u003e\n\n\u003cspan class=\"c1\"\u003e# Not a Duck.\u003c/span\u003e\n\u003cspan class=\"n\"\u003epolestar_driver\u003c/span\u003e \u003cspan class=\"o\"\u003e=\u003c/span\u003e \u003cspan class=\"no\"\u003eDriver\u003c/span\u003e\u003cspan class=\"p\"\u003e.\u003c/span\u003e\u003cspan class=\"nf\"\u003enew\u003c/span\u003e\u003cspan class=\"p\"\u003e(\u003c/span\u003e\u003cspan class=\"no\"\u003ePolestar\u003c/span\u003e\u003cspan class=\"p\"\u003e.\u003c/span\u003e\u003cspan class=\"nf\"\u003enew\u003c/span\u003e\u003cspan class=\"p\"\u003e)\u003c/span\u003e\n\u003cspan class=\"n\"\u003epolestar_driver\u003c/span\u003e\u003cspan class=\"p\"\u003e.\u003c/span\u003e\u003cspan class=\"nf\"\u003ego\u003c/span\u003e \u003cspan class=\"c1\"\u003e# Erm...\u003c/span\u003e\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003c/div\u003e\n\n\u003cp\u003eIn the Ruby code above an error will be thrown when the Tesla driver tries to start their non-existent ignition.\u003c/p\u003e\n\n\u003ch2 id=\"️-code-reviews-️\"\u003e❤️ Code Reviews ❤️\u003c/h2\u003e\n\u003cp\u003eI love code reviews, they’re so helpful for people learning a new programming language. I’m super lucky to have patient colleagues who will not only highlight where something could be improved but will also take the time to explain why. Deep understanding is important to them so they’re super happy to help me work on that too. Look for, and encourage, an environment where engineers seek to improve themselves and each other.\u003c/p\u003e\n\n\u003cp\u003eBe humble when receiving feedback. If you react well to it then the quality and usefulness of subsequent reviews will be even better which will help you learn and be a more useful contributor.\u003c/p\u003e\n\n\u003cp\u003eComing from the other side, give good code reviews and use them as a way to further your knowledge. Ask, or figure out for yourself, why things have been written in the way they have. See a function call you don’t know? Check out the docs. Use reviews to explore existing codebases and discover how things fit together. Give considered comments, and don’t just comment on things you think could be done differently - highlight code you think is great!\u003c/p\u003e\n\n\u003ch2 id=\"dont-neglect-comments\"\u003eDon’t Neglect Comments\u003c/h2\u003e\n\u003cp\u003eSelf-documenting code is important. I should be able to read it and understand what it does. Self-documentation won’t tell me why it does whatever it does in the way it does it. Comments help give code context. I’m not saying every line needs a note, far from it; if commenting is required too regularly it’s a surefire sign that something is amiss. That said, comments are super useful when making your way through a codebase as a newbie.\u003c/p\u003e\n\n\u003ch2 id=\"celebrate\"\u003eCelebrate!\u003c/h2\u003e\n\u003cp\u003eLearning a new language is hard. You will make silly mistakes and you will get things wrong but don’t beat yourself up about it. Getting things wrong is not a bad thing, it’s how people learn! Always take time to look back and see how far you’ve come.\u003c/p\u003e\n","tags":["PHP","Ruby","Ruby on Rails"]}}