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

help-circle

  • Yeah the main reason is performance. In some languages if you use a value “linearly” (i.e. there’s only ever one copy) then functional style updates can get transformed to mutable in-place updates under the hood, but usually it’s seen as a performance optimisation, whereas you often want a performance guarantee.

    Koka is kind of an exception, but even there they say:

    Note. FBIP is still active research. In particular we’d like to add ways to add annotations to ensure reuse is taking place.

    From that point of view it’s quite similar to tail recursion. It’s often viewed as an optional optimisation but often you want it to be guaranteed so some languages have a keyword like become to do that.

    Also it’s sometimes easier to write code that uses mutation. It doesn’t always make code icky and hard to debug. I’d say it’s more of a very mild code smell. A code musk, if you like.





  • Easily above average code for Python. I’m going to pick on one method:

    def _set_float_icon(self, is_floating: bool):
                """ set the float icon depending on the status of the parent dock widget """
                if is_floating:
                    self.float_button.setIcon(self.icon_dock)
                else:
                    self.float_button.setIcon(self.icon_float)
    

    First, Python does have ternary expressions so you can

    self.float_button.setIcon(self.icon_dock if is_floating else self.icon_float)
    

    Second, what does this code do?

    foo._set_float_icon(true)
    

    Kind of surprising that it sets the icon to icon_dock right? There are two easy fixes:

    1. Use *, is_floating: bool so you have to name the parameter when you call it.
    2. I’d probably rename it to _update_float_icon() or something.

    Also use Black or Ruff to auto-format your code (it’s pretty well formatted already but those will still improve it and for zero effort).


  • I’ve tried to learn Vim in the past but IMO it is not worth it at all. In a world without multiple cursors… sure, maybe. With multiple cursors? No way. I can can edit just as fast as I’ve seen any Vim user do it, and without having to remember a gazillion mnemonics and deal with the silly modal thing.

    Multiple cursor editing even has some significant advantages over Vim style, e.g. it’s interactive, so you can do your edit gradually and go back if you make a mistake. Rather than having to write a complex command and only finding out it if works at the end. (If you’ve used regex find & replace you’ll understand that problem.)

    I’ll probably get downvoted for this since Vim is kind of a cult, and Vim users get a sense of superiority from it. Kind of like audiophiles - they don’t appreciate it if you tell them their £10k valve amp doesn’t actually sound any better than your £1k digital amp.

    For editing on remote computers I use VSCode remote or Micro for quick tasks.




  • A couple of possible reasons:

    1. If it’s a new company with fewer standards then more niche products become more viable. I don’t know exactly what the situation at Pebble was but if they took lots of VC funding they can’t turn around and say “ok we’re just going to trundle along with this niche watch that is loved, but only by a few people”. A small company can do that.

    2. Advertising / brand awareness. Pebble was very well known, but if you make some random alternative nobody is even going to learn of your existence. This attempt is using the actual Pebble code and it’s run by the ex-Pebble people.

    3. Don’t underestimate the software effort. Now that they have most of the code, resurrecting it is a lot easier.

    Having said that, I would probably put my money on them doing a Kickstarter (which will do very well based on nostalgia), delivering a product that can’t really compete with modern smart watches, and then slowly fading into the night. Hope not but I won’t hold my breath. (I can’t really wear watches anyway so it doesn’t really affect me.)




  • You can do it in launch.json. In fairness it easily the weakest part of VSCode - I wouldn’t call editing JSON “comfortable”. I tend to just use the integrated terminal instead.

    I think the bigger argument for Pycharm is refactoring. VSCode still has fairly weak support for refactoring, whereas in IntelliJ you can move classes and methods around, extract functions etc and it all works quickly and reliably (in Java at least; I dunno about Pycharm - Python is trash so it might not be possible to do refactoring reliably).