Simon blogs

Started by Simon, October 18, 2015, 06:05:44 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Simon

#165
Quote from: ccexplore on September 12, 2018, 08:59:56 AM
Looking forward soon to reading "Dr. Simon blogs". :P :thumbsup: :tal-silver:

I remember my first rant after passing: When you hand-write the digit 5 on paper, then move the hand to write another digit, but during the move, either you don't lift the pen properly or have the paper stick to the pen, you will draw a line through your 5 and make the 5 look like an 8. Digits should be designed more robust than this. :lix-evil:

Weight bet

In April 2018, I weighed 86 kg at 1.92 m and made a bet to lose 8 kg of weight to 78 kg over 7 months. This week, 5 months into the bet, the scale shows 77.7 kg and I merely have to maintain this weight for 2 months to win. :lix-grin: When I picked a new suit for the defense, the clerk even said: Skinny tall guy, it'll be easy to find something fitting.

During the bet, I still played only my feeble amount of sports. Instead, I ate in moderation and cut off-the-shelf snacks and sugary drinks. One idea behind the guinea pig diet (put cucumber on every bread in addition to your usual salami/cheese/...) is to make the food more elaborate to prepare, and you will stop easily when satisfied.

Occasionally, I still indulged in snack feasts with friends. That's fine: By then, one is accustomed to a moderated diet and will adapt to such extra intake, eating less the day after.

Mafia replacements

Mafia (social game, we played by forum) has downsides: Early and frequent player elimination, and a moderator who can't play themself. I preferred lean Mafia rules with few roles, but then you must debunk liers by pure face-by-face observation, very hard in a forum game. Others like many extra roles to give the community more substance for clues and discussion.

But whenever you're stuck with questionable design, plastering extra rules on top is rarely correct. You should instead attack the root problems. Secret Hitler (2016) and The Resistance (2010) fix both the early player elimination and obviate a moderator. Were I to play a hidden-role party game, I'd probably propose one of these over Mafia to the game group. Secret Hitler seems to have a large growing fanbase.

Still, I believe that Mafia will be played for many years to come, because it's the simplest. It captures the game idea and isn't obviously broken.

-- Simon

grams88

Hi Simon

It used to be a nightmare trying to get trousers to fit myself, it was the ones you would tend to wear for funerals and job interviews, weddings maybe. I'm around the 19 stone mark, I've been looking to trying to get back into the basketball as that was something I was quite good at back in the school and college days. My brother and I played a few one on one football games with a basketball. I ordered a basketball earlier this year and it has gotten my brother and myself out running a bit more. I can run at a fast pace but you do notice when you are at the 19 stone mark you do get out of breath a bit more. Still thinking about joining a basketball league in the future. :)

That's an interesting idea about making the food more elaborate when it comes to preparing that way you do tend to take steady approach to what you are eating. Do you play a little sports yourself, what's your favorite sport if you had to choose Simon?

Simon

#167
Yeah, 19 stones (120 kg) sounds like the high end. Way to go with the basketball! :thumbsup:

Weight loss, slowly over time, happens via diet: Look up your daily food energy requirement and actual intake. But merely dieting loses both fat and muscle. The sports counterbalance that, and keep you fit and happy.

My sporting -- I rode the bike each day to the math department and back. Now, Tim (reallife friend) has taken up Disc Golf, occasionally I join him on his weekly round: I get to spend time outside, and throwing those discs feels like starting lawn mowers.

I haven't considered joining a sports club. But even at home, I should practice pushups again, just a few.

-- Simon

Proxima

I've noticed lately that most of my trousers no longer fit me, and I think the reason is that my warehouse job, where I was for nine months, added up to a lot more physical activity than I realised. I haven't checked my actual weight any time over the last year, though.

When I visited Japan in 2013, I was there for three weeks and lost about 5kg very quickly. I guess that was a combination of visiting so many places, and Japanese food being so much healthier. I would love to go there again 8-)

nin10doadict

I've been at around 57 kg for at least 6 years now. At 1.8 m tall, this means it's also difficult to find pants that fit.
If I exercised more than what I get at my job then I might not have this problem...

Still, I'll take that over being too far in the other direction. :D

Simon

#170
Quote collections
  • random3.txt: My personal list of collected quotes. Most of them are about design, psychology, games, software. I don't remember why the file is called random3.txt anymore, I don't have any such files with numbers 1 or 2, but the name sticks. Random quotations.
  • Akin's Laws of Spacecraft Design: Classic list about physical engineering. Most of it is applicable to software engineering, even though my instinct would tell that it is not. E.g., in software, the extreme solution is often the cleanest, and cleanliness has great value, but it pales against backwards compatibility.
  • Dutch Quotes: Collected by somebody unknown, but most likely by a Dutch. I'm rehosting this because the original disappeared from the net 10 years ago.
-- Simon

Simon

#171
Aaaaaaa

I want to go to bed early, to fix sleep schedule by force. No computer time past 00:00 UTC+2 for next >= 1 week.

