Live data from Hacker News

Software development topics I've changed my mind on

chriskiehl.com

751–760 of 788 posts

Re: Software development topics I've changed my mind on

#751
post #22

> Most won't care about the craft. Cherish the ones that do, meet the rest where they are > (…) > People who stress over code style, linting rules, or other minutia remain insane weirdos to me. Focus on more important things. What you call “stressing over minutiae” others might call “caring for the craft”. Revered artisans are precisely the ones who care for the details. “Stressing” is your value judgement, not neces…

Sigh... it really doesn't matter compared to say how and what you test, and that you are consistent. He's saying your opinion about where a brace goes or even spaces or tabs is just not that important compared to crafting simple systems with clear code.

Re: Software development topics I've changed my mind on

#752
post #22

> Most won't care about the craft. Cherish the ones that do, meet the rest where they are > (…) > People who stress over code style, linting rules, or other minutia remain insane weirdos to me. Focus on more important things. What you call “stressing over minutiae” others might call “caring for the craft”. Revered artisans are precisely the ones who care for the details. “Stressing” is your value judgement, not neces…

> People who stress over code style, linting rules, or other minutia remain insane weirdos to me.

Until you open a file that has 10 different coding styles from 5 different developers. Just the variations of variable naming schemes alone in individual code files that I see/edit, would drive anyone crazy.

Re: Software development topics I've changed my mind on

#753

> Most programming should be done long before a single line of code is written Nah. I (16+ years developer) prefer to iteratively go between coding and designing. It happens way too often that when you're coding, you stumble across something that makes you go "oh f me, that would NEVER work", which forces you to approach a problem entirely differently. Quite often you also have eureka moments with better solutions th…

'Programming as theory-building' is an approach that has grown on me in the past few years. Your first draft may be qualitatively an MVP, but it's still just a theory of a final product you want, which requires a lot of iterative building before you get to that. As such, there's no way to not shift between code and design, especially when business requirements are involved and which themselves may change over time.

Relevant HN discussion: https://news.ycombinator.com/item?id=42592543

Re: Software development topics I've changed my mind on

#754
post #652

Can someone explain the ORM thing to me? I’ve been a developer for 8 years but never really worked on an app that was really database dependent. ORMs for me have always been convenient, and the performance has been fine. I understand there’s obvious tradeoffs I’m making, and in some cases full control is necessary, but I’ve never seen it happen. What level of complexity does an app need to get to before an ORM become…

Personal pet peeves: * They hide the queries. When your DB or cloud service gives you a printout of your 10 slowest queries, you then have to figure out what object code that relates to. And then is there even a way to fix it, or are you stuck with the ORM? * LINQ-specific: Love the tech, but it's unclear whether my .wheres() are being sent upstream properly, or if I'm downloading the whole database and filtering it…

> If I try to do an UPDATE ... SET x = x + 1, that will always increment correctly in SQL. But if read x from an ORM object and write back x + 1, that looks like I'm just writing a constant, right?

This is not specific to ORMs... you can run into the same problem without one.

> Extra magic: if you've read a class from the db, pass it around, and then modify a field in that class, will that perform a db update: now? later? never?

In every ORM I've used you have specific control over when this happens.

Re: Software development topics I've changed my mind on

#755

Earlier quoted context omitted.

Functional code is more chained and need more space often. Descriptive names are better; tends to be longer. Buy ultrawide. 80 is for aholes who like to use small laptop and then force it on everyone else. 120/150 is reasonable. 200 is great.

200 is entirely too fucking long, and I code on a 43” 4K. I try to stay under 90 in deference to others, and if it looks better breaking at 80, so be it.

200 allowed doesn't mean most lines will be. In general, 99% will be around 150 with a few places going high if it makes sense.

Re: Software development topics I've changed my mind on

#756
post #740

How come a fully typed ORM is the devil, if we agree we want a typesafe codebase for our mixed experience dev team? I have had positive experiences with Prisma. It just works.

I personally draw a distinction between micro-ORMs and ORMs. A micro-orm will simply take a strongly typed flat struct and map it into the set of parameters for a query, and likewise map a single row out to another flat struct (or enumerate/iterate while doing so). They may even include insert, update, and delete helpers that deal with a single table. This is what 90% of Prisma does and is the Good Parts. Migration generation is also good (but can be dangerous, e.g. deleting columns).

