News for hackers. Stuff that matters.
Re:Elixir v1.4.0 released by transfire on Wednesday January 04, 2017 @09:08PM (#13324111)
> [Kernel] Deprecate support for making private functions overridable. Overridable functions must always be public as they must be contracts

Just lost interest. I thought Elixir was supposed to learn from Ruby.

Re:Elixir v1.4.0 released by josevalim on Thursday January 05, 2017 @04:32AM (#13325900)
Can you please expand on this a bit? Your comment is very vague.

The comparison with Ruby here doesn't make much sense because private means different things in both languages and Elixir does not have inheritance.

Re:Elixir v1.4.0 released by brightball on Wednesday January 04, 2017 @10:57PM (#13324600)
Personally, I've never seen the value in private functions in the real world. If you are in the same runtime and can see the code, what exactly does a private function offer you other than ensuring somebody has to duplicate the method to manipulate it.

Professionally I've never seen a private function/method that had a purpose or benefit from being private.

Re:Elixir v1.4.0 released by _asummers on Thursday January 05, 2017 @12:17AM (#13324954)
In Elixir especially, with everything being immutable, I don't really have to worry about state hanging around for my private methods to care about. I wind up just throwing private functions into little helper modules that can be tested independently.

As far as benefit of something being private, an API does not have to be maintained if it is private. Once it's out there, you're locked into doing that for the duration of your deprecation window.

Re:Elixir v1.4.0 released by preordained on Thursday January 05, 2017 @12:21AM (#13324967)
There are plenty of times. Take a data structure like a hashmap. You know there are plenty of internal functions to manage the map (rehash, handle collisions...) that there is no reason for a hashmap end user to see or even be tempted to muck with. Now, you can could make a new class as an interface to this hashmap with only the appropriate exposed methods...but that seems like an excessive sort of pattern.

In a statically typed language like Java, etc., it also gives you the benefit that when you are auto-completing or discovering methods, you see only the exposed methods you are meant to call as an API user instead of poring over every two-line helper method in the class.

Re:Elixir v1.4.0 released by true_religion on Thursday January 05, 2017 @02:08AM (#13325332)
When I subclass hashmap, I may desperately want to reimplement collision handling without also having to rewrite the every other private function it calls. Private functions close the library off to custom extension.
Re:Elixir v1.4.0 released by mkarklins on Thursday January 05, 2017 @04:35AM (#13325910)
... and keeps the library's updates smoother, since there can't be any tinkering with library's implementation.
Re:Elixir v1.4.0 released by true_religion on Friday January 06, 2017 @12:32PM (#13338225)
You don't have to support users who use your library internals. Django for instance didn't support everyone who relied on undocumented internals in its orm. The standardization for the latest release made those internals clean and documented, but unapologetically broke other people's code including mine.
Re:Elixir v1.4.0 released by barrkel on Thursday January 05, 2017 @05:45AM (#13326142)
Private functions permit functional decomposition without a commitment to support the interface implemented by the private functions (meaning the functions can be changed / refactored without breaking clients of the library).
Re:Elixir v1.4.0 released by swsieber on Thursday January 05, 2017 @12:20AM (#13324962)
They seem quite useful. Mostly signaling that things should not be used.

What's the largest number of people you've workwe with on a codebase? I would assume the benefits aren't really all that much for small codebases / teams.

Re:Elixir v1.4.0 released by brightball on Thursday January 05, 2017 @08:29AM (#13326925)
On a single code base, the most I've worked with at a time is 12.
Re:Elixir v1.4.0 released by ramchip on Thursday January 05, 2017 @06:59AM (#13326438)
Private (a.k.a. non-exported) functions affect how the compiler optimizes code, at least around inlining.
Re:Elixir v1.4.0 released by jkmcf on Wednesday January 04, 2017 @09:57PM (#13324338)
You'd think they'd learn from Java!

Edit: Not a shallow dig, but I had lots of fun using a 3rd party library that had locked down a lot of methods which prevented some sales driven features...

Re:Elixir v1.4.0 released by int_19h on Thursday January 05, 2017 @03:13AM (#13325587)
A function being overridable is a part of the contract, because other functions may rely on it. If you can override truly private stuff, you have no idea about the invariants that you need to uphold to do that correctly.
Re:Elixir v1.4.0 released by sch1zo on Thursday January 05, 2017 @03:17AM (#13325602)
Am I misunderstanding this or what do you mean learn from ruby? In Ruby I can override private methods without a problem.
Re:Elixir v1.4.0 released by pmontra on Thursday January 05, 2017 @07:20AM (#13326545)
Ruby doesn't have private methods. You can always object.send(:method) and the only effect of the private keyword is to disable the object.method() syntactic sugar. No wonder that even methods marked as private can be redefined.