dwyl / learn-elixir Goto Github PK
View Code? Open in Web Editor NEW:droplet: Learn the Elixir programming language to build functional, fast, scalable and maintainable web applications!
:droplet: Learn the Elixir programming language to build functional, fast, scalable and maintainable web applications!
Elixir for Programmers by Dave Thomas: https://pragdave.me/
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.
Wondering if anyone has checked out and recommends either of these books by the same author..
Imposters Handbook
Taking Off With Elixir
I know that @nelsonic has ordered the PragProg books which offer the plethoric experience of that particular author. I'm wondering if these might be a gentler intro, of course they also cost ๐ฐ ..
Imposters Handbook reminds me of this post, 4 Semesters Of CS In 6 Hours. Now I'm rambling...
See:
Relates to: dwyl/learn-travis#19 we should have the instructions over in the "Learn Travis" tutorial for people who want to know more about CI and Elixir on Travis can be a section. ๐
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.
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?
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.
Functional Programming in Erlang: video and assignments
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!
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?
https://medium.com/@StevenLeiva1/understanding-elixir-s-genserver-a8d5756e6848
Found this article useful in understanding GenServer ... ๐
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:
anonymous function
is/
syntax for named functionsmacro
isI 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
healthlocker/healthlocker@cc66a3c
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.
edeliver
(I don't see a reason why not, we need to be certain)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?
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.
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! ๐
More to come! ๐
Codeschool just have released this course https://www.codeschool.com/courses/try-elixir
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?
Dave Thomas is very very good at communicating information; this conference talk gives a nice introduction to the use of pattern matching in Elixir: Think Different
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.
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!
After reading dwyl/contributing#4 about raising issues for every PR, I am creating this issue because I intend to work through the exercise on the README and then submit any amends based on my experience.
https://zeroclarkthirty.com/2015-11-01-elixir-is-not-ruby.html (interesting read...)
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.
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).
great post by @sajmoon explaining how to use Tags to simplify tests:
http://blog.simonstrom.xyz/elixir-testing-tag-tests-in-exunit
snapshot: Elixir testing - Tag tests in ExUnit will help you clean up your code_.pdf
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
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.
The Elixir Book: https://pragprog.com/book/elixir13/programming-elixir-1-3
is easily the best way to learn Elixir. Should we consider buying 20 copies in "bulk"
and giving one to each person in DWYL to accelerate people's learning?
Who is interested in getting a paper copy of the book?
#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
relates to / depends on: #53
... we want to curl app.net/_version
instead of reading it from
required by: dwyl/learn-travis#22
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:
Also, it doesn't help that my internet connection keeps timing out because people are clearly using it for (non-work related) streaming ...!
What should be our syntax preference in these scenarios? Is it important?
String.contains "longer string" "string"
vs
"longer string" =~ "string"
list = ~w(one two three)
vs
list = ["one", "two", "three"]
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:
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?
go to: https://elixirweekly.net
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.
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
A set of problems to practice Elixir-fu!: Etudes for Elixir
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:
Does anyone have any thoughts on things to include?
Initial list of topics to add or extend within the documentation:
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?
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?
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>
<%= component "primary_button", value: "I'm a Primary Button" %>
</code>
Where <
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
Found this when searching "elixir semantics", and I think it is a very useful article on learning Elixir.
I just wanted to share this resource with dwyl!
Enjoy it!
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.
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.
The Elixir book uses module attributes such as @moduledoc
and @create_attrs
in modules and tests but does not explain what they are and how to use them, we should add an explanation to our tutorial...
http://brettwise.com/the-or-at-symbol-in-elixir/
https://elixir-lang.org/getting-started/module-attributes.html
The README file is currently not rendering anymore.
It breaks down on line 630
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:
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
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
This looks promising: https://github.com/ueberauth/guardian
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.