Live data from Hacker News

Keep your source code SIMPLE

medium.com

31–40 of 77 posts

Re: Keep your source code SIMPLE

#31
post #3

Earlier quoted context omitted.

Can you define "over-comment"? Without a clear definition, it's just subjective opinion.

//increment i in for loop For (i=0;i++.... Var x; //define variable x X=4; //give value of 4 to x Everyone knows what that code does. The comments aren't necessary.

This is what I’m saying by over-commenting. I stated comments at the beginning of functions - what are the arguments? - what does it return - or at the beginning of class names are the wise go.

Re: Keep your source code SIMPLE

#32
post #12

Earlier quoted context omitted.

Yes, please comment! I was once on a project where commenting was prohibited presumbely because your code should be self explanatory? Give me a break.

Comments are often a code smell indicating that the code was written in a hard to understand way. On a top notch code base - the kind that almost nobody works on - they probably should be sparse and mostly unnecessary. Moreover, when a lot of people are asked to comment they write stuff like "this function does x to y" when the function is named "x_to_y". No shit sherlock comments I call them. I'd always prefer to ha…

Check out the CPython code base sometime, as an example of a top notch code base. Are the comments sparse?

Re: Keep your source code SIMPLE

#33

Earlier quoted context omitted.

Comment the why, not the what.

It's good to comment the what too if it's hard to discern what it's doing from the code. There have been a number of cases where, for instance, I had to call a bizarrely named API and do something unexpected in order to get an unintuitive outcome and in that case a "what" comment isn't such a bad idea.

Comment the intentions and motivations for behavior.

Re: Keep your source code SIMPLE

#34
post #15

Earlier quoted context omitted.

Is there a language that leans heavily towards immutable data, but steers clear of the, shall we say, dorkier side of functional programming?

This is Clojure. It's functional, but more as a side effect of focusing intently on simple, immutable, persistent data structures and their compositions. I'd strongly recommend looking into it, along with many of the presentations by its initial author Rich Hickey.

Imo no Lisp variant can claim to not be in the "dorkier" side of things ("dorkier" being read as "hard to approach" in my eyes).

I'd say Kotlin over Clojure.

Re: Keep your source code SIMPLE

#35
"Keep the story going. Sign up for an extra free read. You've completed your member preview for this month, but when you sign up for a free Medium account, you get one more story."

Sorry, can't read behind paywall.

Re: Keep your source code SIMPLE

#36
post #12

Earlier quoted context omitted.

Yes, please comment! I was once on a project where commenting was prohibited presumbely because your code should be self explanatory? Give me a break.

Comments are often a code smell indicating that the code was written in a hard to understand way. On a top notch code base - the kind that almost nobody works on - they probably should be sparse and mostly unnecessary. Moreover, when a lot of people are asked to comment they write stuff like "this function does x to y" when the function is named "x_to_y". No shit sherlock comments I call them. I'd always prefer to ha…

Comments are critical for explaining the code that isn't there. I'm skeptical about "sparse".

Re: Keep your source code SIMPLE

#37
post #12
post #2

I couldn’t agree more. Also; keep it clean . Don’t over-comment, but comment.

Yes, please comment! I was once on a project where commenting was prohibited presumbely because your code should be self explanatory? Give me a break.

Good readable code has very few comments.

Writing good readable code is hard, and you don't get it just by banning comments.

Much like how you don't lose weight by buying smaller sized clothes :)

Re: Keep your source code SIMPLE

#38
post #3
post #2

I couldn’t agree more. Also; keep it clean . Don’t over-comment, but comment.

Can you define "over-comment"? Without a clear definition, it's just subjective opinion.

Some of it is an art, and thereby subjective opinion.

Nothing wrong with that!

Re: Keep your source code SIMPLE

#39
post #12
post #2

I couldn’t agree more. Also; keep it clean . Don’t over-comment, but comment.

Yes, please comment! I was once on a project where commenting was prohibited presumbely because your code should be self explanatory? Give me a break.

I would much rather be on a project where commenting is prohibited then where it is mandatory, e.g., the senseless babbling that goes along with javadoc/doxygen/PEP-8-like comments. That is such absolute garbage. At some point it even becomes hard to spot the code in between the garbage. Yes, even with syntax highlighting....
Post reply on HN