-
-
Notifications
You must be signed in to change notification settings - Fork 554
Language-specific exercises #352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Go for it. |
Okay cool! |
As an aside (no action is required from this comment), the lens exercise is no longer Haskell-specific. Scala has a implementation too, which may be amusingly confusing because the metadata.yml still says "(Haskell-specific)", so seeing that in the list of Scala exercises may give a student pause. Actually, maybe there is an action to be taken here... remove "Haskell specific" from lens-person. Maybe "Functional programming language specific" I do want to ask whether an F#-specific exercise ever materialised, but I think I would have seen an x-common PR if it did, so I have to assume no. I'm asking because the Rust track is now discussing some exercises that only make sense for it, since they extend an exercise (Luhn) with Rust-specific features (traits). |
I do not think that "traits" are specific to rust, but maybe named differently in other languages. As I do understand them, they are similar to Haskells classes, Elixirs protocols. Someone else told me, that rusts traits are even inspired by scalas traits. |
You have caught me exaggerating! I should not make such bold claims of uniqueness. I guess the question that should be asked is - would other languages want to have the metadata for this new Luhn-based exercise in x-common? If yes, then maybe we will just add it to x-common! If no, then for now it is as if it were a language-specific exercise, if only the Rust track is interested in it. Let's explain what the Rust proposals are, so that other languages can determine whether they are interested in them. There are two proposals in the Rust track (exercism/rust#248), which both use Rust traits but, off the top of my head, admit the following possibilities in other languages:
So, many languages support these features and could ostensibly make the same exercise as those proposed. Would they want to apply these exact techniques to the Luhn exercise in particular I don't know, but we can discuss the right way. Aside: I didn't realize until doing research for the above that Rust supports UFCS, but I guess it's logical that it does... please feel free to point out other languages with UFCS since I'm interested in language features. |
@petertseng said:
There are no F# specific exercises today, however, I'm not sure if any have been suggested in the past. @ErikSchierboom keep me honest here :) |
This is just an implementation detail, which again is totally in the hand of the implementing track. BUT! As you are already said elsewhere:
THIS is the important and interesting part of your post. And let me rephrase it: Can we extend the canonical tests in a way, that they allow optional generalisation over types? |
This is less about Luhn and more about a way to use the Rust exercises to teach Rust concepts. Luhn just seemed like a good candidate. The idea is:
Other exercises could do similar things with whatever exercises fit their needs. Since these type of exercises will be specific to the language track, it seems to me that it's better to not have to rely on the existence of metadata. |
This has been a long-standing question, and I've not come up with a good solution yet, instead only leaving notes in the JSON files: https://github.com/exercism/x-common/blob/master/exercises/react/canonical-data.json#L38 and https://github.com/exercism/x-common/blob/master/exercises/circular-buffer/canonical-data.json#L20 . One thing I was wondering is whether it would be made unnecessarily difficult for statically typed languages to read the JSON file if in one case the values are strings and in the other case the values are integers, for example. We may not know this until some track runs into it, so I've only left it at that for now, but in the future we may have to discuss it more, perhaps when dealing with #336. |
Strict typing is a very language dependent concept, so I would argue that it does not belong in the canonical-data and should instead be dealt with some other way. |
I'm with @Insti. The canonical-data should be language independent. If a language track decides to add some additional type-related features to an exercise, why not? However, this should not be reflected in the canonical-data IMHO, unless it is a feature shared by several languages and we can make a dedicated exercise for it. |
I'd suggest that type handling should be its own exercise(s) and question whether it needs to be included in any other exercise. If the exercise is about validating a number it surely doesn't make much difference algorithmically if the number is an integer or a string or some other specific type. And if we're:
Then it doesn't matter what the domain logic component is. |
At the time it was added (#97), indeed [Haskell][haskell] was the only implementing track, and it was marked Haskell-specific. However, the [Scala][scala] track has also implemented this exercise. I predict it is confusing for Scala students to see "Haskell specific" in the list of the Scala exercises. The proposal is to change it to "specific to languages with immutable data". [haskell]: exercism/haskell#84 [scala]: exercism/scala#157 Lenses can be a fit for any language that has immutable data and data structures that can be nested. In such a language, updating a deeply-nested field can be a lot of work, but made easier with lenses. This exercise demonstrates the use of lenses and is applicable to **any** language with immutable data, not just Haskell. The alternative considered was to use "functional programming" specific, but the term "functional programming" is a little too broad. It's altogether possible that a functional programming language could have mutable data and a non-functional programming language could have immutable data, so let's be precise about where lenses are helpful. As of this writing, I do not believe any other exercise is language-specific. Questions to this effect have been asked in: * #352 * exercism/exercism#3113 If you are curious about having language-specific exercises, you may be interested in exercism/DEPRECATED.trackler#22.
I'm not convinced there is much left to discuss here about language-specific exercises.
|
Notice to all track maintainers: With exercism/DEPRECATED.trackler#24, it is now possible to have track-specific exercises. Place the description.md and metadata.yml inside the exercise directory inside your track. I recommend that this be documented. |
(I'm documenting it, btw) |
@IanWhitney Great! |
Where can I find the documentation for this? |
@IanWhitney Where's the documentation for this? |
At the moment, there are a couple of exercises that are only relevant to one language. The best example is probably the
lens-person
exercise, which is only relevant to Haskell. Is having a language-specific exercise something that is considered good practice, or should we shy away from it? I ask this because F# has a very cool feature namedcomputation expressions
and I was wondering if I could make an exercise for that feature.The text was updated successfully, but these errors were encountered: