3 ms·
he's not saying c code is clear; he's saying that using c code can help you avoid complexity because many things you might attempt in another language are simpl
by andrewcooke 16y ago
he's not saying c code is clear; he's saying that using c code can help you avoid complexity because many things you might attempt in another language are simply too expensive.
nor is he saying (as someone else said) that you should avoid higher level constructs in other languages. its quite ok to use those, as long as you keep things simple.
simplicity does not map 1-to-1 on language features and is hard to explain because it's very context dependent. it's more "YAGNI" than "avoid yield in python".
for example, here's an example from Python i noticed just yesterday. i had some code that expanded a particular kind of data and i wanted to let the user do something with the data. so i added a callback - on each step in the expansion i pass the user the relevant chunk of data through the callback.
but how do i handle errors? i had a use-case that needed to handle errors, but they didn't fit with the callback. so my first thought was to make the callback an object and have a method to handle exceptions. but that looked complicated.
then i realised that i was passing the callback a list of values. if, instead, i passed a generator, then the exceptions, when they occurred, would be raised inside the callback! so by "using yield" i kept things simple.