Git Product home page Git Product logo

learn-elixir's People

Contributors

andrewmacmurray avatar asntc avatar carloslfu avatar changjoo-park avatar cleop avatar debck avatar finnhodgkin avatar fusillicode avatar hyprstack avatar iifeoluwa avatar iteles avatar jackcarlisle avatar jay-meister avatar jruts avatar jujumilk3 avatar katbow avatar luchoturtle avatar markhu avatar mcade avatar ndrean avatar nelsonic avatar nielsbom avatar pathway27 avatar reergymerej avatar robstallion avatar rohduggal avatar sciencefidelity avatar simonlab avatar sumanp avatar wyugue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

learn-elixir's Issues

Difference between tuples and lists

According to the readme:

Tuples are similar to lists except the items are stored in order

Which suggests that items in a list are not stored in order.

Developing with Elixir [online course]

A Pragmatic Studio course about Elixir was released yesterday. It cost $49 with the early access, and also there is a discount of 15% with the coupon code "elixir-early".

Here is the link to the course.

Question: Try elixir level 2 ( Making function calls easier to read )

Just finished the level 2 but i still have some doubts:

Exercise:

defmodule Person do
  def format_name(full_name) do
    format(String.split(full_name))
  end
end

Solution:

defmodule Person do
  def format_name(full_name) do
    full_name
      |> String.split
      |> format
end

We use the pipe operator to clean up our code and to facilitate maintaining and reading the code (no doubts here) my question is:

Is there a correct order to "divide" a function using the pipe operator?

Erlang Moocs by Simon Thompson (Functional Programming Guru Extraordinare!)

Yeah it is in Erlang, but at this introductory level, the mooc should still be useful as a well put together video course to supplement other resources.

  1. Functional Programming in Erlang: video and assignments

  2. Concurrent Programming in Erlang: Future Learn Note that the materials for this course are only going to be available for about two weeks, so if the course is of interest, the time to act is narrowing.

Simon Thompson teaches at the University of Kent, and so part teaches functional programming for a living, as well as being on first name of basis with the likes of Joe Armstron who is one of the creators of Erlang, upon which Jose Valim built Elixir It is good to get the information from the mouth of the horse, yes?

The Elixir docs have a very nice page on Elixir/Erlang syntax, but as I have said, and this introductory level, it is the explanations and examples and applications of concepts that I am personally looking at.

Evening all!

Video to accompany this repo

After the discussion in #56 about there not being a free/bought video series for Elixir (there is a subscription based one on codeschool.io, and a free intro, but both are very basic, and the bought one on udemy, but see the discussion in #56 ) I think it would be great (after a suggestion from @iteles) to have a video/series of videos accompanying this repo!

I'm not sure how we could actualise this, but I'd love to be involved, any ideas?

How much clarity is needed for beginners?

Should we assume Elixir is unlikely to be someone's first attempt beyond a simple understanding of the basics?

I'm wondering how much we need to add small notes to clarify things like for example what an enumerable is here:

Lists are enumerable, the Enum module provides lots of useful functions.

Or:

  • What an anonymous function is
  • The Elixir / syntax for named functions
  • What a macro is

Read Git Revision (Hash) in Elixir

I would like to display the git revision hash when visiting a url in an application
so that everyone on the project knows exactly which version of the app
is in "staging" or production.

e.g visiting: https://www.healthlocker.uk/_version
image
healthlocker/healthlocker@cc66a3c

Note: currently visiting this url shows an error page:
image

We made the Git Revision available in dwyl/aws-lambda-deploy/lib/utils.js#L80-L81
So it's a matter of running a similar command in Elixir and returning that when visiting the route.

