Live data from Hacker News

Practicing Elixir or any programming language

ericdouglas.github.io

31–40 of 59 posts

Re: Practicing Elixir or any programming language

#32

Great article, thanks! I'm not an expert Alchemist by any means, but whenever I see a `cond`, I try to see if it can be refactored out using pattern matching (after I was picked up on the same thing during an interview!) defp formatted_hour("AM", "12"), do: "00" defp formatted_hour("AM", hours), do: hours defp formatted_hour("PM", "12"), do: "12" defp formatted_hour("PM", hours), do: 12 + String.to_integer(hours)

Pattern matching is awesome and we should make use of it whenever appropriate, but not every situation is appropriate. For instance, if your formatted_hour functions were larger, or shared some amount of code between them, then cond might be a great option instead. Or case, or even the dreaded if statement. As a community, sometimes we overuse our cool special features just because we have them! Personally, I like the case statement as a middle ground for lots of scenarios. You still get pattern matching and it's pretty readable.

Re: Practicing Elixir or any programming language

#33

How hard is it to design your page without javascript needing to be enabled? I now can't be bothered to see what you have to say. It is not worth my while.

That 'reveal' is definitely overkill - in a world where shaving off 10s of milliseconds in load time helps engagement, adding 100s of milliseconds of unnecessary pause before content does seem a little silly.

That said, 'has javascript' is a reasonable assumption for most websites these days. Most people outside the HackerNews echo chamber wouldn't dream of turning it off, but then I suppose this blog is aimed at the HackerNews audience (among others).

Re: Practicing Elixir or any programming language

#34
post #32

Great article, thanks! I'm not an expert Alchemist by any means, but whenever I see a `cond`, I try to see if it can be refactored out using pattern matching (after I was picked up on the same thing during an interview!) defp formatted_hour("AM", "12"), do: "00" defp formatted_hour("AM", hours), do: hours defp formatted_hour("PM", "12"), do: "12" defp formatted_hour("PM", hours), do: 12 + String.to_integer(hours)

Pattern matching is awesome and we should make use of it whenever appropriate, but not every situation is appropriate. For instance, if your formatted_hour functions were larger, or shared some amount of code between them, then cond might be a great option instead. Or case, or even the dreaded if statement. As a community, sometimes we overuse our cool special features just because we have them! Personally, I like th…

If the formatted_hour functions were larger or shared some amount of code, I wouldn't have suggested it ;)

Re: Practicing Elixir or any programming language

#35
post #13

I always find it interesting how people learn so differently. Personally, I learn a language by building something in it. I want a feel for it, before digging deep and learning about theory. I only do that stuff much later, after I'm relatively proficient in the language. This is probably why I wasn't very good at picking up musical instruments. I was never satisfied learning at a slow pace and only being able to pla…

I actually started the same way. In the article I focused more on step 4, but in step 2: "Familiarize with the syntax and semantic of the language" I watched a video course and built two mini projects.

To practice the language specifically though, coding challenges are pretty effective, funny and more focused IMO

Re: Practicing Elixir or any programming language

#36
post #27
post #13

I always find it interesting how people learn so differently. Personally, I learn a language by building something in it. I want a feel for it, before digging deep and learning about theory. I only do that stuff much later, after I'm relatively proficient in the language. This is probably why I wasn't very good at picking up musical instruments. I was never satisfied learning at a slow pace and only being able to pla…

Yes, I'm the same. With Ruby, I actually learned Rails first, and built a few apps with it (one of which is in production and going well). Then I went back and took the approach in this article to learn Ruby better. I still wouldn't call myself an idiomatic Ruby programmer, but I know enough to do any task I'm faced with without writing complete rubbish. With the little Elixir I've done I took the same approach: dive…

Very interesting.

The big point should be: do some practical stuff to keep you motivated while you are learning!

Re: Practicing Elixir or any programming language

#37
post #11

personally i think algorithm or hacker rank-like problems are probably a poor way to actually pick up a new language. pass one for me is usually "read all the books that are needed to cover the main parts of the language, toolchain, frameworks, idioms, etc and make sure to type in the code as you go." for elixir this means all the pragprog books and probably one book on OTP/beam. second pass is once that surface leve…

> "if you don't have the first part of dedicated learning and wide exposure (without a motivating problem per se) you inevitably end up doing the lazily evaluated "stack overflow driven development" since you haven't been exposed to the breadth of the language, frameworks, etc systematically. in other words, you don't know what you don't know."

Totally agree. I'm doing exactly this. But instead of only read books and type the code, I'm also after each section of the resource (doc || book), practicing code challenges :)

Re: Practicing Elixir or any programming language

#38

How hard is it to design your page without javascript needing to be enabled? I now can't be bothered to see what you have to say. It is not worth my while.

Many thanks for your comment. You are totally right.

This is a theme from the Hexo platform I use.

I'll probably create a theme to address this and other issues.

Re: Practicing Elixir or any programming language

#39
post #33

How hard is it to design your page without javascript needing to be enabled? I now can't be bothered to see what you have to say. It is not worth my while.

That 'reveal' is definitely overkill - in a world where shaving off 10s of milliseconds in load time helps engagement, adding 100s of milliseconds of unnecessary pause before content does seem a little silly. That said, 'has javascript' is a reasonable assumption for most websites these days. Most people outside the HackerNews echo chamber wouldn't dream of turning it off, but then I suppose this blog is aimed at the…

Thanks for your comment. I'll fix this.
Post reply on HN