3 ms·
1) I would argue that the pipe operator is *more erlangey than ruby-ey. It is crazily enough possibly the most useful syntactic sugar feature I've ever seen, e
by dnautics 8y ago
1) I would argue that the pipe operator is *more erlangey than ruby-ey. It is crazily enough possibly the most useful syntactic sugar feature I've ever seen, especially coupled with labelled IO.inspect. I've never had to go down to the debugger, and reverting the inspect is nearly instantaneous.
2) my number one wish-that-will-never happen for elixir would be the inverse of the mutability issue, variables should be immutable by default but have a sigil or postfix (like !) that lets you make it mutable. Of course, as it is, this is trivially implementable as a credo linter feature.
3) I think generally the biggest problem with macros is the risk of nonlocal side effects in your code, and elixir does a nice job of containing it lexically.
- _asummers 8y agoYou can get mutability, you just need to be explicit with it using a GenServer or some other process abstraction. It just has to be explicit via message passing because your local node is just a special case of the overall network topology that Erlang needs to service.
- losvedir 8y ago> 2) my number one wish-that-will-never happen for elixir would be the inverse of the mutability issue, variables should be immutable by default but have a sigil or postfix (like !) that lets you make it mutable. Just to clarify for others, and as the article notes, variables aren't "mutable" in Elixir but rather can be rebound. Even rust, where - just like you desire - you have to explicitly tag something "let mut" if you want mutability, will let you re-bind the variable without that tag. I've programmed in Elixir full time now for two years and I can't recall any times accidentally shadowing a variable has bit me (but I do `mix compile --force --warnings-as-errors`) as part of my development routine, and that has caught it before for me. (Oh, unless you mean you wish Elixir had _real_ mutability. That _would_ be quite the change, as obviously no functions in the standard library support that and you have to make do with GenServers and the like. I'm not sure I'd like that as the whole language ecosystem is predicated on immutability and message passing...) While we're throwing out "one wish-that-will-never happen" ideas, though, here's mine: I'd love for Elixir to be able to automatically add guards to functions based on the type spec. That is, if you had this code: @spec foo(String.t(), MyEnum.t()) :: boolean() def foo(str, enum) do # ... end I would love it if that got compiled to essentially: def foo(str, enum) when is_binary(str) and enum in [:enum1, :enum2, ...] do # .. end In general, dialyzer is the weakest part of the ecosystem for me, and I've had `nil` and other random things sneak into my functions before despite being against the type spec. I'd much prefer to have the function call crash early by just not matching any clauses.
- dnautics 8y agoYes sorry I was being inexplicit about variable rebinding. I'm used to Julia where variable refers to the lexical form.... Identifier? And not to the actual underlying data, which is called the value. I'll write up my credo linter and see if you like it. Your guard idea is pretty good, but I would appreciate it even more if those guards existed in dev and test and got yanked in prod.