0 points

Ligatures 🤢🤮🤮

permalink
report
reply
0 points

You’re brave (I don’t agree)

permalink
report
parent
reply
0 points

What’s wrong with Ligatures? It makes reading code a bit more tolerable.

permalink
report
parent
reply
2 points

Sadly, that’s not code Linus wrote. Nor one he merged. (It’s from git, copied from rsync, committed by Junio)

permalink
report
reply
3 points

You really think someone would do that? Just go on the internet and tell lies?

permalink
report
parent
reply
1 point

here you go, linux 0.01

permalink
report
parent
reply
3 points

Isn’t that from 1991 while the quote is from 1995? If we’re nitpicking maybe we shouldn’t time travel 🤓

permalink
report
parent
reply
2 points

Damn it Time Patrol! You can’t stop me!

permalink
report
parent
reply
3 points

I mean it was 0.01, at that point he was screwed anyway, and he fixed his program.

permalink
report
parent
reply
3 points

He wouldn’t make that statement unless he experienced the horror himself.

Now, if he still does it these days…

permalink
report
parent
reply
1 point

I’ve heard similar from the worst first year CS students you could ever meet. People talk out their ass without the experience to back up their observations constantly. The indentation thing is a reasonable heuristic that states you are adding too much complexity at specific points in your code that suggests you should isolate core pieces of logic into discrete functions. And while that’s broadly reasonable, this often has the downside of you producing code that has a lot of very small, very specific functions that are only ever invoked by other very small, very specific functions. It doesn’t make your code easier to read or understand and it arguably leads to scenarios in which your code becomes very disorganized and needlessly opaque purely because you didn’t want additional indentation in order to meet some kind of arbitrary formatting guideline you set for yourself. This is something that happens in any language but some languages are more susceptible to it than others. PEP8’s line length limit is treated like biblical edict by your more insufferable python developers.

permalink
report
parent
reply
1 point

line 152 is the only thing past 3 levels and I’d say that one gets a pass.

permalink
report
parent
reply
1 point

Plus it shows three levels of indentation. Well… there is the extra one created by the compiler directives, but do they really count?

permalink
report
parent
reply
1 point

Only the sith deal in absolutes

permalink
report
reply
1 point

You must be a sith…

permalink
report
parent
reply
1 point

Absolutely.

permalink
report
parent
reply
0 points
*

While I totally agree with that philosophy, it heavily depends on the language.

For Rust, my philosophy is more like this:

  • Impl + fn body don’t count, as well as async blocks if they span the whole function
  • do not nest more than one if statement. You probably better using guard clauses or matches
  • do not put loops into an if statement.
  • do not nest loops unless clearly shown to be (X, Y) indexing
  • method chaining is free
  • do not nest closures, unless the nested closure doesn’t have a {} block
  • do not use mod unless it’s test for the current module. No I don’t want to Star Wars scroll your 1000 line file. Split it.
permalink
report
reply
0 points

Why have an async block spanning the whole function when you can mark the function as async? That’s 1 less level of indentation. Also, this quite is unusable for rust. A single match statement inside a function inside an impl is already 4 levels of indentation.

permalink
report
parent
reply
-1 points

A single match statement inside a function inside an impl is already 4 levels of indentation.

How about this?

The preferred way to ease multiple indentation levels in a switch statement is to align the switch and its subordinate case labels in the same column instead of double-indenting the case labels. E.g.:

switch (suffix) {
case 'G':
case 'g':
        mem <<= 30;
        break;
case 'M':
case 'm':
        mem <<= 20;
        break;
case 'K':
case 'k':
        mem <<= 10;
        /* fall through */
default:
        break;
}

I had some luck applying this to match statements. My example:


let x = 5;

match x {
5 => foo(),
3 => bar(),
1 => match baz(x) {
	Ok(_) => foo2(),
	Err(e) => match maybe(e) {
		Ok(_) => bar2(),
		_ => panic!(),
		}
	}
_ => panic!(),
}

Is this acceptable, at least compared to the original switch statement idea?

permalink
report
parent
reply
0 points

i personally find this a lot less readable than the switch example. the case keywords at the start of the line quickly signify its meaning, unlike with => after the pattern. though i dont speak for everybody.

permalink
report
parent
reply
0 points

It’s a lot less readable imo. As well than a cargo fmt later and it’s gone (unless there’s a nightly setting for it)

permalink
report
parent
reply
0 points

Well, of course you can have few indent levels by just not indenting, I don’t think the readability loss is worth it though. If I had give up some indentation, I’d probably not indent the impl {} blocks.

permalink
report
parent
reply
0 points

One nit: whatever IDE is displaying single-character surrogates for == and != needs to stop. In a world where one could literally type those Unicode symbols in, and break a build, I think everyone is better off seeing the actual syntax.

permalink
report
reply
1 point

I think it’s a lineature. FiraCide does that for example, and I like it very much. My compiler and lsp will tell me if there is a bad char there. Besides, the linea tires take the same space as two regular characters, so you can tell the difference.

It’s not the 90s anymore. My editor can look nice.

permalink
report
parent
reply

Programmer Humor

!programmerhumor@lemmy.ml

Create post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.

Community stats

  • 4.3K

    Monthly active users

  • 945

    Posts

  • 10K

    Comments

Community moderators