• 0 Posts
  • 30 Comments
Joined 1 year ago
cake
Cake day: September 24th, 2023

help-circle





  • There are arguments to be made either way, but normally you’d scope your variables in a way that the ones specific to a particular bit of code are not accessible from elsewhere.

    Sounds like you agree with that one to me? I’m not sure I follow their arguments about regions there (I’ve never used regions), but the example of declaring a variable in a block way before it is every used is spot on. I’ve seen code written like that and 99% of the time it’s a bad idea. I think a lot of it comes from people who learnt C where you have to do that (or maybe Javascript which has weird rules for var).

    Suggest writing a custom class to do what most languages can solve with inheritance or even better: the ? syntax.

    Yeah I’ll give you that one. They even suggest using Optional as a solution, which is what their “smelly” code did in the first place!

    Yes, it can be annoying. No, clarity is more important than insisting on removing that extra underscore.

    Not sure what your point is here. Of course inconsistent naming is a code smell. Do you want inconsistent names?

    They’re advocating the use of a function to replace an expression. Sometimes this works, but the task of a boolean expression is not always easily expressed in a couple words. And so you can end up with misleading function names. Instead, just put a comment in the code.

    Erm, yeah that’s why this is a code smell. They aren’t saying never have complex boolean expressions - just that if you do you’d better have a good reason because probably you’d be better off splitting it up into named parts.

    callback hell - Not even a code smell. It’s an issue from back when languages like JavaScript didn’t support promises yet, but callbacks were popular.

    Indeed, so now it is a code smell.


  • Any specific ones? I’ve seen this before and I thought I would feel the same way as you before I read them, but actually the vast majority are pretty basic things that are not really arguable.

    It’s definitely nice to have a list like this to point inexperienced colleagues to in code reviews. It’s a bit more authoritative than “trust me bro, I’ve written a lot of code”.





  • The problem is there aren’t really any good alternatives that have as widespread support. I’ve looked at lots and always found some annoying flaw that JSON or YAML don’t have. I mainly want good support in Python, Rust and VSCode.

    • JSON5: This is my ideal alternative but it has surprisingly poor support. No good VSCode extension. There’s a Serde crate but it’s not very popular.
    • Jsonnet: This has great VSCode support and support for lots of languages including Rust, but for some inexplicable reason they won’t let you use it with Serde just to load documents.
    • TOML: This is just not a good format. It’s ok for very basic things but any level of nesting and it becomes even worse than YAML.
    • Cue: Only supported language is Go.

    There isn’t really a perfect option at the moment IMO.

    If I’m using Rust I tend to go with RON at the moment. Sometimes I do use YAML but I write it as JSON (since YAML is a superset of JSON) with # comments.

    Also never output YAML from your programs. You can always output JSON instead which is better.







  • Yeah it’s easier to compile software with support for the latest vector extensions etc. if you do it from source. It is also possible to do runtime detection and switch between implementations that way, but it requires more work.

    Tbh I don’t think it would make much difference in practice. If you are ok with supporting only recentish CPUs you can use one of these options:

    • -march=x86-64: CMOV, CMPXCHG8B, FPU, FXSR, MMX, FXSR, SCE, SSE, SSE2

    • -march=x86-64-v2: (close to Nehalem) CMPXCHG16B, LAHF-SAHF, POPCNT, SSE3, SSE4.1, SSE4.2, SSSE3

    • -march=x86-64-v3: (close to Haswell) AVX, AVX2, BMI1, BMI2, F16C, FMA, LZCNT, MOVBE, XSAVE

    • -march=x86-64-v4: AVX512F, AVX512BW, AVX512CD, AVX512DQ, AVX512VL

    v2 is definitely fine and v3 is probably acceptable by now.

    In short I don’t think -march is a compelling argument for avoiding binary distribution. If it really makes a big difference either distribute multiple versions of your software using the flags above, or do runtime detection.




  • You basically shouldn’t until you are forced to move. Almost all of the improvements so far are in the internal architecture.

    You might notice some tiny differences if you switch, like logging in doesn’t show a black screen at any point, and window choosers when screen sharing show a (totally broken) grid of previews instead of a plain list of window titles.

    Hopefully when X is fully dead (give it another 10 years) we’ll see some actual improvements, e.g. RDP-style remote desktop, good support for multi-monitor, HDR, HiDPI, etc.