News for hackers. Stuff that matters.
Re:Show HN: Visualizing 'Silhouettes' of Programming Languages by Stratoscope on Friday June 30, 2017 @04:47PM (#14673512)
This is fun and interesting, but I don't think it says much about the various languages. Each of these languages can be formatted in a variety of styles.

As one example, Rust, and especially Servo, began with a recommended (or mandated) style with a heavy use of column alignment for things like function arguments. Like this code from rustfmt:

    let mut rewrites = try_opt!(subexpr_list.iter()
                                            .rev()
                                            .map(|e| {
                                                rewrite_chain_expr(e,
                                                                   total_span,
                                                                   context,
                                                                   max_width,
                                                                   indent)
                                            })
                                            .collect::<Option<Vec<_>>>());
But the Rust example in the silhouette page doesn't follow this style at all. Instead, it uses a purely indentation-based style with little or no use of column alignment. From looking at the latest Rust coding style document, it seems that the Rust community may be moving away from this aligned style to an indented style. (Anyone who is more tuned into Rust style, feel free to set me straight.)

If the code above were written in an indented style it might look more like this:

    let mut rewrites = try_opt!(
        subexpr_list
            .iter()
            .rev()
            .map( |e| {
                rewrite_chain_expr( e, total_span, context, max_width, indent )
            })
            .collect::<Option<Vec<_>>>()
    );
Same language, same code, but a very different silhouette.

Similarly, the last time I looked at the Oculus SDK, its C++ and C# code used a column alignment style, and I think some other projects like OpenCV use column alignment too.

Many other C++ and C# projects eschew alignment in favor of indentation, though.

This kind of choice in styles is available in all the languages being compared. Yes, even in Python. The Python example uses column alignment here and there, but it would be just as "Pythonic" to use indentation in those places.

So I don't think this is really comparing programming languages, it's just taking a single example for each language, where other projects in the same language may have very different silhouettes.

Re:Show HN: Visualizing 'Silhouettes' of Programming Languages by steveklabnik on Friday June 30, 2017 @05:46PM (#14673779)
> (Anyone who is more tuned into Rust style, feel free to set me straight.)

Style team member here; you're absolutely right. We started with more visual indent but basically have switched entirely to block indent.

> it might look more like this:

This is how rustfmt would format this code, exactly.

Re:Show HN: Visualizing 'Silhouettes' of Programming Languages by z3t4 on Friday June 30, 2017 @05:08PM (#14673615)
im working on a auto formatting tool ... is there anyone here that enforce column alignment or have it in their style guide ?
Re:Show HN: Visualizing 'Silhouettes' of Programming Languages by OJFord on Saturday July 01, 2017 @05:12PM (#14679059)
For Rust? Are you aware of rustfmt?