Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@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. -
@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. -
Wack63116y@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
-
@Wack Yeah Javascript isn't optimal for recursion if the interpreter lacks TCO support.
-
@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. -
@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.
-
@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. -
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. -
arekxv10546y@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. :)
-
You are not the only programmer who writes weird comments. “40 Ridiculous Comments in Source Code that People Actually Wrote” is published by Brunette girl ...
-
emmausa0339dI believe that with the information you share, it will bring a lot of value to the readers and I hope that they will absorb the good and useful things.
-
drewbinsky1213d@emmausa The text says "me commenting my code in engr102" which refers to an introductory engineering course.
https://retrobowlonline.io -
Suika game is a fruit merging puzzle game that is very popular today. https://suikagame.io
How programmers comment their code
joke/meme