Live data from Hacker News

Ask HN: What is the coding exercise you use to explore a new language?

news.ycombinator.com

21–30 of 73 posts

Re: Ask HN: What is the coding exercise you use to explore a new language?

#21
Thanks for all the comments. Just to clarify, not really asking how to learn a specific language or how to code. Question is more if one were doing a survey of various languages to understand disadvantages/advantages of each and for a general working knowledge, what's a good relatively quick baseline exercise to do that comparison ?

Re: Ask HN: What is the coding exercise you use to explore a new language?

#23
I typically write a raytracer while attempting to stick to a small set of "best-practices" for the language I'm trying to learn. I also use this exercise from time-to-time to test new language features (for example C++20 ranges/coroutines recently).

I also recommend this same exercise to others through the book "The Ray Tracer Challenge" [1] by Jamis Buck, because it describes an entire implementation of a raytracer in pseudocode. Beginners mostly just need to plug-in their language of choice & still end up with a satisfying visual result. Experienced programmers can extend it by adding the ability to load non-trivial .obj models, which will necessarily motivate adding concurrency, bounding volumes, & other general performance improvements.

I'm planning on tackling it again in Elixir soon, which should be fun & interesting.

EDIT: Almost forgot to mention the free bonus chapters [2] that get you started on bounding volumes (AABB), soft area lights, and texture mapping.

[1] https://pragprog.com/titles/jbtracer/the-ray-tracer-challeng...

[2] http://www.raytracerchallenge.com/#bonus

Re: Ask HN: What is the coding exercise you use to explore a new language?

#24
Meta-answer: I like to pick a project I wouldn't mind doing a 2–3 times in that language. It's hard to learn all the best practices, idioms, etc. of a language in one sweep. Having a project that you can repeatedly do in X language—making it more "X-like" each time—is a good way to learn how to refactor things and structure things "natively" in language X.

Re: Ask HN: What is the coding exercise you use to explore a new language?

#26
post #23

I typically write a raytracer while attempting to stick to a small set of "best-practices" for the language I'm trying to learn. I also use this exercise from time-to-time to test new language features (for example C++20 ranges/coroutines recently). I also recommend this same exercise to others through the book "The Ray Tracer Challenge" [1] by Jamis Buck, because it describes an entire implementation of a raytracer…

Wow. That looks really cool.

Re: Ask HN: What is the coding exercise you use to explore a new language?

#27
Depends on the language.

Python has been stuff like Pi hats with sensors, or using Pandas to analyze VAERS or Kaggle data. I assume this is similar for other scripting or backend languages/projects.

UI could be something like using Angular to build a simple site, or Android to build a simple app.

Basically find something that's simple and functionally similar to what you think you want to achieve with the language. At least for me, I want to learn a language to use it on a project, not just learn it for the sake of learning it.

Re: Ask HN: What is the coding exercise you use to explore a new language?

#28

I commonly build a name generator based on travesties or Markov chains. I can write a simple version of it in a few minutes in a familiar language, but it exercises file IO, some simple data structures, string operations, and some randomization. Gives me a good first general idea of what it will be like to work with a new language.

That's very helpful, close to what I was envisioning. Thank you.

Re: Ask HN: What is the coding exercise you use to explore a new language?

#29
I try to write a guest book.

This way I can see how to input data, display it and how I can operate with the database.

It's simple.

Sadly for Rust and MongoDB I tried that 5 times and never got to the point that it compiles. It just wasn't intuitive and the error messages didn't make sense. For Rust also I went through the tutorial, because I really wanted to like it and switch to it, but compared to Go it was just too complicated. I didn't understand the game, boxes ownership move unpack... it all didn't make sense . I digress but yeah, a guestbook is usually my 1st application.

Post reply on HN