jmp's recent activity

  1. Comment on "Java is fast but in practice, PHP sites run faster as PHP coders take more straightforward approach to design and don't get lost trying to implement exotic design patterns and endless abstractions" in ~comp

    jmp
    Link
    I write enterprise Java software daily. To be honest, I don’t really see the stereotypical “endless abstractions” thing that much these days. The language certainly doesn’t enforce you to write...

    I write enterprise Java software daily. To be honest, I don’t really see the stereotypical “endless abstractions” thing that much these days. The language certainly doesn’t enforce you to write anything like that.

    I think in the end, it really depends on the team. For example, our team practices TDD which results in simple designs by default. During TDD’s refactoring steps, we might generalize some piece of code, but usually it's just to remove duplication. Sometimes we might want to add some less trivial abstractions, but only if it makes sense given our current needs. If you want simple design, then you don't want to make too many assumptions about potential future requirements.

    But some teams (even in the same company) don’t do that. I think by nature, some people are drawn to gold-plating, generalizing and abstracting things. (I probably would do it too if I didn’t have a team writing and reviewing the code with me.) The problem is, most of the time we don’t know whether that abstraction or pattern was really useful or necessary in the long run, because we’re always working on limited knowledge of the future. At worst case, abstractions can just end up being overkill and increasing the cost of change in the future without adding any value.

    8 votes
  2. Comment on iPhone 14, 14 Pro owners complain about battery capacity that’s already falling off in ~tech

    jmp
    (edited )
    Link Parent
    Do you know how many charge cycles you’re at? Just for comparison, my iPhone 12 Pro is three years old and its battery is at 549 charge cycles at the moment. The maximum capacity is reported as...

    Do you know how many charge cycles you’re at? Just for comparison, my iPhone 12 Pro is three years old and its battery is at 549 charge cycles at the moment. The maximum capacity is reported as 90% by the Settings app.

    6 votes
  3. Comment on Fortnightly Programming Q&A Thread in ~comp

    jmp
    Link Parent
    What you described doesn't look too bad. So without knowing more details, it's hard (for me, at least) to see how to make the design better. Maybe just a couple of thoughts: As others have pointed...

    What you described doesn't look too bad. So without knowing more details, it's hard (for me, at least) to see how to make the design better. Maybe just a couple of thoughts:

    As others have pointed out, Python isn't necessarily well equipped for functional programming. This may be why something about your code feels off for you. When you start using things like immutable data structures and pure functions, you stray further away from object-oriented paradigm and more towards functional paradigm.

    In the OO paradigm, what you would probably prefer is rich domain models that encapsulate the behavior and state (if it exists) for that model. For example, in your case B could be modeled as a class with a calculate_thing method as opposed to a free function. What you would probably also do is separate the file reading and writing part to its own class. So if the persistence format or logic changes, it can be easily swapped or modified in one place.

    In the functional paradigm, you would do something similar to your example instead. Now I suspect it feels a bit off because the data and behavior are separated, and the language doesn't really encourage or support such programming style in any particular way. In many ways, it resembles the more traditional procedural paradigm. In languages like Clojure, it's more natural to write code in this way: If everything is an immutable list or map, you can use any functions that operate on lists or maps (many of which the language / standard library already provides for you), and combine and chain them together in all sorts of ways.

    5 votes
  4. Comment on What webhost and software do you use for your personal website? in ~tech

    jmp
    Link
    Mine is statically generated website that I host on Netlify. I use Zola to generate the website. The site “source code” is written in Markdown with some templates and style sheets written HTML and...

    Mine is statically generated website that I host on Netlify.

    I use Zola to generate the website. The site “source code” is written in Markdown with some templates and style sheets written HTML and SCSS. The source sits in a GitHub repository.

    I’ve connected the repository to Netlify, so whenever there’s a new commit, Netlify automatically picks it up, runs zola build and deploys the output.

    Until a few days ago, I was using my own static site generator written in Python. It was tiny (<100 SLOC) and worked fine for many years. But it had some quirks and didn’t have support for many features found in other static site generators. So I decided to migrate to a ready-made solution. Fortunately Zola was almost a drop-in replacement.

    12 votes
  5. Comment on Reddit is Fun, Apollo, BaconReader, and other third-party Reddit apps have officially shut down in ~tech

    jmp
    Link Parent
    There’s a thread about the API: https://tildes.net/~tildes/15y3/are_there_any_plans_to_publish_an_official_api In short, there’s an accepted issue in Tildes’s issue tracker since around 3 years...

    There’s a thread about the API: https://tildes.net/~tildes/15y3/are_there_any_plans_to_publish_an_official_api

    In short, there’s an accepted issue in Tildes’s issue tracker since around 3 years ago, but it’s a lot of work.

    4 votes