sashaafm / exads

Algorithms and Data Structures collection in Elixir
83 stars 12 forks source link

BSTs on Tuples #7

Open ramonsnir opened 8 years ago

ramonsnir commented 8 years ago

I saw in the README that you'd like to support BSTs that are implemented using tuples. I'd like to take a hit at that, as an easy PR, but have some questions on how you thought to do it:

  1. Is that actually needed? Does that add performance or functionality?
  2. Should there be a common protocol for both?
  3. Why a tuple, and not a record?
  4. Should the existing BST module be renamed: leaving the original module, while keeping the same public backwards-compatible interface, also to supports tuple BSTs?
NobbZ commented 8 years ago

As far as I understood @sashaafm on this, the difference was more for a learning than practical purpose.

We are already in an internal discussion if we should change to structs for everything to be able to be more in the elixir style of doing things.

Also structs would give further benefits that we can't get by using tuples, tagged or not, like beeing able to implement protocols and such.

Also there is a discussion which of the protocols we can und which we should use. After we have settled a bit, I think we will publish for further discussion with the community.

But to answer your remaining questions:

at 2. Of course there should, if we stick with the idea of having different versions of the BST. at 3. Because a record is only some syntactic sugar ontop of a tuple with a lot less control, but a lot less verbose I have to admit. at 4. Can we leave this question open for now until other things have settled a bit?

sashaafm commented 8 years ago

Hello @ramonsnir, like @NobbZ said it was more for exploration and learning, there's still a lot that's not set in stone and I'm open to discussion and suggestion (this is a group project, I don't want to be seen as the "boss" :) ). Tuples won't give much of a performance or other benefits that structs can. It's important for the project to conform to the Elixir way of doing things.

Like Norbert said, we may leave this question open and come to it later until we've decided more carefully on what should be done, but thank you for the initiative and if it goes forward you may work on it :+1:

EDIT: I wanted to add that the algos and data structures in the README are not final. They're just a guideline to the kind of stuff I thought should be in a project when I first came up with it. For all I know in the future, if it really takes off, we may even expand to work on a mathematical library or other common libraries.