696
AL1L
2y

How programmers comment their code

Comments
  • 28
    So good. Great naming renders comments unnecessary in most cases.
  • 6
    this reminds me of comments on geeksforgeeks articles. 😂
  • 62
  • 19
    Well, to be fair, those are really fucking obvious controls.
  • 12
    In the best case code is self expanatory...
  • 12
    @Root for you, yes. On the other hand I dare you to show it to your grandparents...
  • 5
    @bigus-dickus pool water can get hot, so in context that image makes sense
  • 26
    They don't let me write Javascript anymore 😢
  • 13
    @bittersweet what torture is this...my eyes burn...it is beautiful.
  • 10
    @RememberMe

    Don't worry, I don't subject others to it, but I do love to write Javascript as if it were Haskell using recursion, currying and function composition, just as kata-exercises.
  • 7
    @bittersweet wow your code is self-obfuscating.
  • 13
    @duckWit It depends which corner of the dev world you come from. To me,
    "const f = (x, a = 1) => x ? f(x-1, x*a) : a"
    seems like a very readable factorial function because I usually think in terms of recursion. Most OOP devs would prefer a function with a "while" or "for" loop.

    One is not necessarily better or worse, just different approaches — although it's usually wise to adjust to language and team conventions.
  • 3
    @bittersweet haha great. Thats how HaskelScript was born. 😂
  • 6
    /** Returns the value */
    int getValue() {
  • 7
    @bittersweet although I like haskell, I'd still prefere a loop, just for the simple fact, that a recursive call needs some space on the stack for each itteration, while a loop doesn't
  • 6
    @Wack Yeah Javascript isn't optimal for recursion if the interpreter lacks TCO support.
  • 3
    @bittersweet haha, nah, I love it! The torture bit was from seeing such ideas being sullied by JS's syntax and awkward constructions. ML family syntax ftw.

    Though I really shouldn't complain, I do similar things in C++ and the syntactic torture is even worse there, heh.
  • 6
    @RememberMe I really like doing things you're not supposed to do. I've been working on a pure bash MVC with netcat webserver and awk templating engine, including middleware layers and a half finished database abstraction layer.
  • 4
    @bittersweet oh wow, that's extreme. Seriously though, you learn a lot from doing that kind of stuff.

    I have a home networking setup (i.e. the stuff that connects two laptops and a desktop together at my place) using a self made Arduino based "router", my own protocol, and (a very shitty and slow) userland sockets implementation. It actually works, to my great surprise.
  • 5
    Rule of thumb to have comments in code

    Instead of what you are doing, write why you are doing!

    Anyone can go through code figure out what you are doing, but no one can figure out why you are doing it.
  • 1
    Lol true
  • 1
    @duckWit In cases where it is not it simply means that the names chosen are not good enough. Comments should sometimes be on interfaces and classes which other people might use like libraries. Making a comment on a function should mean that you failed to convey meaning through normal code. :)
  • 1
    @arekxv I agree on all counts.
  • 3
    // Import stuff
    import stuff from 'stuff';
  • 2
    xId - id of x
    xAddress - Adress of x

    I don't want to do it, but the yellow warning from IntelliJ tells me to do it and I'm to lazy to turn it off
  • -1
    best blog and site <a href="https://yallacleaning.com/cleaning-...">cleaning company in dubai</a>
  • -1
    [url=https://yallacleaning.com/cleaning-... company in dubai[/url]
  • 0
    @bittersweet I still can't get full understanding of your code example. 😅
Add Comment