Hacker News new | past | comments | ask | show | jobs | submit | memco's comments login

Yin the OOP world I’ve seen this pattern called chaining : usually either method or object chaining.

Smalltalk (and Dart) also have "cascading" which is method chaining with special supporting syntax e.g. in ST you'd send four different messages to the same object with something like

    scene add: sprite; 
          add: otherSprite;
          setBackGround: stage;
          start
I'm not sure if it matches the "reuse values from previous computation" but it should since messages will affect the object, you just don't have local variables.

visual basic has the `with` statement for that https://learn.microsoft.com/en-us/dotnet/visual-basic/langua...

Nim has a similar `with` for the same use case. It can be handy!

It is using ';' instead of parenthesizing the messages to the objects, correct?

In Smalltalk, `;` does two things: terminates the current message (EDIT: while ignoring its return value) and propagates the target object of the current message as a target for the following message.

So this:

    scene add: sprite; 
          add: otherSprite;
          setBackGround: stage;
          start
is equivalent to:

    scene add: sprite.
    scene add: otherSprite.
    scene setBackGround: stage.
    scene start.
In Dart, they use `..` prefix instead of `;` postfix: https://dart.dev/language/operators#cascade-notation

    var paint = Paint()
      ..color = Colors.black
      ..strokeCap = StrokeCap.round
      ..strokeWidth = 5.0;    
You can model this with monads easily, but it's just one, very limited application of them - monads are much more general.

It's a style I really enjoy, and it's definitely not exclusive to one language or paradigm, exactly. I see it as more of less of a kind with pipelines in Unix shells, too.

In Scala, a language with OOP heritage and support, plus lots of functional programming features, some of the most common methods you use in such chains are monads.


This previous discussion of Spice on HN may help a bit: https://news.ycombinator.com/item?id=41230344


Relatedly, I once saw someone realize that the sound they played at the end of their build was running synchronously so they were blocking themselves from a faster feedback loop and reporting unusually long builds in their profiling. Properly backgrounding the sound fixed their issues.


I wonder whether pouring them together in addition to the first or second cases would be useful for helping to ascertain how keen the sense was.


I don’t remember if Mac had HTML but I used to set one of the quartz screensavers as my desktop back in the day. I can’t find links to how to do it right now so can’t test if it still works. It could only be set using a command line so it wasn’t exactly mainstream. I found “Flurry” to have decently low battery and CPU usage but many would chew through one or the other quickly.


For science I added versions of the benchmarks as for loops: it's faster than the while loop versions above, but min(heights) is still way faster:

    def benchmark1for(heights):
        smallest = heights[0]
        for h in heights:
            if h < smallest:
                smallest = h
        return smallest

    def benchmark2for(heights):
        smallest = heights[0]
        for h in heights:
            smallest = min(h, smallest)
        return smallest
Results: min(heights) : 0.07920974999433383 benchmark1 : 0.954568124958314 benchmark1for: 0.5765543330344371 benchmark2 : 1.8662503749947064 benchmark2for: 1.5281645830255002


Good call GP, and thanks for the results!

What was the Python version you used, and what was the CPU?

My runs were on 3.11 on Ryzen 7 Pro 6850U with whatever the TDP envelope is on a Thinkpad T14s.


Python 3.12.1 on an M2 macbook air. For extra fun I also tested doing `sorted(heights)[0]` which is slightly faster than the benchmark2 variants, but slower than the benchmark1 variants.


Same for business names! If you zoom in too close to the building the name disappears.


Niches inside of niches. I’m one of the few who enjoys a split ergo with > 60 keys and low-pro caps that doesn’t want to build it myself. The sofle choc looks promising as does the pinky4[1] if it can be made with all chocs.

[1]: https://github.com/tamanishi/Pinky4


Yeah I dont wanna build one either. Where can I buy this thing?


Sadly, I don't know anyone selling pre-assembled ones.


That’s over 40 minutes of a full day or 5 hours a week spent locking! As the author states it’s highly context dependent but in some cases this is a lot of time to do other work if it can be reduced.


I know at least Preview on MacOS has this feature now: if you try to put a black bar over text it tells you this isn’t secure and offers to redact for you using a method that both visually replaces all characters and removes the embedded text underneath It is non-destructive until saved meaning you have a window in which to make changes before the data is gone.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: