exercism / r

Exercism exercises in R.
https://exercism.org/tracks/r
MIT License
26 stars 38 forks source link

Supporting #48in24? #302

Open colinleach opened 8 months ago

colinleach commented 8 months ago

Would it be best to assume that @jonmcalder is going to be too busy to engage much with this?

I'm currently working with Bethany to add approaches to the Python track (only 118 more to go!). I may also be able to do some R versions in parallel, but that is only really worthwhile if they can be PR'd, reviewed and merged before the week when that exercise is featured.

We're off to a bad start with exercises. The R track has leap (week of Jan 16) but is missing reverse-string (week of Jan 23). We would have to start by adding the Practice Exercise.

jonmcalder commented 8 months ago

I''ll do my best to prioritise stuff for #48in24

I've started working on adding (the beginnings of) approaches for leap so will open a PR for that.

colinleach commented 8 months ago

Wow, that's great, and not what I was expecting!

There's no need to start from scratch on these approaches. Erik has a GIST with all the exercises (ordered by # tracks implementing them), together with which tracks already published approaches. A copy-paste-edit approach is encouraged, to migrate these to other languages. Jeremy was talking about this on yesterday's community call - he's looking into getting ChatGPT to help, but that may need to wait till v4 allows training on our own data (expected in the next month or two, only v3.5 has this at the moment).

C# can be a good track to copy from, because Erik probably wrote the documents. Most of the other tracks have stuff that bobahop wrote in an intense burst a few years ago, so tend to be quite similar.

There is also a forum post for each chosen exercise: leap and reverse-string. Others will follow once a decision is made about what/when: forum post. I'm sure Bob will be high on the list, because Jeremy likes it. Erik posted a longer list, which will surely be influential. We really, really hope that this gets sorted out soon for February and preferably March, and they don't keep dropping stuff on us at 2 weeks notice.

The python/leap approaches have been updated in the last couple of days: PR #3583. Bethany is reviewing it and hopes to merge in the next day or so. We added a bunch of performance stuff, but for r/leap this is probably far more trouble than it's worth: all the approaches are "good-enough", and 2-fold differences in run time are pretty boring. Benchmarks can be much more interesting for other exercises: Pythagorean Triplets is an extreme example.

I'll put together a PR for a new Reverse String exercise over the next few days. If that works out and gets merged, we can add approaches as a later step.

Going forward, I'll be doing quite a few Python approaches throughout the year, so I'll try to do an R version around the same time. I'll try to work in some benchmarking, where appropriate. Would you recommend the microbenchmark library for this, or do you know of something better?

jonmcalder commented 8 months ago

Yes I've been following the relevant forum posts the past few days (but thanks for mentioning them anyway).

I'm basing the R approaches for leap on the python ones (and that includes your PR updating these which I had already referred to as well - thanks!)

I wasn't planning on including a performance article (probably not worth the effort to include in a hurry) as this can always be added later.

I'd recommend that we use {bench} for that since I think it's slightly newer and better than {microbenchmark}.

Thanks in advance for your assistance! Will keep an eye out for your PR to add reverse-string.

colinleach commented 8 months ago

Looking ahead, in an idle moment, I checked which of the exercises already being recommended for future inclusion in #48in24 are missing from the R track. This is a rough list:

I've excluded linked-list and parallel-letter-frequency, which Bethany already vetoed for Python and also look unsuited to R.

If I get some free time in the next several weeks, I may draft a few of these as new exercises for R - I like the top 4 on that list. If I do, what's your preference:

colinleach commented 8 months ago

