all 8 comments

sorted by: hot top controversial new old
[–] 13 points 6 months ago (1 child)

42 or 69

Depends on the function. Scientific functions should be 42 long, and for a couple of functions it should be 69. I don't make the rules here.

  • source
  • hideshow 1 child comment
  • [–] 4 points 6 months ago (4 children)

    @codeinabox A function should be short enough that you can read and understand it.Unless you're using a language in which each function declaration has a performance or memory-usage penalty. Not an issue if your language compiles to machine code or WebAssembly, but interpreted languages like JavaScript do have such a penalty. In these cases, you may need to make your functions longer to avoid that penalty.#programming

  • source
  • hideshow 4 child comments
  • [–] 5 points 6 months ago (2 children)

    @argv_minus_one @codeinabox This is utter nonsense, except you proof with serious performance measurements that- the extra function is slower- this actually matters

  • source
  • parent
  • hideshow 2 child comments
  • [–] 4 points 6 months ago (1 child)

    @HaraldKi I am admittedly a bit…emotional about not wasting memory. Growing up on a 486 with 4MB of RAM does that to you, I guess.The extra function will only be slower if the compiler/interpreter doesn't inline it, which most compilers/interpreters including JavaScript will, so it's mostly just a memory-usage issue. But I have used rather simple interpreters that don't inline functions, and one of them even came with a warning that function calls are slow!@codeinabox

  • source
  • parent
  • hideshow 1 child comment
  • [–] 2 points 6 months ago

    Sufficiently DRY. Beyond that its pedantry.

  • source