Personal blog written from scratch using Node.js, Bootstrap, and MySQL. https://jrtechs.net
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
11 KiB

  1. Is that English?
  2. ```
  3. private boolean canCompressBlock(Coordinate start, int size){
  4. return size == (int)Arrays.stream(this.rawImage, start.getRow(), start.getRow() + size)
  5. .filter(r-> size == (int)Arrays.stream(r, start.getCol(), start.getCol() + size)
  6. .filter(c-> c == this.rawImage[start.getRow()][start.getCol()])
  7. .count()).count();
  8. }
  9. ```
  10. After 30 minutes of brain boiling work, I finally finished crafting the most
  11. beautiful lambda statement in Java. What could have simply been done in two
  12. nested for loops, I decided to tackle the problem with the infamous lambda
  13. statement-- feared by most programmers. Lambda statements by no stretch makes
  14. code any easier to read since the same tasks can be accomplished through using
  15. simpler and more recognizable syntax. Yet I decided to utilize this excessive
  16. lambda statement. After much contemplation, I realized that I was only using
  17. lambda statements due to the fact that people inside of a field typically try to
  18. write to impress their peers. This code chunk is clearly a sophisticated use of
  19. functional programming and will likely impress people inside the computer
  20. science community; however, 95% of my computer science class would not
  21. understand a single word of this statement. This poses a dilemma to newer
  22. programmers which may have difficulty reading this “sophisticated code”. After
  23. years of helping students learn to program in my high school, I know that
  24. students struggle with making their own code legible. Their code often lacks
  25. sophistication and clarity. However, at the same time many of my college
  26. professors which are embedded in the field of computer science often write code
  27. that is too sophisticated and obscure for anybody to easily understand. This got
  28. me thinking, how can we teach students to programming in a way that yields
  29. legible code for everybody in the computer science field? I turned towards
  30. English. It turns out that programming can take a few pointers from English to
  31. improve its clarity. The same skills used to teach writing can be applied when
  32. teaching students to program because excellent code and writing contains thought
  33. through structure, clear phrasing and readability.
  34. The role that composition has in programming is disputed. There are people that
  35. gravitate towards programming in college because it is math and science
  36. intensive. Traditionally, programming has been viewed solely as a science. Some
  37. people may argue that composition does not play an influential role in
  38. programming. Computers are rocks that we tricked into manipulating data for us.
  39. However, language is inescapable and finds a way to seep into every facet of our
  40. lives. Once we recognize the similarities that programming and English
  41. composition have, we can move towards writing more comprehensible code. If you
  42. ignore the parallels between writing and coding, you are disconnected from
  43. relationships that can further enhance your code. Tom Lynch concluded in his
  44. article “Letters to the Machine: Why Computer Programming Belongs in the English
  45. Classroom”, “If English class is where our children already learn how to
  46. critically engage with language, adding computational languages is a natural
  47. complement”(96). The same skills that we have been developing for hundreds of
  48. years to teach English can also be applied when teaching programming.
  49. Structure is the first thing that can make or break a writing assignment or an
  50. extensive programming project. There is nothing more cringe inducing than
  51. sitting down to read an essay only to quickly realize that is just all heaped
  52. into one massive body paragraph. The same is true with programming, students try
  53. to jam all their code into a single method like an overpacked suitcase.
  54. Typically teachers try to prevent the slaughter of an essay by giving students a
  55. graphical organizer to fill out before the pens strike paper. The most notable
  56. essay organizers represent the introduction as an upside-down triangle and body
  57. paragraphs as rectangles. The triangles helps the students visualize the
  58. specificity of details and the partitioning forces the separation of ideas into
  59. paragraphs. It turns out that this technique also yields success in teaching
  60. students structure in computer science. In Vincent’s master thesis he noted
  61. “Results indicated that when students went on to their second level programming
  62. course, the students who were provided templates wrote better code. The code
  63. they wrote was more modular, used more effective parameter passing, and was
  64. better documented”(63). Computer science students are provided with “skeleton
  65. code” where the classes and method headers are provided, but, the students have
  66. to implement the methods. This teaches students to make both methods and classes
  67. homogeneous. In other words, functions should perform one task and should be
  68. under 30 lines long. Functions are a lot like sentences in English where they
  69. should convey a single message. Classes comprise both variables and functions
  70. and should only express one idea -- a lot like a paragraph. You might be
  71. wondering why students struggle with structure in writing when they are provided
  72. ample templates by their teachers. In his essay “Pay Attention to the Man Behind
  73. the Curtain: The Importance of Identity in Academic Writing” Williams states
  74. that “Many students are taught that using the five-paragraph essay form with any
  75. semblance of identity removed is the core of academic writing and will allow
  76. them to march triumphantly through the writing assignments of one class after
  77. another”(Williams 711). The truth is, writing and programming does not always
  78. follow strict structural guidelines. Just like always writing five paragraph
  79. essays is not always the optimal solution for essays, templates also fail in
  80. programming. As much as we love to provide students with nifty templates to
  81. follow, there will come a day when students have to think outside of the box and
  82. formulate their own structure. Programming students need more exercise where
  83. they learn to structure their code into methods and classes. A good example of
  84. such an exercise would have students separate a cluttered chunk of code into
  85. methods and classes. I am not suggesting that teachers should not use templates
  86. to teach structure to students; however, I believe that the templates used
  87. should not be stressed as the only or best solution.
  88. Both concise composition and programming uses clear diction. It is frustrating
  89. when you read an essay and it does not register because the concepts were
  90. inefficiently conveyed. This is a major issue in both writing and programming.
  91. There are simple forms of misleading phrasing that distracts the user from the
  92. intended message. The simple use of obscure verbs or rambling may distract the
  93. reader from the intended topic. Code and literature are competing for your
  94. finite attention when conveying a message. If you have to read a programming
  95. project multiple times before understanding it, its phrasing is probably poor.
  96. An effective way that both English major and Computer Science majors can try to
  97. improve phrasing is through peer reviews. In peer reviews it becomes obvious
  98. which parts of your projects are hard to understand. In his paper “Letters to
  99. the Machine: Why Computer Programming Belongs in the English Classroom” Lynch
  100. noticed that as students become more comfortable with the computer dialect, they
  101. imagined how their audience would respond to what they wrote”(96). Programs,
  102. although ran on the computer are meant to be read and analyzed by other people.
  103. People can make their programs more readable through documentation, clear
  104. variable, and helper methods. Most inexperienced programmers use terrible
  105. variable names which have no relationship to what they are storing. Take the
  106. following example:
  107. ```
  108. String s1;
  109. String s2;
  110. String s3;
  111. ```
  112. ```
  113. String firstName;
  114. String middleName;
  115. String lastName;
  116. ```
  117. Someone skimming over the code on the top you would have no clue what the
  118. strings stored and would have to tear apart the program to figure out. The
  119. example on the bottom is crystal clear on what the variables are meant to store.
  120. Like programming students, inexperienced writers tend to struggle with using
  121. sources to support their arguments in their essays. Just like programmers lack
  122. documentation which informs the reader about what the program is doing,
  123. inexperienced writers have a hard time using sources in their essay to support
  124. their claims. In article “I Just Turned In What I Thought” Anne Elrod Whitney
  125. examined a particular student as he struggled to find a balance between personal
  126. ideas and sources when writing an essay(188). Although programmers and writers
  127. may know what they are talking about, they also need to communicate those ideas
  128. with the reader through ample sources and documentation.
  129. ```
  130. \++++++++[\>++++[\>++\>+++\>+++\>+\<\<\<\<-]\>+\>+\>-\>\>+[\<]\<-]\>\>.\>---.+++++++..+++.\>\>.\<-.\<.+++.------.--------.\>\>+.\>++.
  131. ```
  132. Would you believe me if I told you that the segment of code above this sentence
  133. when ran in a Brainfuck compiler prints “Hello World”?
  134. ```
  135. print("Hello World")
  136. ```
  137. This programming segment also prints “Hello World”, but in Python. There is a
  138. large variation in programming languages. However, most high level programming
  139. languages like Python and Java are much more readable than Brainfuck. A buzz
  140. word in the computer science field is “abstraction”. Abstraction is the process
  141. of simplifying complicated processes into something more understandable. The
  142. example in the top of the paragraph deals with manipulating memory registers to
  143. become the ascii values of “Hello World”. The problem with Brainfuck is that
  144. whenever you program for it, you have to translate every concept into a byte
  145. array. Computer scientists solve this problem by making higher level programming
  146. languages like Python and Java which takes care of mundane tasks under the hood.
  147. Vincent in his master thesis noticed that “Given the similarities between spoken
  148. languages and object-oriented programming languages that have emerged, there is
  149. much encouragement that there may be possibilities for a new instructional
  150. paradigm”(5). Higher level programming languages are starting to share a
  151. shocking number of similarities with English. With these new levels of
  152. abstraction, programmers are able to focus less on syntax and more on
  153. structured, problem solving and documentation which enables larger teams of
  154. programmers to work together with clarity.
  155. When you start treating code as an extension of the English language rather than
  156. a scientific construct, you start to write more understandable code. A few days
  157. ago a friend of mine asked me for help on a large programming project the night
  158. it was due. My brain groaned as I scanned his project, the bulk of the code was
  159. jammed into an ugly 300-line undocumented method. The variable names were
  160. obscure and there were so many nested statements that the code started to tail
  161. off the screen. I was unable to decipher what was happening in his program. All
  162. I could do for him was suggest how he could clean up his code and restructure
  163. his project so that he can understand what is happening where. It is hard to
  164. solve a bug when even the author has difficulties deciphering what is happening
  165. in the code. Programming is another form of communication that needs to be
  166. treated similarly to composition. The computer does not care what you write;
  167. however, it is critical that your audience is able to understand what you are
  168. saying with clarity and precision.
  169. ![](media/90703af9527d8d4aecc7eefbda5f049a.png)