To preempt any future discussion (which Jeremy and Erik keep encouraging: I Don't Make Videos!

Please regard that as one of the fundamental laws of nature, as invariant as the speed of light.

jonmcalder commented 8 months ago

Happy for you to open PR's for practice exercises if and when you work on them.

One thing I would note though, is that for the more complex exercises there might be more implementation choices involved (e.g. deciding on what atomic data types to use for inputs & outputs and/or whether to require an OO approach in some cases).

I'm not familiar with all of these exercises, but the first 4 on that list look fine with respect to the above I think? Though for robot-simulator while one could just have standalone functions it might make sense to use S3?

In general, I think if we want to use OO then it should probably be S3, though R6 might make sense for certain problems depending on the problem characteristics and/or learning objectives - see here for more on trade-offs.

colinleach commented 8 months ago

I think if we want to use OO then it should probably be S3

I'm the amateur at R, I totally defer to your preferences. (I would be more assertive in Python)

In general, my first priority with the example.R is to make sure the tests all work correctly. Obviously, I'll try to do a decent job, but it's fine if you replace it with something better. Then we have multiple implementations to discuss in the approaches PR later.

jonmcalder commented 8 months ago

Ok cool - but it's not so much the example.R implementation that I'm referring to (although that is of course impacted by other implementation details).

The reason I bring this up is because the way one chooses to implement the exercise (the data types / object types etc) determines the tests (i.e. the functions / interface and what output type / structure is checked, so that is a design choice for the exercise itself which limits the scope of allowed implementations.

colinleach commented 8 months ago

Point taken. I tripped over this issue a couple of times before.

colinleach commented 7 months ago

Now we have an official timetable for #48in24, I made a Google Sheet of which exercises are implemented in a few languages that I like (an entirely personal and subjective choice, though of course Python, R and Julia are on there).

I see R is a highlighted language for raindrops (week 3), the exercise which Erik talked about in the Brief Intro to R video last year. What do you want to do about Approaches? I could create something if you don't have time, but you might prefer to do it yourself?

After that, roman-numerals is missing from the R track. I'm currently writing approaches for Python, so I could create the exercise in R if you think it's worth it. It would be a struggle to find a distinctive approach to show off R capabilities: most solutions are based on a while loop.

protein-translation in week 5 is more promising, as that might lend itself well to vector processing. I'll take a look at it.

Far ahead, all-your-base is coming up in mid-April. There's a closed PR #247 for this that may be worth reopening sometime?

jonmcalder commented 7 months ago

Thanks so much for picking up on this (again) and planning ahead!

I think I'm happy to work on approaches for raindrops.

Please could you work on adding roman-numerals and protein-translation (or only the latter if the first one doesn't seem viable but I think it's worth a try if you're up for it).

I've re-opened your PR for all-your-base and will review in due course (no rush as you say).

(and thanks also for the reverse-string PR, I'll get onto that ASAP)

Nerwosolek commented 7 months ago

To keep track of the progress:

Nerwosolek commented 7 months ago

So what's next? I would prefer doing robot-simulator right now. Or is it anything I can help with protein-translation? It's for week 5 and haven't been merged yet.

colinleach commented 7 months ago

Doing robot-simulator seems a good idea.

There's not much you can do with protein-translation, because the exercise is finished and just needs a track maintainer to review it - meaning in this case Jon, who is overloaded.

In an emergency we could get ErikSchierboom to review stuff, but (as one of the 3 employees) he runs most of Exercism and is just as busy.

jonmcalder commented 7 months ago

As I alluded to earlier in this thread, I think that robot-simulator calls for an object-oriented implementation using S3. It doesn't have to be done that way but it would be my preference. I'm of course open to debate if you want to suggest how you would implement it without defining a class (e.g. a generic vector, list or data.frame that stores the coordinates and direction of the robot), but I think this exercise is a natural candidate for OO.

@Nerwosolek you're welcome to work on a PR for that if you're comfortable with what I mean above re the design of the exercise (or even if you don't know but still really want to work on it and get support from us to do it)

Otherwise it might be better if we find you a different exercise to work on next (I don't mean to sound condescending, just have no idea what your R background is).

And again, I haven't forgotten about protein-translation - will aim to review later this evening or sometime this weekend.

Nerwosolek commented 7 months ago

I'll take the challenge! I understand how in general S3 system works but did not yet implement any, so it will be good way to learn. I promise think twice than implement to save your time as much as possible.

jonmcalder commented 7 months ago

Ok great - feel free to go for it then.

The only practice exercise I can refer you to as an example of an S3 implementation is triangle and it's super basic (but maybe still useful to refer to see the test implementation).

As general reference material (if needed) I'd recommend this chapter of Advanced R.

My suggestion is that you have a go, create the PR, and then we can facilitate any follow-up and discussion via the PR itself rather than here so that this issue can be kept focussed on co-ordinating our efforts on #48in24.

Thanks again for your willingness to help!