Todo

  • run an Elixir command/script to get the git revision
  • create a route in basic Phoenix app that returns the git revision
  • determine if the git revision is available in an elixir app that has been deployed with edeliver (I don't see a reason why not, we need to be certain)

Simple but *practical* explanation of pattern matching

Pattern matching is one of the core things to understand in Elixir, but I'm yet to find any really good explanations of pattern matching.

Most give you very basic implementations like https://elixirschool.com/en/lessons/basics/pattern-matching/#match-operator, which are ok but leave beginner with very little to build on.

What other things can be done with pattern matching? How is it useful in a live app?
Can we add more advanced examples later in the tutorial?

Udemy "The Complete Elixir and Phoenix Bootcamp"

In order to learn Elixir and Phoenix I'm using the udemy course "The Complete Elixir and Phoenix Bootcamp", and at the moment I'm really enjoying it! It is also reduced to ยฃ15 at the moment if dwyl wanted a copy of the course to use.

I found the description and examples of pattern matching especially helpful as this was something I was struggling with understanding through the Elixir School book.

I'm only on the third section right now, but I hope to finish the course this week, at which point, assuming I still like it, I'd like to make a PR to add it as a link in the "Further Resources" section.

How to Monitor Dependencies in Elixir Projects using "HexFactor" :-)

In node-land we use the fantastic https://david-dm.org by fellow dwyler @alanshaw to monitor our dependencies ... โค๏ธ โœ…
see: https://github.com/dwyl/repo-badges#what

In the elixir-verse the tool for monitoring Hex dependencies appears to be "Hex Factor": https://beta.hexfaktor.org by @rrrene (brilliant project name BTW!) creator of many awesome elixir module including credo so fairly certain it's going to be superb! ๐Ÿš€

Yes, it's "Beta" so get in early to help debug! ๐Ÿ”

authorise hexfactor

We're tracking 3 repos:
image

Deps Status

More to come! ๐Ÿ‘

Are there some more recent tutorials that should be included?

In the 'What?' section of the tutorial, there is Jessica Kerr's Why Elixir Should take over the world which is a great general talk on Elixir for context and then a video intro to Elixir (which covers some of the same ground as both Jessica Kerr's talk and this learning resource) from March 2014: https://www.youtube.com/watch?v=lly-1UYmnFI&feature=youtu.be

With the momentum behind Elixir, are there any more recent videos that are also maybe also a bit more practical that we can include/replace here?

Styleguide

What guide should we follow for our syntax guidelines?

From the ambiguity of syntax guidelines here, deciding on a style guide (or a few style guides) may be a good idea

I would love to follow this one: https://github.com/christopheradams/elixir_style_guide

It looks popular, clear and strict and has the ability to link to each syntax decision which is nice.

[Video] Do we need to introduce Elixir from the bare basics?

In the learn-elixir README we give installation instructions and the links to some (awesome) videos and a link to elixirschool.com to get the user acquainted with what Elixir is.

Do we need to have an introduction to what Elixir is in our own videos, or should we just suggest that the user watches the videos/reads the material linked in the README? I suppose it depends on whether we want these videos to be able to completely stand on their own, or to be an accompaniment to the README of the learn-elixir repo.

I can see arguments for both so am keen for input!

Joy of Elixir: Free Online Book

An "absolute" beginner guide to Elixir, fills a gap in the market, and appears to be a work in progress: Joy of Elixir . From first impressions it feels a little bit like "Learn You a Haskell for Great Good" but for, uhm, Elixir.

Background links section takes you away from tutorial

The first two background links here are:

If I'm minimally methodical about following the tutorial, these two links will take me into a separate world of learning about elixir away from the tutorial, the content of which is also part of the things that come next in the tutorial itself (installation, interactive mode and functional docs).

I would suggest that the two interview links should be left in the background links section but that the two at the top of this issue are interspersed throughout the issue wherever it makes more sense (they are not background reading but the actual content of the tutorial).

String.to_atom errors

If you are liberal with where you are calling String.to_atom you should be weary that:

"Currently Elixir does not support the conversion of strings that contain Unicode codepoints greater than 0xFF."

That means that if you run String.to_atom on a string containing a โ€™ mark (for instance), it will error.

To fix this, when converting to an atom you could convert all of these quote marks to valid ' marks and filter out everything else that would cause an error.

You could write the following:

