from Hacker News

Getting started with Rust by building a tiny Markdown compiler

by jesselawson on 5/16/20, 7:51 PM with 34 comments

  • by AlchemistCamp on 5/16/20, 9:08 PM

    I'm not completly new to Rust, but for some reason writing a Markdown has become a routine project I do in every language I'm learning.

    This tutorial looks fantastic. Is the layout based on a 3rd-party theme or template? I really like the presentation.

  • by berkus on 5/21/20, 10:59 AM

    Hmm, I see the author liberally using _filename as a variable name saying "I just use names with underscores as functions arguments names".

    However: In Rust, variables starting with underscores are usually indicating unused ids and if you actually forget to use it - you will not get a warning. As a tutorial material this sets very wrong mindset for the beginners. ONLY start variable with an underscore if you mean to not use it.

    @jesselawson - please update this.

  • by gilmi on 5/17/20, 4:44 AM

    I think the author did a great job with the format of this tutorial!

    It includes all the steps needed to write the app, has exercises, is neatly splitted to chapters with clear expectations and summaries for each chapter and so on. Everything needed to reduce frustration, maximize knowledge retention, and make it a nice experience as possible to the reader. Awesome work!

  • by einpoklum on 5/16/20, 9:44 PM

    1. This is more of a "taste-teaser" than a tutorial in my opinion, but it's nice enough I guess.

    2. Perhaps a different page for each chapter/part would have been nice.

    3. I wonder how different would a C++ "taste-teaser" with the same scope and goal be.

    4. I'm not a Rustian (Rustic? Rust-guy?); this seems strange to me:

        // Try to open the file
        let file = File::open(&input_filename)
                        .expect("[ ERROR ] Failed to open file!");
    
    why am I expecting an error? Shouldn't that keyword be "on_exception" or something?
  • by greglindahl on 5/16/20, 10:01 PM

    I'm a bit confused by the use of the word "compiler" to refer to something that turns markdown into html.
  • by mrlonglong on 5/17/20, 3:14 AM

    I tried Rustlings, found it a wee bit too easy to do, but I'm not quite finished yet.
  • by Lapland on 5/17/20, 3:57 PM

    Looks great, thanks for creating this!