Tim talked about arrow functions in JavaScript, and how “this” works with arrow functions. The behaviour of “this” differs between ES6 arrow functions, and traditional ES5 and before JS functions.
He suggested some rules of thumb:
- Don’t use arrow functions as methods in object literals, because they do not pick up the scope from the object literal that you might expect
- Don’t use arrow functions as methods in classes – it does work, but it’s more verbose than using the concise class method syntax
- Do use arrow functions as function parameters – e.g. arr.map(el => this.doSomething(el)) is much clearer than using bind or assigning this to another variable outside the method
- Be careful using “this” with an arrow function if you’re using JQuery – because JQuery reassigns “this”
- Don’t use them in lifecycle functions in Vue – Vue reassigns “this” instead
We also talked about lambdas in TypeScript and in other languages.
Then, Ed talked about the past and future of programming, based on a talk he’d recently attended by Uncle Bob. He talked about the history of programming, using mercury delay lines for memory, and how the profile of what a “programmer” is has changed over time. Half of programmers have less than five years experience – so passing information on is harder than it used to be, and understanding the importance of disciplines such as TDD is less common. Uncle Bob thinks that a combination of lack of experience, and that programmers are managing increasingly important systems, means that there will be a disaster created by poor software in the near future. Uncle Bob suggests that more attention towards craftsmanship will help prevent this – the alternative being greater regulation of programmers.
We expressed many strong opinions on these topics.