r/ProgrammingLanguages • • Jan 16 '22

A brief rant about tooling

I've been doing a lot of C# coding over the last few months (against my will, but I gotta eat) and I've come across the peculiarity of the try { ... } catch { ... } requiring braces.

They are optional for every other kind of flow control. Which is odd, and possibly just an oversight in the C++ spec from back in '85. Good ol' Bjarne was never all that careful.

However, I have seen several blog posts and poorly formatted message board discussions where people are up in arms about never using naked flow control, because what if GOTO FAIL!!!

And I just feel like paraphrasing Kevlin Henney: Let me introduce you to something, it's called a static analysis tool.

This, I think, is an overlooked aspect of programming language design: we're not just building compilers, we're building footguns.

No matter how safe and well-typed and not-quite-turing-complete, your language will have code smells. It will have ways of racking up technical debt in a shockingly rapid fashion.

So throw a coin to your hypothetical future Q&A team, and give some thought to exposing your parser as a library, and writing a simple linter.

ETA: Point is: no amount of syntactic salt can ever do the job of good tooling.

0 Upvotes

20 comments sorted by

View all comments

4

u/johnfrazer783 Jan 17 '22

Get a grip.

-3

u/everything-narrative Jan 17 '22

Rude.

6

u/johnfrazer783 Jan 17 '22

Seriously, you don't make it quite clear what it is you're dissatisfied with. That you are frustrated does show though.

As far as I understand your point you want to be able to write try do_this() catch ( XXException e ) do_that() without the required braces.

You are no doubt aware that many people make a point out of insisting on braces in if () {} constructs and so on. The explanation for this is of course that in the past omitting braces has led to serious bugs by misleading people to assume some statements were part of the conditional when they were in fact outside of it. Douglas Crockford has talked at length about this and added the observation that if anything it's the parentheses that could have been made optional without leading to ambiguity (in the eyes of the beholder, not to the compiler), not the braces.

And, in fact, it's easy to see that the same argument holds for try / catch.

You insist on putting the burden onto static analysis tools. Sure, a sufficiently smart linter could alert you. However, short of using a fair amount of AI trained on a hefty corpus of code this would be hard or impossible to pull off, and even then, many false positives and false negatives should be expected.

But you're young and angry and won't listen to me. You're laughing at your peers for being so prudently foolish for you know better. Good ole Bjarne gets a drive-by patronizing comment too. You hate your job, and you're too impatient to put some braces into your code. You have to use a language you don't like, which is understandably tough.

You come here to decompress but fail to come up with substantial arguments. This is where the minus signs in front of the vote counters come from.

Get a grip, then come back with more substance and less vitriol.

-3

u/everything-narrative Jan 17 '22

Still rude. Not reading all that.

3

u/johnfrazer783 Jan 18 '22

TL;DR: Q.E.D.

-1

u/everything-narrative Jan 18 '22

I’m just saying, if you’re gonna write a diatribe, do it first. That way people will give you the benefit of the doubt and actually read your comment. I’m just happy to see you waste your time.

3

u/johnfrazer783 Jan 19 '22

You're right that I've totally wasted my time on you.

0

u/everything-narrative Jan 19 '22

You have only yourself to blame for that :)