I sent email with missed attachment. Again because I didn't follow my own advice to always add attachment first, then write body, then write subject, then add recipients.

Had to resend, and now rant, and now it's 00:12. Good night.

-- Simon

namida

Quote from: Simon on October 10, 2018, 10:12:20 PM
I sent email with missed attachment. Again because I didn't follow my own advice to always add attachment first, then write body, then write subject, then add recipients.

Do you use GMail? If so, GMail has an "Unsend" feature that can be very handy - you need to enable it though, it's not enabled by default.

This isn't a true unsend, of course - that'd be pretty much impossible (and even if possible, there are possible moral issues with such a feature). Rather, it delays sending the email for a time period of your choosing - the maximum I believe being 30 seconds - during which you can cancel the send. Very useful for those cases where you click Send then immediately realise you forgot something.
My projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)
Non-Lemmings: Commander Keen: Galaxy Reimagined (a Commander Keen fangame)

Simon

#173
Right, I've used Gmail.

Undo-sent-email is available for a few seconds, it wouldn't have helped me that time. Interesting that one configure its duration, I've set it to 30 secs, the max.

I remember how they were annoyed about their internal delay on sending email, and turned it into a user feature. Very nice hack!

-- Simon

Simon

#174
Text-based configuration formats

All text-based configuration formats suck. (They're still the best. Binary sucks more. Databases are overkill for configuration.)

I'm considering to write Lix's trophies and options in a different place, and add trophy fields (author of level, title of level). I'm considering to write the trophies in SDLang, but there are many competing text file standards and they all have problems.

Why not use X, where X = JSON, Ini files, SDLang, TOML, YAML, XML, etc., for at least 10 formats, by the StrictYAML authors.
JSON as configuration files: please don't
YAML: probably not so great after all

Downsides of Lix's config file format: Hardly extensible. Even though the parser ignores lines beginning with unknown keywords, but the attributes after the keyword have no names, have a fixed order, and fixed types. Can't define nested structures. Tile groups in Lix levels already need a hack with an open-section-tag and a close-section-tag. (I will keep the level format and not change that anytime soon! This is only for options.)

Downsides of SDLang: Almost nobody uses it, few existing parsers for other languages besides D, complicated (does the application expect a tag with many values, or a tag with attributes, or a tag with child tags?)

-- Simon

Simon

#175
Pure

It is nice if your function is weakly pure (doesn't read or write to global mutable state) or strongly pure (as weakly pure, and additionally doesn't dereference any of its argument pointers to mutable state) because the same inputs will then always yield the same outputs. The compiler can assume things about your function, replace function calls with cached results, or constant-fold everything.

It is nice if your function doesn't allocate memory, guaranteed. That's faster, that's compatible with more algorithms (leaves your callers in control about how to allocate), and makes your function simpler.

It is nice if your function cannot throw exceptions. Need fewer things in the mind before the code is complete and handles all conditions. Thus, it's simpler.

It is nice if your method promises to not modify the object. Your readers can reason about the system's state more easily, and focus on the real problems.

It is nice if your function, if it promises to return a class object by reference, guarantees that the reference is not null (we had this rant).

It is nice if ...

It is terrible if everything in your code is annotated with @property @safe const pure nothrow @nogc:

It looks ugly and complex.

It's brittle because simple changes produce nasty, cascading errors.

It's unworkable if only 98 % of your language's standard library follows the principle, you call into the standard library everywhere, and even if you file bugs or send patches to the library, it will take months before the changes have propagated to your self-building users.

It tempts to cheat the system. Surely, to round() a floating-point number should be pure? What if, in general, yes, it is pure, but only on one particular architecture, the library writes custom float-handling flags to the CPU, then rounds, then restores the old flags? Such assembler calls are the most impure building blocks of any function. Let us consider this hack to cast between pure and impure... Oh, some well-optimizing compiler doesn't like the hack 3 years down the road, and you get segfaults in unrelated-looking parts of the source.

It runs into rarely-used parts of your language. These parts tend to be particularly buggy and lack the necessary manpower. These parts are notoriously incompatible anytime you want to mix two features of the language.

Likely, at least one of these features was designed 15 years ago, and then software engineering theory has advanced, but the language is encrusted enough to stick with the old design.

Arg arg arg. This must be why people write their own toy languages all the time. :lix-tongue:




Crane: In your purity proposal, can you allow pointer dereferences to immutable external memory? Can Pascal guarantee that some object will never mutate? Typically, immutability and purity go hand-in-hand to make strong purity more usable.

-- Simon

Simon

#176
Graphics card henchmen

The CPU is the criminal mastermind, capable of anything. But he must carefully delegate tasks that would take too long for him alone.

The graphics card is the mastermind's army of muscular thugs. If you can explain a task in simple terms, they're highly efficient at getting things done. These henchmen don't like drawing individual pixels on textures. But they can draw readily-prepared bitmaps with transparency, hundreds of them, in the blink of an eye.

Lemmings programming is special: Pixel-precise drawing on the graphics card's bitmaps is necessary, but, naively implemented, would be slow. Kitchen-sink libraries such as SDL2 or Allegro 5 have a hard time offering suitable abstractions for this. I'm already calling more specialized Allegro 5 routines for the graphics card's batch-processing of many small drawing operations. I can't shake the feeling that learning hands-on graphics card programming would immensely help my cause. But the Allegro 5 functions hit a sweet spot: It's fast enough and doesn't leave their abstractions (good because I rely on Allegro 5 bitmaps throughout).




Interface segregation

The interactive game has an effect manager: What sound effects should be played, what sound effects should not be played because they're merely from a recalculation of physics, what skill-highlighting arrows should pop up, etc.

The lixes need to know the effect manager to queue their sounds: Only the digger hitting steel can tell that a steel-hitting sound should be played. But lixes and physics should also run without interaction. Why should they depend on a class like EffectManager that is 95 % user interface bells and whistles? EffectManager doesn't affect physics at all.




Game with EffectManager----depends-on---->Physics
Physics----depends-on---->Game's EffectManager

The answer is to define the EffectManager's queuing interface, EffectSink, separately from its implementation. EffectSink is a part of the physics, and lixes know how to queue effects.





Game----depends-on---->EffectManager, Physics
EffectManager----implements---->EffectSink
Physics----depends-on---->EffectSink

This way, you have no circular dependencies in your program. Bonus points is that, now, you can define a NullEffectSink that auto-implements all EffectSink methods as empty methods -- a one-liner definition with the D standard library's BlackHole. Then, noninteractive replay verification gets passed a NullEffectSink and can unconditionally call its EffectSink instead of my old way of checking whether an optional EffectManager is really there (even with a special Optional library type, this was a nonzero effort at the call site). It's always nice whenever there is no need for null references. :lix-grin:

Finding these abstractions is utmost joy. :lix-blush:

This should really go into OO-with-Simon instead. Perhaps clarify the relation between Game and EffectManager, so it's clearer how either depends on physics.

-- Simon

ccexplore

Quote from: Simon on October 26, 2018, 11:24:40 AMIt tempts to cheat the system. Surely, to round() a floating-point number should be pure? What if, in general, yes, it is pure, but only on one particular architecture, the library writes custom float-handling flags to the CPU, then rounds, then restores the old flags? Such assembler calls are the most impure building blocks of any function.<snip>

In Crane's purity proposal that you link to, the focus there seems to be specifically about the function being deterministic such that same inputs always produce same outputs (and also that it's either side-effects free, or no one will take dependency on the side effect), so that for example you can precompute at compile time in some cases.  It seems like you can assert something being deterministic separately from a definition of purity that is based on a function's implementation with respect to interactions with global states.  So you could assert that round() is deterministic even if it might not be pure in some corner case, and may still reap a good portion of the benefits of doing so.  Purity would imply deterministic, but you can assert something to be deterministic without being pure.

Simon

Quote from: ccexplore on October 31, 2018, 06:29:01 AM
Purity would imply deterministic, but you can assert something to be deterministic without being pure.

Right.

This is the idea behind compile-time function execution in D: You can execute nearly everything at compile time, even if it's not marked pure. The compiler will complain e.g. about I/O, but happily execute whatever it can, allocate memory for temporaries etc.

I'm not sure what the selling point behind D's pure keyword is then -- I presume it's some hint for the compiler that it should consider more ruthless optimization here.

C++ has constexpr to enable compile-time function execution. A very long keyword to type, very verbose if the headers are full of that. :lix-tongue: I still believe that compilers should infer constexpr/const/immutable/pure/nothrow/@nogc etc., wherever they can. After all, they can check whether a keyword is allowed on a function. Only if we annotate the function explicitly, then the compiler should enforce the property.

-- Simon

Simon

Save-money coupons

The devil's contraption to waste everybody's time and money.

I was shopping at the supermarket. At another cashier, I observed two Asian students trying to redeem a voucher to save 1 Euro on toothpaste. This failed for some hard-to-understand reason. The students weren't 100 % up-to-speed with German either. Two extra clerks were called, and the customers behind waited for 4 minutes. That was longer than my entire wait and cash-out.

Let's summarize the disaster:
5 customers had to wait for 4 minutes = 20 minutes.
3 clerks busy for 4 minutes = 12 minutes.
2 other clerks interrupted from other work = 30 extra minutes to regain flow.
Already over an hour of lost time.
An hour is worth far more than the 1 Euro the coupon would have saved.

Cashback programs are similarly insidious: The clerk will ask everybody for their cashback card, that loses 3 seconds per customer even when no customer participates. The supermarket exchanges marketing data with the cashback firm. Nothing is free, the cashback customers are paying with their time and lost privacy.

For humanity's sake (the people around you), never participate in coupon programs or cashback programs that have even the slightest risk of slowing down public infrastructure. Coupons are less intrusive in online sales, but really, who cares about saving 1 Euro. Buy few things, but if you buy, buy high quality and don't mind small price differences.

-- Simon