3 ms·
I've yet to try Rust. But Go is the best and worst thing to happen in my career. Best because it's amazing, worst because now I don't like working in other lang
by ngngngng 7y ago
I've yet to try Rust. But Go is the best and worst thing to happen in my career. Best because it's amazing, worst because now I don't like working in other languages.
I'm trying elixir currently, and it makes me want to rip my hair out. No for loops, no typed parameters, implied returns. Who in the world though any of this was a good idea? IO.puts() refuses to print certain objects (list of ints) and just prints a newline, making it useless for debugging.
I'm very very excited to try Rust, and I'm glad I've been able to choose the languages I work with up to this point in my career.
- quaunaut 7y agoJust wanted to correct some things, as a fan of both Elixir and Rust. > No for loops But we do have for loops? That's what comprehensions are: https://elixir-lang.org/getting-started/comprehensions.html https://elixir-lang.org/getting-started/comprehensions.html > no typed parameters But if you need types on your parameters, you have Guards, which... check for type? Sure, you don't type every last parameter, but if you want that you can upgrade to Dializer and get that feature too. It's just not as useful as you likely treat it. > implied returns I understand that some may not like this, but it comes out of the idea that generally, you want to avoid "side effects"- ie, things in code that happen without anyone but the original function causing them being able to tell. Elixir doesn't completely lack them, as that would be pretty unreasonable, but it does at least ask that you're clear about the purpose of functions by having them always return something. > IO.puts() refuses to print certain objects (list of ints) and just prints a newline, making it useless for debugging. This seems like something must be going wrong. `IO.puts` certainly prints lists of ints, however, it might also be mistaking them for a charlist, which is definitely a concern. That's why generally, you want to use `puts` for text, and `IO.inspect` for data structures. As an added convenience, if you want to annotate your data structure with text, you can modify `IO.puts` like so: `IO.puts "List: #{inspect(list_of_numbers)}"`. That will parse the list to the inspect version and insert it into your `puts` line. For the record, I'm not saying any of these necessarily shouldn't be a reason to not like Elixir- we all have our preferences, but the reason behind many of these choices is philosophical, and I'd be happy to explain anything else that has puzzled you, if you're still interested in learning more about Elixir.
- Svip 7y agoI also write Go for a living, and feel sort of the same way about other languages. But then I have some good news for you with Rust, you'd like it (at least I did/do). It's different from Go, for sure, and in my head fulfils different purposes from Go, but it's nice to have a choice between two things I like. Fair warning, though, before Go, I wrote Delphi for a living.
- rargulati 7y agoThis is really interesting to read. I've been writing Go for about ~4 years professionally, and recently (<6 months) jumped into Elixir (and a bit of Rust). They've been nothing but a breath of fresh air, and I can't wait to write more as I'm starting my new thing. I'm definitely more excited about Elixir as it's really, really pleasant to write and in some sense, a major increase in productivity. Agree about typed parameters + implied returns, but you can get some of that back using guards + dialixer/dialyzer.
- weiming 7y agoYou can accomplish iterations more concisely using other means, for example list operations in `Enum` [1]. Not too different from other modern languages often using `foreach` vs. i-based iteration. Also, try `IO.puts inspect foo` for printing stuff. `IO.puts` can be compared to print() behavior in other languages expecting toString() is fully implemented (`to_string` in this case for your custom typed data structs. [2][3]) [1] https://hexdocs.pm/elixir/Enum.html https://hexdocs.pm/elixir/Enum.html [2] https://hexdocs.pm/elixir/String.Chars.html https://hexdocs.pm/elixir/String.Chars.html [3] https://code.tutsplus.com/articles/polymorphism-with-protocols-in-elixir--cms-29081 https://code.tutsplus.com/articles/polymorphism-with-protoco...