https://github.com/melling/ComputerLanguages/blob/master/eli...
https://github.com/melling/ComputerLanguages/blob/master/eli...
I never had any issues here with sublime
As someone who has also used Erlang in the past I can tell you what's nice about Elixir: super modern developer friendly ecosystem. Mix - the pkg manager - is dead simple and does the job well, the docs are amazing with tons of examples and direct links to source code everywhere. The language itself also has some nice syntactic sugar over standard Erlang, and integrating with Erlang was a breeze. Overall the whole system is just smooth and works. I was impressed.
I should have been more specific: what about Phoenix do you like?
The other bit for me is Elixir's macro support. This lets you do really clean route matching in Phoenix. See http://www.phoenixframework.org/docs/routing for some examples.
and not to throw yet another buzzword at this post but Phoenix is the best framework I've found yet for smaller networked services. so enjoyable to build with.
Most out-of-box apps are too simple, and most web framework app skeletons are insanely overdesigned and, frankly, miserable. Certainly there are a number of big frameworks (django, rails) that can give you most things out of the box, but I'm not a fan of heavyweight frameworks in general. I think Phoenix strikes a great balance
For example, if I have an `user/index.html.eex` template for a `UserView` module, I can render it with:
View.render(UserView, "index.html", name: "colbyh")
At compile time, we simply precompiled the index.html.eex template as a `def render("index.html", assigns) ...` function clause.Now imagine I want a `bio.html` template. Instead of making a template file, I can literally do this in my view:
def render("bio.html", assigns) do
"Bio: name: #{name assigns.name}"
end
...
View.render(UserView, "bio.html", name: "colbyh")
=> "Bio: name: colbyh"
And it Just Works exactly because there's no magic going on. Templates are just function calls, whether they are precompiled from a template engine or defined by the user manually.- templates are just functions
- Views render templates and serve as a presentation layer
1. @var's in templates are not module attributes (though they do seem to be convenient!)
2. The form for `use` is different in Phoenix than it is in Elixir proper – instead of passing opts, you pass an atom that selects the implementation of __using__ you want. (This bit of magic makes no particular sense to me – why wouldn't you just use a submodule, say MyApp.Controller, that has the correct and single __using__ attached?)
This isn't really true. If you check out the ExUnit, you can pass something like "use ExUnit.Case, aysnc: true" and it'll setup your module to run tests asynchronously. You can pass any atom/value combination into use.
HTTPoision.Base, and ExAws to name a few other projects also have the convention of passing options into __using__.
To me, the confusion comes from the fact that the Elixir get-started documentation doesn't say anything about this. It is however listed in the Kernel forms that "use Module" actually just translates to Module.__using__([])
I seem to remember earlier documentation using a lot of render calls directly in the controller, and add to that the fact that view functions were available to both controller modules and templates without any explicit inclusions muddied the waters a bit. your explanation makes total sense though and the documentation is now clearer than I remember so chalk it up to growing pains? haha.
and having templates that precompile to render functions is pretty magical, tbh. would personally love it if the view documentation reflected this on some level.
> having templates that precompile to render functions is pretty magical, tbh. would personally love it if the view documentation reflected this on some level.
You mean like in our nicely formatted ExDocs? :) The docs walk you through similar examples as I've posted here, but go more in depth. https://hexdocs.pm/phoenix/Phoenix.View.html
and thanks for keeping up work on the docs!