Tricky Code
Learn about the trade-off between writing code that’s concise and tricky versus code that’s longer but more comprehensive.
We'll cover the following
Short vs. explicit
As a general rule, explicit code should be preferred over using ‘tricks’ to make code extremely short. There is a trade-off, of course. Short, tricky code is less code, but the trade-off is that it may be more difficult to understand—both for others and for ourselves as code authors, when we revisit it later. Finding the optimal trade-off between concise and clear is something we should be thinking about and something that will be different for everyone.
If you want to see some examples of ridiculously ‘tricky’ code, there is a competition called ‘The International Obfuscated C Code Contest.’ Here is an example, from the 2011 IOCCC Competition, the entry called eastman by Peter Eastman:
Create a free account to access the full course.
Continue your learning journey with a 14-day free trial.
By signing up, you agree to Educative's Terms of Service and Privacy Policy