Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Is your code Clean enough?

Name: Anonymous 2016-01-20 13:09

Hi, Everyone. I'm slowly learning Haskell and something that slows me down is how different the culture and style is from Clean Coding. (I.e., Clean Code: A Handbook of Agile Software Craftsmanship)

I'm coming from Ruby, and CC is hugely influential. E.g., Code should be self-documenting with descriptive variable and function names. Functions should be very short and each one's expressions should all be at a similar level of abstraction.

Sandy Metz's Rules are also very prominent. E.g.:

Methods can be no longer than five lines of code.
Pass no more than four parameters into a method.


But the Haskell docs and code examples in posts are pretty far from this style, e.g. I see one-letter identifiers, multiple levels of nesting, functions which are many lines long, etc.

EDIT: Cf. Elixir, where Haskel's a becomes any.

What do haskellers think of this? To me, much Haskell code is unnecessarily obfuscated.

Name: Anonymous 2016-01-20 13:10

Thanks! What do you think of this example:

(from the haskel wiki)

-- if the list is empty, the result is the initial value z;
foldr f z [] = z


Re-written in clean code style which removes the need for the comment:

foldr fun initial_val [] = initial_val

Name: Mentifex 2016-01-20 13:47

Name: Anonymous 2016-01-20 14:07

Arthur T. Murray, a.k.a. Mentifex, is a notorious kook who makes heavy use of the Internet to promote his theory of artificial intelligence (AI). His writing is characterized by illeism, name-dropping, frequent use of foreign expressions, crude ASCII diagrams, and what has been termed “obfuscatory technobabble”.

Murray claims to have received a Bachelor’s degree in Greek and Latin from the University of Washington in Seattle in 1968 [26]. He has no formal training in computer science, cognitive science, neuroscience, linguistics, nor any other field of study even tangentially related to AI or cognition. He works as a night auditor at a small Seattle hotel [3, p. 25] and is not affiliated with any university or recognized research institution; he therefore styles himself an “independent scholar”. Murray claims that his knowledge of AI comes from reading science fiction novels [41].

Murray is notorious for posting thousands of messages to Usenet promoting his AI software, book, websites, and theory. Most of these messages are massively cross-posted to off-topic newsgroups. Murray takes the mere mention of anything vaguely AI-related as an invitation to post a follow-up directing readers to his own work (e. g., [47]). He claims that people are “crying out” for repetition of his message [48].

Before he had regular access to the Internet, Murray used the US postal system to spread his ideas by mass-mailing prominent AI researchers, computing authors, and sometimes even entire university departments. He boasts that he mailed seven thousand letters in 1989 alone [37].

Murray has also been known to cause disruptions in person. In one notable example, he picketed the 2001 International Joint Conference on Artificial Intelligence [16, 29].

Name: Anonymous 2016-01-20 14:22

>>4
They forgot to mention the # perl by example comments.

>>3
Give me a pdf of your books already.

Name: Anonymous 2016-01-20 14:44

Name: Anonymous 2016-01-20 18:39

What the fuck is wrong with multiple levels of nesting? When you're iterating over a multidimensional dataset, or are dispatching over multiple sources, that's kind of a requirement.

Lexical scope is your friend, and is a whole fuckton more manageable and readable than smearing your scope around a ton of scattered functions that are only called from 1 place anyway.

Name: Anonymous 2016-01-20 21:01

>>7
You're arguing with a set of rules popular in the Ruby community and made up by a woman.

Name: Anonymous 2016-01-20 22:44

>>6
I found that funny.

Name: Cudder !cXCudderUE 2016-01-21 5:30

Methods can be no longer than five lines of code.
I really wasn't sure if this was really meant to be serious, or just a sick joke, but then I Googled it... :facepalm:

These are the things the ENTERPRISE cargo-cult is constantly raving about. These idiots got brainwashed into the shorter=better mindset, completely ignoring the fact that it adds overhead and turns the nice linear control-flow into a hairy nested spaghetti mess of fragments, making the whole program bigger. One 500-line method is better than 100 one-line methods, if only for the fact that you don't have to go jumping all over the place to figure out how it all works.

This rule would be better (and I've had to use a variation of it on some embedded systems):

Function calls can not be nested more than five deep.

Name: Anonymous 2016-01-21 6:28

Are my dubs clean enough?

Name: Anonymous 2016-01-21 7:19

>>10
What is the maximum number of lines that the shittiest hirable programmer in the world can be trusted with? 5. ENTERPRISE POLICY MAKING!

Name: Anonymous 2016-01-21 7:57

Clean Code leverages Agile Software Craftsmanship and world-class Self-Documenting Design to provide programmers worldwide with robust, scalable, modern turnkey implementations of flexible, modular, cutting edge method system of algorithmic architectures that accelerate response to theoretic and real-world code integration demands and reliably adapt to evolving software design, seamlessly and efficiently integrating and synchronizing with their existing legacy codebases, enhancing the inherent information sharing capabilities of code production teams across the enterprise while giving them a critical competitive advantage and taking them to the next level.

Name: Anonymous 2016-01-21 8:11

>>13
Anybody who can even scan their eyes across that text is dead inside. Mine uncontrollably fly away from the post after a few words.

Name: Anonymous 2016-01-21 10:57

The best way to clean code is to hit delete.

Name: Anonymous 2016-01-21 11:49

>>15
That only removes 1 character, and only if the cursor isn't at the end of the file already.

Name: Anonymous 2016-01-21 11:56

>>16
Take your autism pills

Name: Anonymous 2016-01-21 18:30

Yes. I brush it everyday and make sure to give it extra shampoo.

Name: Anonymous 2016-01-23 8:15

Clean Code vs Python
https://www.reddit.com/r/Python/comments/3jenwb/clean_code_in_python_vs_javacc/
Apparently Python is anti-clean code with indentation bloat and huge function call overhead.

Name: Anonymous 2016-01-23 8:21

>>20
That would be meaningful if anybody gave any credence to this "Clean Code" bullshit.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List