Skip to content

parallel-letter-frequency: add exercise #238

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

Closed
wants to merge 1 commit into from

Conversation

ErikSchierboom
Copy link
Member

No description provided.

"name": "Parallel Letter Frequency",
"uuid": "9ba6a56b-77bb-494b-88c2-0b751a1f66a9",
"practices": [
"async",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what we want to call this concept?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Processes or actors or OTP perhaps.

Comment on lines +1 to +6
# Instructions append

## Using Gleam OPT

To compute the letter frequencies in parallel, you can use the [gleam_otp library](https://hexdocs.pm/gleam_otp/).
This library is built to be compatible with Erlang's OTP actor framework and has many concurrency-related features.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to improve this text. I've added this to point students in the right direction.

[dependencies]
gleam_stdlib = "~> 0.26"
gleam_bitwise = "~> 1.2"
gleam_otp = "~> 0.5"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a new dependency. If we're fine with that, I can add it to the test runner.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer not to add this one, it is very rough and ready, lacks docs, and likely will undergo various breaking changes. I think it would be a frustrating experience for the student and not show the language in a good light to present this up front.

@jiegillet
Copy link
Contributor

This exercise doesn't have canonical data right?
I have the same concerns as for #223 and I would love to take the opportunity to add some data to the problem-specs repo before merging this.

@ErikSchierboom
Copy link
Member Author

I would love to take the opportunity to add some data to the problem-specs repo before merging this.

It would be great to do that, but honestly I don't see the need for it happening before this PR could be merged.
There is no tangible benefit to this exercise to add test data 🤷

@ErikSchierboom
Copy link
Member Author

Just to be clear: I agree that adding canonical data would be great! I just feel like that should be a separate thing and not block this. I'll work on a prob-specs PR.

@ErikSchierboom
Copy link
Member Author

[dependencies]
gleam_stdlib = "~> 0.26"
gleam_bitwise = "~> 1.2"
gleam_otp = "~> 0.5"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer not to add this one, it is very rough and ready, lacks docs, and likely will undergo various breaking changes. I think it would be a frustrating experience for the student and not show the language in a good light to present this up front.

pub fn calculate_frequencies(texts: List(String)) -> Map(String, Int) {
texts
|> list.map(calculate_frequency)
|> list.map(task.await(_, 100))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a common pitfall: Waiting on tasks like this will potentially wait 0.1 * len(texts) seconds rather than 0.1 seconds.

An await_many is desired here, though one does not exist in the library yet.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An await_many is desired here, though one does not exist in the library yet.

Yeah, I was looking for one but didn't find it.

"name": "Parallel Letter Frequency",
"uuid": "9ba6a56b-77bb-494b-88c2-0b751a1f66a9",
"practices": [
"async",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Processes or actors or OTP perhaps.

@ErikSchierboom
Copy link
Member Author

I would prefer not to add this one, it is very rough and ready, lacks docs, and likely will undergo various breaking changes. I think it would be a frustrating experience for the student and not show the language in a good light to present this up front.

Would it then make sense to wait with merging this PR until async functionality is properly supported? I could convert this to a draft PR.

@ErikSchierboom
Copy link
Member Author

Or maybe close it for now?

@lpil
Copy link
Member

lpil commented Feb 25, 2023

Unfortunately I think it's best to delay this exercise. It's a nice one for showing the strengths of Gleam but the UX of learning that side of Gleam is really very poor at the moment.

@ErikSchierboom
Copy link
Member Author

Sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants