Ask HN: What are your favorite examples of elegant software?
281–290 of 422 posts
Re: Ask HN: What are your favorite examples of elegant software?
#282Earlier quoted context omitted.
This game sounds really cool, but I can't find it when I lookup "X game" or "X 4x game". Can you link it to me please?
X4 Foundations is its name https://store.steampowered.com/app/392160/X4_Foundations/ The expansion packs have expanded the size of the game world considerably, making the whole thing even more amazing
Re: Ask HN: What are your favorite examples of elegant software?
#283Earlier quoted context omitted.
This is nice. One interesting choice is the decision to compute the number of observed words, N, as the default value of an optional argument, thereby ensuring that it is only computed once, while still limiting its scope to the function in which it is needed. Perhaps this is a common pattern but it's one I haven't stumbled across before. The short circuiting `or` chain is also pleasantly virtuosic. Sometimes a littl…
> One interesting choice is the decision to compute the number of observed words, N, as the default value of an optional argument, thereby ensuring that it is only computed once You're saying python computes an expression that's part of a default value when the code defining the function is run? I guess it makes sense now that i say it, I wouldn't have automatically assumed that. That's an interesting one to remember…
Re: Ask HN: What are your favorite examples of elegant software?
#284Earlier quoted context omitted.
This is nice. One interesting choice is the decision to compute the number of observed words, N, as the default value of an optional argument, thereby ensuring that it is only computed once, while still limiting its scope to the function in which it is needed. Perhaps this is a common pattern but it's one I haven't stumbled across before. The short circuiting `or` chain is also pleasantly virtuosic. Sometimes a littl…
> One interesting choice is the decision to compute the number of observed words, N, as the default value of an optional argument, thereby ensuring that it is only computed once You're saying python computes an expression that's part of a default value when the code defining the function is run? I guess it makes sense now that i say it, I wouldn't have automatically assumed that. That's an interesting one to remember…
>>> def function(b, a=[]):
... a.append(b)
... print(a)
...
...
>>> function(1)
[1]
>>> function(2)
[1, 2]
>>> function(3, [4])
[4, 3]
>>> function(5)
[1, 2, 5]
A correct implementation would be: >>> def function2(b, a=None):
... if a is None: a = []
... a.append(b)
... print(a)Re: Ask HN: What are your favorite examples of elegant software?
#285> Abstract: We show that it is Scheme, of the Lisp family, the language that deterministically emerges when one opts for elegance.
Re: Ask HN: What are your favorite examples of elegant software?
#286Earlier quoted context omitted.
This is nice. One interesting choice is the decision to compute the number of observed words, N, as the default value of an optional argument, thereby ensuring that it is only computed once, while still limiting its scope to the function in which it is needed. Perhaps this is a common pattern but it's one I haven't stumbled across before. The short circuiting `or` chain is also pleasantly virtuosic. Sometimes a littl…
> One interesting choice is the decision to compute the number of observed words, N, as the default value of an optional argument, thereby ensuring that it is only computed once You're saying python computes an expression that's part of a default value when the code defining the function is run? I guess it makes sense now that i say it, I wouldn't have automatically assumed that. That's an interesting one to remember…
def foobar(my_list=[]): my_list.append(42)
A cursory glance suggests this function appends a number to an empty list every time it's run. But actually, the default argument is evaluated once when the function is defined, so calling this function repeatedly will continue to append to that same list.
Re: Ask HN: What are your favorite examples of elegant software?
#287Re: Ask HN: What are your favorite examples of elegant software?
#288Re: Ask HN: What are your favorite examples of elegant software?
#289Visual Basic (cue the hecklers). Yes the language is awful. But the tool was great. I wish Microsoft (or somebody) would release a new version for full-stack apps with a drag-and-drop UI with js event handlers, easy backend framework, and a one-button “deploy to cloud” button for testing. Then a “publish” button that sets up your CI pipeline for production deployments. I feel like we’ve raised the white flag in terms of what software development should look like in 2022. Writing yaml feels like banging rocks together compared to possible alternatives.
Re: Ask HN: What are your favorite examples of elegant software?
#290Not a specific piece of software, but a characteristic of a limited percentage of anonymous internal systems--one of the most beautiful things to witness in the realm of design is a system undergoing catastrophic stress when the designers anticipated and planned for such events, and in usually a very short period of time you see the results of extensive planning spool out, design features hidden from view and unappre…