@doc """
  iex>safe_to_atom("hiโ€™hi")
  :"hi'hi"
  iex> safe_to_atom("hello")
  :"hello"
"""
def safe_to_atom(string) when is_binary(string) do
  string
  |> String.replace("โ€™", "'")
  |> String.to_charlist
  |> Enum.filter(&(&1 <= 255))
  |> to_string
  |> String.to_atom
end

Learn Functional Programming with Elixir by Ulisses Almeida

Not quite a book for absolute beginners, but most certainly a level or two down in difficulty and preparation than the Dave Thomas' book "Programming Elixir". It will be a useful book to learn the micropatterns ( see micropatterns article and micropatterns video) of functional programming for those needing to learn it, but not of the desire to go off to Scheme Land.

Here the author, Ulisses Almeida, compares within the Elixir forum the main differences between his text and that of Dave Thomas:

In Programming Elixir by Dave, he will guide you through all Elixir feature showing you some concepts of functional programming, concurrent programming, and testing. The book is for experienced developers. In Learn Functional Programming with Elixir by Ulisses (what me?), it will guide you only though functional concepts and show you Elixir. The book is for beginners, then a lot of examples will be step by step.

A good example is the "recursive functions" subject. In Programming Elixir you'll have ten pages that describe the recursive function and quickly jump to lists navigation, high order functions, and tail call optimization. In Learn Functional Programming With Elixir, we have entire a chapter with more than 20 pages about recursive functions. You'll see bounded and unbounded recursion, decrease and conquer, divide and conquer, tail call optimization, and anonymous recursive functions. Then, we have another chapter with more than 20 pages to explain high-order functions, giving you several examples from simples lists operations to lazy computation.

I'll hope this explanation help you understand the difference between the two books.

For further information on the necesssary preparation, here is a passage from the beginning of the book:

This book was tailored for beginners in functional programming and Elixir. I expect you have some experience in building simple algorithms, debugging errors, running commands in terminal, and an entry-level knowledge of software development. Any experience in others languages will help you out. You donโ€™t need to be an expert because weโ€™ll start from the scratch.

If you are an object-oriented programmer ready to take the next step, or a college student graduating and looking for a language to work with, this book is for you. If you tried to program in Elixir before and have had a hard time because of the functional programming concepts, this book will teach you the missing knowledge that you need to become a future expert. If youโ€™re already an Elixir or functional programming expert, you may find some valuable tips here, but this book probably isnโ€™t for you.

My basic feeling is that those who have already done some prior Elixir study would be more than enough prepared to tackle this text. It will hopefully solve the problem of having to learn the basic Elixir functional programming patterns so as to then go on to Phoenix, and has a fuller discussion of the use-cases of pattern matching than is found within the free resources. Too, it is written from the point of view of teaching those for whom functional programming is not the first paradigm they were introduced to, so includes within its audience those for whom Javascript was their first exposure to programming.

Yeah! That is all.

*single* edeliver command to build and "hot upgrade" a Elixir/Phoenix App?

#as part of using Travis to Continuously Deploy our Elixir Apps using Travis-CI
we are on a quest to find a single command that we can run when a build passes

mix edeliver build upgrade --auto-version=git-revision --from=$(git rev-parse HEAD~) --verbose 
mix edeliver deploy upgrade to production --version=$(git rev-parse HEAD~) --verbose

image

relates to / depends on: #53
... we want to curl app.net/_version instead of reading it from
required by: dwyl/learn-travis#22

Todo

  • keep investigating until we find the magic command to "hot upgrade" an Elixir app! ๐Ÿ”
  • Use latest available version of the app when deploying

I've read through all the docs https://github.com/edeliver/edeliver
& wiki https://github.com/edeliver/edeliver/wiki without any luck.
This looks like a good place to continue the quest:
http://www.east5th.co/blog/2017/01/23/upgrade-releases-with-edeliver/

Right now the process requires human intervention to manually type/input the version:
image

Also, it doesn't help that my internet connection keeps timing out because people are clearly using it for (non-work related) streaming ...!
image

