Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Learning Elixir Better through Collaboration and Giving Back

Learning Elixir Better through Collaboration and Giving Back

Talk given at Code BEAM SF 2018 - https://codesync.global/speaker/mohnish-jadwani/

Abstract:
Learning a new programming language can be intimidating and it doesn’t take too long before impostor syndrome can kick in. Things can even get more challenging if you’re learning includes being exposed to a new programming paradigm. This talk discusses about ways through which the journey of learning Elixir can be made more fulfilling and worthwhile through collaboration. We will explore how the better usage of mediums like Exercism, Slack etc., not only help us identify different ways of getting unstuck as we work towards getting a clearer understanding of the functional concepts in Elixir but also how they empower us to be better programmers in general through thoughtful conversations about code. We will also see how this journey of learning Elixir gives us opportunities through which we can contribute back to the language and community.

Mohnish G J

March 15, 2018
Tweet

More Decks by Mohnish G J

Other Decks in Programming

Transcript

  1. Many resources out there Learning a new language with so

    many resources out there can get overwhelming 2
  2. Learning a new language can be challenging and fun The

    journey of learning a new language can be - thrilling and deeply uncomfortable 3
  3. 4

  4. Posted by a user on elixirforum.com - This was me

    7 A real world connect seemed missing in Learning by Reading
  5. Why learn this way? ◦ Easier to understand ◦ Easier

    to see a real world connect ◦ Learn to apply multiple concepts at one time Learning by Doing - Why? 9
  6. What were my learning goals? ◦ Get confident ◦ Make

    and Track regular progress as a beginner ◦ Compare my solutions to others Learning by Doing - What? 10
  7. Learning By Doing - How? How can Exercism.io help you

    learn a new language better? Exercism 11
  8. Exercism and ‘Hello World’ exercise in Elixir Sample script in

    which we write code to pass the failing ‘Hello World’ related test 14
  9. Documentation was confusing wrt usage of Default Arguments The presence

    of IO.puts in the website documentation wrt usage of Default Arguments was confusing 15
  10. Gigasecond Exercise ◦ Given a particular input date ◦ Calculate

    a date one billion seconds(Approx. 31.70 years) after an input date Solving the Gigasecond exercise on Exercism A sample test case wrt the Gigasecond exercise 17
  11. My Initial Solution to the Gigasecond Exercise 18 My Initial

    Solution to the Gigasecond Exercise defmodule Gigasecond do @doc """ Calculate a date one billion seconds after an input date. """ @spec from({{pos_integer, pos_integer, pos_integer}, {pos_integer, pos_integer, pos_integer}}) :: :calendar.datetime @gigasecond 1000000000 def from(time_in_datetime) do given_time_in_seconds = :calendar.datetime_to_gregorian_seconds(time_in_datetime) new_time_in_seconds = given_time_in_seconds + @gigasecond :calendar.gregorian_seconds_to_datetime(new_time_in_seconds) end end
  12. Unlearning imperative style of problem solving Feedback on my initial

    solution 19 Feedback on my initial solution
  13. Unlearning imperative style of problem solving Assignments to a temporary

    variable can be replaced by the pipe operator in Elixir 20
  14. Many Learnings from solving just one Gigasecond exercise Initial Solution

    to the Gigasecond exercise 21 defmodule Gigasecond do @doc """ Calculate a date one billion seconds after an input date. """ @spec from({{pos_integer, pos_integer, pos_integer}, {pos_integer, pos_integer, pos_integer}}) :: :calendar.datetime @gigasecond 1000000000 def from(time_in_datetime) do given_time_in_seconds = :calendar.datetime_to_gregorian_seconds(time_in_datetime) new_time_in_seconds = given_time_in_seconds + @gigasecond :calendar.gregorian_seconds_to_datetime(new_time_in_seconds) end end
  15. Many Learnings from solving just one Gigasecond exercise Final Solution

    to the Gigasecond Exercise 22 defmodule Gigasecond do @doc """ Calculate a date one billion seconds after an input date. """ @spec from({{pos_integer, pos_integer, pos_integer}, {pos_integer, pos_integer, pos_integer}}) :: :calendar.datetime @gigasecond 1000000000 def from(time_in_datetime) do time_in_datetime |> :calendar.datetime_to_gregorian_seconds |> + @gigasecond |> :calendar.gregorian_seconds_to_datetime end end
  16. ◦ Bob is a teenager whose his responses are very

    limited. ◦ Bob’s responses usually are: ▪ 'Sure.' if you ask him a question. ▪ 'Whoa, chill out!' if you yell at him. ▪ 'Fine. Be that way!' if you address him without actually saying anything. ▪ 'Whatever.' to anything else. Solving the Bob exercise on Exercism 23
  17. . Solving the Bob exercise on Exercism 24 “shouting in

    Russian” - The test case where I got stuck wrt the Bob exercise
  18. How different pieces fit together - Exercism & Elixir Forum

    Another user asking about a similar question for the Bob exercise on elixirforum.com 25
  19. Applying the suggestion on Elixir Form to my solution Trying

    out the suggestion in IEx 26 iex(5)> input = "УХОДИ" "УХОДИ" iex(6)> String.upcase(input) "УХОДИ" iex(7)> String.downcase(input) "уходи" iex(8)> String.upcase(input) == input true iex(9)> String.downcase(input) != input true
  20. Applying the suggestion on Elixir Form to my solution Applying

    the suggestion on elixirforum to my solution 27 defmodule Bob do def hey(input) do cond do String.ends_with? input, "?" -> "Sure." String.trim(input) == "" -> "Fine. Be that way!" String.upcase(input) == input && String.downcase(input) != input-> "Whoa, chill out!" true -> "Whatever." end end end
  21. The suggestion on Elixir forum led to a simpler solution

    Applying the suggestions discussed on elixirforum to my solution 28
  22. How different pieces fit together - Exercism, Elixir Slack Wrote

    a blog post based on the typespecs learnings discussed via slack 29 Discussed importance of typespecs in the #beginners channel
  23. Word Count Exercise ◦ Given a phrase, count the occurrences

    of each word in that phrase. ◦ Thought Process ◦ Approach Solving the Word count exercise on Exercism 31 One of the test cases as part of the word count exercise
  24. Question asked on how to Enumerate effectively in Elixir? A

    Stackoverflow question asked on how to loop through a map in Elixir 32
  25. Use Enum.reduce to enumerate effectively in Elixir The Stack Overflow

    question was answered by the creator of Elixir - José Valim 33
  26. Did you Know? - Bots can Collaborate too! Ebert Bot

    offers a valuable suggestion via Credo to help one write better Elixir code 36
  27. 39 Not all Elixir track exercises seemed to be in

    increasing order of difficulty
  28. Solving the Sublist exercise on Exercism • Given two lists

    determine if ◦ The first list is contained within the second ◦ The second list is contained within the first list ◦ Both lists are contained within each other ◦ If none of these are true 41
  29. Solving for Sublist exercise using the Subset approach • Approach

    1 - Subsets ◦ MapSet.subset ▪ Limitations 42 The sublist exercise related test case for which Mapset’s subset function did not pass Mapset’s subset returns true but as per our test case what we require is false(or unequal)
  30. 43 Huge sublist not in huge list related test case

    • Approach 2 - Difference between two lists ◦ Subtraction operator ▪ Limitations Solving for Sublist exercise using the Differences approach
  31. 44 • Approach 2 - Difference between two lists ◦

    Subtraction operator ▪ Limitations Complexity of the difference is proportional to list lengths This information about complexity was mentioned in the docs of the core elixir repo
  32. • Approach 2 - Difference between two lists ◦ Subtraction

    operator ▪ Limitations Solving for Sublist exercise using the Differences approach 45 The sublist exercise related test case for which the difference operator usage did not work
  33. Did I honestly try fixing things myself? Looking Beyond Impostor

    Syndrome - Questions that I ended up asking myself 53
  34. Did I find ways to get unstuck? Looking Beyond Impostor

    Syndrome - Questions that I ended up asking myself 54
  35. Was I fast enough at getting unstuck so that you

    could keep moving forward? Looking Beyond Impostor Syndrome - Questions that I ended up asking myself 55
  36. Have I attempted to identify the missing gaps between my

    thought process and that of others? Looking Beyond Impostor Syndrome - Questions that I ended up asking myself 56
  37. It’s completely ok to go ahead and ask for hints

    on Exercism Looking Beyond Impostor Syndrome - Other Reflections 57
  38. • Questions that I ended up asking myself a. Have

    you i. honestly tried fixing things yourself? ii. found ways to get unstuck? iii. fast enough at getting unstuck so that you could keep moving forward? iv. identified the missing gaps between your thought process and that of others? • It’s completely ok to go ahead and ask for hints on Exercism Looking Beyond Impostor Syndrome - To Sum up 58
  39. Comparing my solutions to others helped me write better Elixir

    code Other Exercism users discussing what their takeaways where from another user’s solution64
  40. Some other ways through which Elixir Forum can be helpful

    A glimpse of the different kind of questions asked around the topic of ‘Learning Elixir’ 70
  41. Use Elixir Lang Slack Archive to see older conversations 75

    One can also see older conversations on some channels via - http://elixir-lang.slackarchive.io
  42. Elixir community is very approachable for beginners Takeaways - Elixir

    community is very supportive 77 A recent Elixirforum.com user appreciating the responsiveness in the community
  43. • Platforms like Exercism provide ◦ Direct or Indirect Mentorship

    ◦ Provide countless small wins ◦ Help you become better problem solvers Takeaways - Use Collaboration platforms actively 78 A user who solved the Exercism problem cared to learn more about the underlying approach to it
  44. Collaboration can be in the passive form as well Takeaways

    - Power of Collaborative Learning 79
  45. Takeaways - You can contribute to Elixir even as a

    beginner 80 Give Back - You can contribute to Elixir’s & it’s adoption even as beginner to the language! The Bigger Picture - Why write good docs?
  46. Takeaways - Keep Having a Beginner’s Mind! Benjamin Tan Wei

    Hao(An Elixir book author) wrote a post about Beginner Elixir Project Ideas 81
  47. • Image Credits ◦ Are your ramping up in a

    new langauge ◦ Many resources out there ◦ Being Stuck ◦ From Not Knowing to Knowing ◦ Confucius quote - Tim Fargo • Other Credits ◦ To all those people who’ve directly or indirectly inspired me to give this talk Credits 84
  48. Thank You and Feel Free to Get in touch! Mohnish

    G Jadwani Twitter @mohnishgj Github boddhisattva Blog medium.com/@mohnishgj Site http://www.mohnishjadwani.com/ Gmail mohnishgj 85