Hacker News new | ask | show | jobs
by nickjj 1427 days ago
This is very true but there's still is a very big difference between knowing languages like JS, Python, Ruby or Go but then jumping into a place that uses Elixir or a niche language that's different than a lot of other popular languages.

For example I took a position to do mostly infrastructure work. Most of their services are written in PHP which I haven't used since the early 2000s. I wouldn't classify myself as a PHP developer. Sometimes I find myself diving into the code to self-solve issues I have that are infrastructure related. My thought process is if I can solve a problem and it's within my scope of things to do I'd much rather just do it than add extra work to another developer on the team. In the worst case scenario someone with actual PHP experience who does the code review will offer suggestions to make the code better.

I don't really know PHP but I can look around and navigate the code without issues. There's nothing that looks too foreign and the code is easy to grep to find stuff. It's also not too bad to trace code in a large app and understand the logic. There's also a massive amount of Google results for almost any problem you can think of. It really means for a lot of cases you can combine previous experience and be productive in a similar language without really knowing it. Enough to contribute real code that gets shipped to production.

I ended up doing this yesterday where I added an IP whitelist address exempt config option to one of our apps. I wanted to at least toy with the idea of doing IP range detection within a CIDR block.

In Python this is really easy, the standard library has functions to do this with 1 line of code. Ruby's implementation is even easier and built into the language. For PHP I had to Google around but found a pretty small custom function to use in less than 2 minutes. For Elixir? Well you have to use a 4 year old+ third party dependency or dive down into Erlang and understand pattern matching and write a bunch of code to manually do the comparisons. Maybe there's a good Elixir solution but it wasn't on the first 3 pages of Google when searching for similar terms as I did for Python, Ruby and PHP. Weirdly enough if you search for "elixir check if ip address is in cidr block range" most of the top results are StackOverflow posts for other languages. There's no contest in comparing the amount of effort it took to get a solution.

I know this is 1 just example but I also know when I tried learning Elixir (and did end up writing about 10k lines of code of it) I kept running into situations that took half a day or longer to figure out while actively trying hard to learn and use the language. These problem could be fully solved in a production ready way in 5-10 minutes with Python or Ruby (and I guess PHP too) either by knowing how to solve it in an imperative way or finding nearly a perfect solution when Googling that's digestible enough to where you can fully understand it and apply it back to your problem.

2 comments

> For Elixir? Well you have to use a 4 year old+ third party dependency

Can we please stop using “4 year old+” as a generally applicable rule to reject libraries?

I know “4 year old” seems like forever ago in Ruby or Node (I can’t talk about Python or PHP), but other ecosystems such as Go and Elixir take compatibility seriously and “4 year old” libraries most often just mean they are done: they work for their intended purposes and there are no breaking changes in the language or tooling forcing frivolous updates.

I have used 8 year old Erlang libraries in the past with no issues whatsoever.

Did you try asking on the forums?

https://hexdocs.pm/net_address/IP.Subnet.html

> Did you try asking on the forums?

Nope, I only looked up the Elixir solution for the sake of my reply here. I haven't worked with Elixir in like 9 months.

Based on the docs it says IP.Subnet.is_in only supports IPv4. The Python and Ruby solutions transparently support both. That kind of sums up my Elixir experience (ie. something might partially exist but to really use it will require a lot of extra work). It's also impressive at how infrequently the Elixir docs come up in Google searches. It's strange considering how many words are there and it's the official source of information for the language.

IP.subnet.is_in is a guard, so there are different constraints. You could still use the `in` keyword.

Honestly my experience with python has been "the solution you're looking for probably exists, but using it will require a lot of effort, and heaven help you if you need to debug someone else's code", but I have mostly dealt with Django which is a nightmare of hidden code and tensorflow. Maybe it's just I've worked with shitty python devs and on the other project Google's notoriously bad engineering practices in some of their public facing OS projects (angular, tf)

> IP.subnet.is_in is a guard, so there are different constraints. You could still use the `in` keyword.

Does that mean you can do something to make it transparently support IPv4 and IPv6 even though the docs mentions it only supports IPv4? Will it be more than 1 line of code?

> Honestly my experience with python has been "the solution you're looking for probably exists, but using it will require a lot of effort..."

I found it to be the opposite approach. The last time I wanted to increment a counter outside of a nested loop in Elixir it sprawled into a multi-week conversation with the author of Elixir, a git repo with 100+ programming language examples to solve the same problem[0] and a proposal on potentially altering Elixir itself to make this process a bit easier. The Python solution was about 2 minutes typing into my code editor and moving on with life.

Elixir solution: https://github.com/nickjj/nested-data-structure-traversal/bl...

Python solution: https://github.com/nickjj/nested-data-structure-traversal/bl...

I'm not saying either language is better than the other but there's certain things that can done a lot easier in Python and on the flip side I'm sure there's things you can do a lot easier in Elixir.

I found in practice for me personally when building typical web apps I kept running into roadblocks left and right with Elixir where as I never had these issues with Python or Ruby. That's why I stopped using Elixir.

> I have mostly dealt with Django which is a nightmare of hidden code

I think that'll happen with any big framework, especially if you haven't contributed a ton of code to it. The Rails code base can be intimidating too and Phoenix's code isn't any more approachable to someone who isn't already at the high end of expert with the language.

[0]: https://github.com/nickjj/nested-data-structure-traversal

I mean to be quite honest I remember this problem and all I could think of was "this being hard is a sign that the data structure is poorly designed. But I also remember giving you a four line code sample using the process dictionary that you could have used, because this was "clearly an exceptionally pathologic data structure".
Oh yeah I remember your reply (not word for word but the approach of using it). If you search around for using process dictionary it seems to go against the grain of Elixir since it introduces mutable state which is fundamentally against what the language provides. It did lead to much easier to understand code because it brings the language more in line with how other languages work where you can update a variable outside of a specific scope. Maybe it's a good example of the idea of "sharp knives" but applied to Elixir instead of Ruby.

I don't think the data structure was that crazy or rare. It boiled down to looping over 2 lists and wanting to keep an independent count of each one.