Syntax preferences

What should be our syntax preference in these scenarios? Is it important?

Strings

String.contains "longer string" "string"

vs

"longer string" =~ "string"

Maps

list = ~w(one two three)

vs

list = ["one", "two", "three"]

[Video] Content to include initially

For the sort of MVP of the videos I think we should make a small amount of content which covers some of the basics of Elixir to see how well the videos are received. Content I think would be good to cover:

  • Use of iex
  • types of values in elixir
  • using the elixir documentation and how awesome it is
  • commonly used code modules (Enum etc)
  • case, cond, if and unless
  • guards
  • pattern matching (including pattern matching in case statements)
  • creating projects with mix
  • documentation in elixir
  • testing in elixir, including doctests

I think these would be a good basis and be enough content that someone could go and play with Elixir. Some of this stuff (testing/doctesting and documentation) is not included in any of the free videos that I've seen on Elixir, and testing and documentation are both super important to us at dwyl so I think they are a must have.

Any suggestions of other content to include in the first series of the videos?

Truthiness in Elixir

Currently there's no reference to truthiness in the readme. Given the prevalence of cond and conditional statements in Elixir I think think it would be good to add a reference to the top of Basic types. A few of the tutorials I followed at the start of my Elixir journey didn't talk about truthiness. It definitely negatively impacted my learning, especially coming from JS.

Truthiness in Elixir

All values / types in Elixir apart from nil and false are truthy:

if 0 do "This is happening" end # "This is happening"

if "False" do "This is still happening" end # "This is still happening"

if false do "Not happening" end # nil

Extend README Documentation

Currently the README.md gives a good introduction by covering the basics. I feel as though this should be extended further to include more things integral to a functional programming language:

  • immutability
  • recursive functions
  • partial application
  • heads and tails

Does anyone have any thoughts on things to include?

Initial list of topics to add or extend within the documentation:

  • Generating an elixir project
  • Object Oriented vs Functional
  • Native Modules
  • Module Documentation
  • Testing
  • Pattern Matching - extend #57
  • Elixir -> Erlang -> BEAM
  • Pipe Operator
  • Maps
  • Keyword Lists
  • Structs

Real examples

I don't know if this is suitable for this repo...

I have been doing some codewars on elixir and thought it would be good to show a few simple problems in this learn-elixir repo, and briefly cover a couple different solutions to each one. I hope that it would provide the reader with more structured intro to the language that they can practice by doing.

Does it sound suitable?

Shortcut syntax for key/value pair lists and maps used in this tutorial

In most beginner learning resources I have seen, map literals are presented as:

  animal = %{
     :name => "Rex",
     :type => "dog",
     :legs => 4
}