I'll call out query generation separately, as it is a lesser evil (in my opinion). This falls under a larger peeve of mine, which is using data (JSON, YAML, or this[1]) as programming languages. Using data as a programming language sucks. Tooling (compilers, LSP, etc.) are typically absent, meaning that mistakes very much become a runtime issue (not really a problem for Prisma). The deeper problem is that you'll run into limitations and will: either have to drop down to SQL (tricky given that you've rarely used it thanks to using ORMs to generate all your queries), or kludge/hack it up in order to remain in the ORM land. There's also lines of code and readability to contend with, the second Prisma example (the first is on my shit list for reasons further down):

    const result = await prisma.user.findMany({
      where: {
        OR: [
          {
            email: {
              endsWith: 'prisma.io',
            },
          },
          { email: { endsWith: 'gmail.com' } },
        ],
        NOT: {
          email: {
            endsWith: 'hotmail.com',
          },
        },
      },
      select: {
        email: true,
      },
    })
vs.

    SELECT u.email FROM users u
        WHERE (u.email LIKE '%prisma.io' OR u.email LIKE '%gmail.com')
          AND u.email NOT LIKE '%hotmail.com'
Just write the fucking SQL.

The objectively bad parts are one or more of the following:

* Change tracking: magically being able to update a value returned by the ORM and calling `save` to write it back to the DB.

* Object graphs: magically accessing related objects in memory, e.g. `order.orderlines` or `order.address.city.state`.

Relational databases (SQL) are not graph databases (in-memory object hierarchies). They are orthogonal concepts. Just throwing whatever you have as your classes into your database is neglecting to think about how your data is stored. This will come back to haunt you. You might claim that you can do the careful design using classes, and I would believe you, however, those juniors you mentioned aren't going to have the knowhow (because they've been shielded from SQL by ORMs their entire career and so don't understand how to make good databases).

Case in-point, back to that Prisma example shown earlier. Any ideas what's actually wrong with that query, besides the pointless hotmail check? Both the original and my conversion have the same serious issue that stems from not designing the database.

[1]: https://www.prisma.io/docs/orm/prisma-client/queries/filteri...

Re: Software development topics I've changed my mind on

#757
post #722

Earlier quoted context omitted.

OK, now try that with my ridiculously simple TodoList example, e.g. `TodoList(items=["item", "item2"])`. You can't do it! Nor can you construct an empty list then add items to it etc.

This is how ArrayField works in the postgres-specific fields: https://docs.djangoproject.com/en/5.1/ref/contrib/postgres/f... Or falling back to a more generic JsonField elsewhere: https://docs.djangoproject.com/en/5.1/ref/models/fields/#jso...

Well yeah, but you could have just used a document store at that point. If you start using JSON field you open up the problems with document databases (namely you can't really do many to many). In any case, postgres being awesome is something you get without any ORM!

Re: Software development topics I've changed my mind on

#758
> People who stress over code style, linting rules, or other minutia remain insane weirdos to me. Focus on more important things.

Considering anyone who is any good is gonna automate these things… and they are very important for long term maintenance and readability and predictability…

… probably the author is terrible. Sad to waste a decade.

Re: Software development topics I've changed my mind on

#759

Earlier quoted context omitted.

The OP didn't say what it is they're talking about that should be done before writing any code. He might have meant design, and I'm not sure about that. But the other thing i think of is: Understanding the problem. It's hard to do too much of that before you start coding, and easy to do too little. It overlaps with design to some extent, because once you understand the problem better, some designs will naturally seem…

Then the author should have said "Most software development should be done long before a single line of code is written" Programming is specifically about the authorship of code.

Right, by your interpretation what they suggested is logically impossible (one can't possibly write any code, let alone most, before one writes a single line of code), so I understand you think they should have written differently, but its clear they meant something else, I would assume they meant programming as a synonym for software development, right.

Re: Software development topics I've changed my mind on

#760
post #84

Earlier quoted context omitted.

I 100% agree. The problem is that after a half a century, software engineering discipline has been unable to agree on global conventions and standards. I recently had an experience where a repair crew was worried about the odd looking placement of a concrete beam in my house. I brought over the blueprints, and the technician found the schedule of beams and columns within seconds, pinpointed the beam and said, "Ah, th…

> The problem is that after a half a century, software engineering discipline has been unable to agree on global conventions and standards. It can't, and it won't, as long as we insist on always working directly on the "single source of truth", and representing it as plaintext code. It's just not sufficient to comprehensibly represent all concerns its consumers have at the same time . We're stuck in endless fights ab…

[deleted]
Post reply on HN