7 ms·
There was so much mystery and magic that I felt was happening behind all things generated in Phoenix that I just felt lost.
by yeetaway1111 4y ago
There was so much mystery and magic that I felt was happening behind all things generated in Phoenix that I just felt lost.
- Rodeoclash 4y agoIt might feel like that way to start with when you're new to the framework, but if you spend a bit of time in it you'll find a lot less magic going on then you expect. I know where you're coming from however, I felt the same way when I started.
- ungamedplayer 4y agoIs this in regard to 'mix phx' gen commands or something else ?
- Liberonostrud 4y agoI guess he is talking about macros and perhaps the syntax which I also didn't like and is one of the reasons why I consider PHP better (even though the naming and parameters inconsistency could be better). Check for yourself: ``` iex> length([1, 2, 3]) == length [1, 2, 3] true ``` or (taken from the Elixir docs): --- Take the following code: ``` if variable? do Call.this() else Call.that() end ``` Now let’s remove the conveniences one by one: do-end blocks are equivalent to keywords: `if variable?, do: Call.this(), else: Call.that()` Keyword lists as last argument do not require square brackets, but let’s add them: `if variable?, [do: Call.this(), else: Call.that()]` Keyword lists are the same as lists of two-element tuples: `if variable?, [{:do, Call.this()}, {:else, Call.that()}]` Finally, parentheses are optional, but let’s add them: `if(variable?, [{:do, Call.this()}, {:else, Call.that()}])` That’s it! Those four rules outline the optional syntax available in Elixir. Those rules apply everywhere consistently, regardless of the construct you are invoking. Whenever you have any questions, this quick walk-through has you covered. --- I don't like this possiblity to use so many syntaxes good, especially if you deal with mulitple parameters in functions. Elixir doesn't have C-like semicolons or braces like in Lisp so multiple parameters are hard to parse sometimes. The creator of Elixir himself answered that one of the things he thinks he could do better at the beginning was to make the syntax more strict and he mentions the optional () e.g. IO.puts "Hello" vs IO.puts("Hello").
- josevalim 4y ago> I don't like this possiblity to use so many syntaxes good There other side of the coin is having specialized syntax for each construct. For example, PHP currently lists [56 keywords][0], and each keyword generally comes with their own grammar rules (I picked PHP because it was an example you mentioned above). Elixir, on the other hand, has [15 keywords][1]. Defining modules, functions, conditionals, and so on, all use the same syntax rules. At the end, you end-up with less syntax because the whole language is built on the few affordances above. The other benefit is that developers can also extend the language consistently, since the constructs for designing and extending the language are the same. > The creator of Elixir himself answered that one of the things he thinks he could do better at the beginning was to make the syntax more strict If I could go back in time, I would have made it strict since the beginning, but we have already made it strict over time through deprecation warnings in the last 7-8 years. Given a time machine, I'd probably not have changed the notes you mentioned above. :) 0: https://www.php.net/manual/en/reserved.keywords.php https://www.php.net/manual/en/reserved.keywords.php 1: https://hexdocs.pm/elixir/syntax-reference.html#reserved-words https://hexdocs.pm/elixir/syntax-reference.html#reserved-wor...
- Liberonostrud 4y ago[flagged]
- josevalim 4y agoNone of your questions are related to the point I have made. > Do you seriously think Phoenix 1.7 is a more productive and better experience for making average websites in 2023 for an average person? Pointless question without specifying what is an average person and what is an average website. This will lead nowhere than pointless speculation. If you want to answer it, go partner with user and developer studies firms, apply proper methodologies and correctly evaluate results. > By the way, isn't your website elixir-lang in Ruby or using a static generator Jekyll for generating the html pages written in Ruby? elixir-lang uses Jekyll in Ruby. We wrote the landing page for livebook.dev in JavaScript. And my previous (mostly Ruby) company had a blog in WordPress. Phoenix runs on Phoenix and my new company website runs on Phoenix too. This question also fully misses the point. There is no one claiming Phoenix (or any other technology) is a superior technology across all users and all use cases. This is literally [a straw man argument][0]. And there is no one claiming Phoenix is useful for static generation. I would be completely happy with using Elixir if we have well-established static side generators. Other than that, the technology for a static side generator hardly matters. What matters are the contents and you will be surprised to find the Elixir website mostly talks about Elixir. It is clear there is no attempt in engaging in good faith here, so I am bowing out of future conversations. 0: https://en.wikipedia.org/wiki/Straw_man https://en.wikipedia.org/wiki/Straw_man
- lycos 4y agoThat's interesting! When I started out I maybe felt the same but most of that was just not understanding it, and now to me it feels like one of the more explicit frameworks I've used, which I actually enjoy. I could recommend reading http://www.petecorey.com/blog/2019/05/20/minimum-viable-phoenix/ http://www.petecorey.com/blog/2019/05/20/minimum-viable-phoe... which was posted on HN as well some years ago.
- ElDji 4y agoSee also https://github.com/wojtekmach/mix_install_examples/blob/main/phoenix.exs https://github.com/wojtekmach/mix_install_examples/blob/main... https://github.com/wojtekmach/mix_install_examples/blob/main/phoenix_live_view.exs https://github.com/wojtekmach/mix_install_examples/blob/main...