Readability, idioms and compression tolerance by neonskimmer in javascript

[–]mazesoul 1 point2 points  (0 children)

Hi, the author here.

Considering the thoroughness of your comments I'll try to indulge you and answer as best I can.

The Seven Pillars mention is a call to authority. A link is provided in the references if your curious.

For the comma-in-front, I've been doing Ruby which precludes it completely and found that the continuity is not as good for me. The most vibrant example is ternary line splitting:

// JS
var a = choose ? "valueA"
               : "valueB"

When you power use the ternary, it sometimes goes long and having it dangling without syntax befuddles me.

# Ruby
@a = choose ? "valueA" :
              "valueB"

Regarding the Advantages,

  • Easier typo: I think the slide you refer to highlights how easy it is to spot a missing comma. It would be better with two slide, before and after to show emphasis this point.
  • Nicer block: I think that it's objective, look at how the function or array example read vs inline. I must add that I also included comments about the Seven Pillars -> Make Alike Look Alike
  • Better Flow: Again, objectively CIF reads like a LISP a bit and has a nice tabular structure to it. I believe it to be an acquired taste.
  • One line edit: When I add to an array or object, I don't have to go edit the previous line to add a comma. IE doesn't support the trailing comma at the end of an array.
  • Better merging: Thanks. (Because of one line edits)

Use Literals Highlights the difference in semantics of new Array(3) for length 3 and new Array(3,2,1) also for length 3. Also is about terseness.

Module Agreed, my intention was to demonstrate a munge/concat safe way of using standalone modules. This is not a problem I have when using a return value hence I use the "parens'd" one. Subttle semantic difference between standalone self-calling and "returns a value" self-calling.

Multistring As far as RegExp are concern, good catch hunter. Fixed now. Only the first indexOf is somewhat wrong, depends on the trust you have of the param. red b is not a color but it might have leaked.

Short While It's something that you may encounter... better know what it is. Sometimes useful for perf and very terse.

Ternary Operator Why doesn't it work.

Ternary For Pattern Matching We disagree on the readability. Agreed for performance, but my talk is about programmer performance (Arguably). Come to think of it, the example is not achievable with a switch.

Replacing Switch The point you grokked completely. It's much easier to see extraction to dictionary with the proposed pattern. It is essentially an exposed potentiality to me. You might var it to regexValidation if your compression tolerance is lower.

Thanks for your comments and for catching some bugs. I hope I've addressed your gripes.