kennethgoodman / rockstar_math

mathlib for rockstar language
2 stars 2 forks source link

Idiomatic/poetic version of the library #11

Open DavideFauri opened 6 years ago

DavideFauri commented 6 years ago

With the recent expansion in what the library can support, I personally think that it's time to start the talk on how to convert it to idiomatic. I don't know if the best way would be to create a separate idiomatic branch that mirrors master, or just put a math_idiomatic.rock file alongside the normal one. (Side note: this file should be tested as well)

Dylan himself gave us a starting point for the idiomatic version: My dreams were ice. A life unfulfilled; wakin' everybody up, taking booze and pills - initialises my dreams with the value 3.1415926535

I've been thinking about this, my humble opinion is that there should be at least a general "theme" to the words that we use for functions and variables: I've tried to go for the obvious math rock joke, but alas, that genre of music is mostly instrumental and it's difficult to take lyrics suggestions.

@kennethgoodman, do you have any particular idea/preference on that?

kennethgoodman commented 6 years ago

I think a math_idiomatic.rock is better because it keeps things all in one place. It should also be easier to test as we can test against the math.rock file that has the same limitations.

I've been thinking about this, my humble opinion is that there should be at least a general "theme" to the words that we use for functions and variables

Going to take a lot of work to maintain that if the project grows, but I am fine starting with a theme and if this happens to grow, we will become more flexible.

DavideFauri commented 6 years ago

I think a math_idiomatic.rock is better because it keeps things all in one place. It should also be easier to test as we can test against the math.rock file that has the same limitations.

Yeah, you're right. We can probably set up Travis so that it builds both the idiomatic and the non idiomatic files, and applies the same set of tests to both. In this way, we should be able to guarantee that there is a 1:1 correspondence.

Going to take a lot of work to maintain that if the project grows, but I am fine starting with a theme and if this happens to grow, we will become more flexible.

Sure! Although, I'm not really sure how much more the library can grow. I've tried to compare it to the math Python library, there's not that many functions that we still need to do: round(x), isclose(a,b), maybe atan2(y,x) and erf(x)... For other stuff we need to wait until arrays are defined.

kennethgoodman commented 6 years ago

Travis so that it builds both the idiomatic and the non idiomatic files ... guarantee that there is a 1:1 correspondence

That would be cool, not sure how to do that

there's not that many functions that we still need to do

This could grow into more advanced math functions:

For other stuff we need to wait until arrays are defined.

I think it would be fair to define arrays ourselves if we want to grow this project to cover a lot of what numpy/scipy covers. It would also allow us to write machine learning/stat analysis in Rockstar.

If the project ever defines arrays differently, we can just change that abstraction. Would need to edit the python transpiler. There are some suggestions: https://github.com/dylanbeattie/rockstar/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+array

kennethgoodman commented 6 years ago

A bit off topic but, could create other libraries that depend on Rockstar Math:

  1. NumRock
  2. SciRock
  3. RandomRock
  4. MachineLearningRock

The big missing pieces are arrays and some way to create a pseudo-random seed (maybe like time.time()). Once get those two working, there is so much that can be done. For now, a badly created RNG can be used with a seed needing to be specified.

Once Random Access Memory is added, I believe the language will be Turing Complete but will have to look through it more closely.

DavideFauri commented 6 years ago

Travis so that it builds both the idiomatic and the non idiomatic files ... guarantee that there is a 1:1 correspondence

That would be cool, not sure how to do that

Commit https://github.com/kennethgoodman/rockstar_math/commit/fb5ba1b0e635e126c907b022d850b5b40310de69 already implemented Travis integration: I can confirm that it works. A possible approach to dual testing would be to modify the test script: change all the tests so they take as input a function handle or a variable name imported from one of the two files, idiomatic and not. In this way, if we rename, say, the pi to my dreams we can do something like:

from mathrock import the_pi
from mathrock_idiomatic import my_dreams

def run_pi_test(variable):
     [...]

run_pi_test(the_pi)
run_pi_test(my_dreams)

This could grow into more advanced math functions: [...] I think it would be fair to define arrays ourselves if we want to grow this project to cover a lot of what numpy/scipy covers. It would also allow us to write machine learning/stat analysis in Rockstar.

I don't know... This has always been a joke project, there's other "real" languages if one wants to actually produce useful code. Personally, I think that the best strategy to let this library grow organically is to first publicize it a bit on the Discord channel, ask other people for collaboration/feedback, and figure out some nice example program where we make use of the library.

kennethgoodman commented 6 years ago

Agreed that it is a joke project, but that's what makes it fun to develop on. :)