In this repo, we dive straight into using the shortcut for key/value maps (https://github.com/dwyl/learn-elixir#maps).

animal = %{
  name: "Rex",
  type: "dog",
  legs: 4
}

My understanding is that whilst this is the most common usage, it's also only able to be used if the keys are atoms. Is it worth mentioning that this is a possible syntax so that beginners who see other resources are not confused?

How to display HTML code snippets in your elixir code without it rendering

HTML entities can be used to help you display code snippets without them rendering as the code they represent. For example:

Is actually written in the code as:

<code>
  &lt;%= component &quot;primary_button&quot;, value: &quot;I'm a Primary Button&quot; %&gt;
</code>

Where &lt; represents the less than or < symbol etc.

Rather than encoding your hard code and pasting it in statically, how can I dynamically encode my regular code into HTML entities so that I don't have to keep on updating/changing it as my code changes? I want to create a function that will read the contents of a file and then encode its contents so that this will update whenever the file is updated.

Encoding your code
At first I considered regex or some other form of replacement function however this would be complicated to cover all possibilities. So instead I came across the hex package:

https://hex.pm/packages/html_entities

To install the hex package add {:html_entities, "~> 0.3"} under deps to your mix.exs file and run mix deps.get.

Reading the contents of a file
Now that I can encode my code, I now need to be able to grab the code from within a given file in order to encode it. To do this I can use the File module like this:

File.read!("./web/templates/component/primary_button_example.html.eex")

This only works with the trailing bang ! otherwise it errors. This is because we want it to return the code to us, without the ! it will return a tuple instead.

So this function is now called where I want the code snippets to appear in the html file like this:

The function contains:

And on the browser we see:

Despite the availability of the hex package, it turns out that using File.read! I don't even need it.

๐Ÿ˜€

Relates to mindwaveventures/good-thinking-phoenix#115

Edit README to be more concise and ordered more chronologically

Currently the README is not far off 4000 words and from my own experience I found this, combined with the order in which topics are displayed/introduced a bit confusing when knowing where to start.

I am proposing to edit down the text a little (not to lose meaning but simply to make things more concise). As well as thinking about the order things appear, e.g. moving some of the longer video content which is about other topics such as phoenix lower down. It's not that this content isn't useful (hence not removing it), it's just that if you're trying to learn Elixir, you probably want to understand the basics of the language before you leap into phoenix.

I will make sure that people know that there is more content for them that may be of interest by making sure its included in the contents.

I think these changes could help improve people's learning experiences by helping them to learn the bits of elixir they need faster.

What does 'enumerable' mean?

Lists are enumerable, What does enumerable mean?

Is the meaning of enumerable that you can refer to a value by numerical reference (by counting from left to right)?

Say I have a list: ["a", "b", "c"], the numerical reference/ index of a would be 0, b = 1, c = 2?

I've looked at dictionary definitions as well as this forum question: http://softwareengineering.stackexchange.com/questions/199592/what-does-enumerable-mean and can't tell if it's more complex than my original assumption.

brew install elixir -> fails

Following the "Official" instructions: http://elixir-lang.org/install.html#mac-os-x
Attempting to install elixir on MacBook Air running OS X 10.12 using brew install elixir
we get the following error:

brew-install-elixir-fails

Warning: You are using OS X 10.12.
We do not provide support for this pre-release version.
You may encounter build failures or other breakages.
==> Installing dependencies for elixir: libtiff, wxmac, erlang
==> Installing elixir dependency: libtiff
==> Downloading http://download.osgeo.org/libtiff/tiff-4.0.6.tar.gz
Already downloaded: /Users/Admin/Library/Caches/Homebrew/libtiff-4.0.6.tar.gz
==> Downloading https://mirrors.ocf.berkeley.edu/debian/pool/main/t/tiff/tiff_4.0.6-1.debian.tar.xz

curl: (22) The requested URL returned error: 404 Not Found
Trying a mirror...
==> Downloading https://mirrorservice.org/sites/ftp.debian.org/debian/pool/main/t/tiff/tiff_4.0.6-1.debian.tar.xz

curl: (22) The requested URL returned error: 404 Not Found
Error: Failed to download resource "libtiff--patch"
Download failed: https://mirrorservice.org/sites/ftp.debian.org/debian/pool/main/t/tiff/tiff_4.0.6-1.debian.tar.xz

Elixir Concurrency Model

Simple example of the Elixir Concurrency Model and how to handle blocking processes.

Paste the below code into a file called concurrency_demo.ex and run
$ elixir concurrency_demo.ex to run the example locally

defmodule Log do
  defp log(arg), do: IO.puts arg
  def first, do: log "first"
  def second, do: log "second"
  def slowfirst do
    :timer.sleep(1000)
    first()
  end
end

IO.puts "RUN 1"
Log.slowfirst()
Log.second()

# Outputs:
# $ RUN 1
# $ first
# $ second

# In "RUN 1" we see that `slowfirst` blocks `second` from running

IO.puts "RUN 2"
task = Task.async(fn -> Log.slowfirst() end)
Log.second()

# Outputs:
# $ RUN 2
# $ second
# $ first

# But in "RUN 2" we start `slowfirst` and then carry on with the script

Task.await(task) # If you don't assign task and `await`, the program will finish and you won't see the log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.