1. 5

    My main gripe with this article is the bitter negative tone, but others have already commented on that.

    Trying to be a bit more constructive, i think this article would really benefit from a code example of how the author would have solved the 99 bottles problem. In fact the first chapter of the book presents the problem and invites the reader to write a solution for it, also providing a test suite to test against. I think most of the value of an exercise-based book like this one comes from trying to solve the exercises and then contrasting the solution with the author’s, or with peers. So, there’s a lot of complaints, but where is the counter-argument or counter-example? Show me the code! :)

    About the book itself, i’ve read it, and in general i do agree that as an OO book, i didn’t get much form it. But i’m not a fan of OOP and in general try to avoid using it, so i’m already biased there. What i did find valuable from the book were the refactoring exercises, which showcased doing meaningful refactors in very small steps, while keeping all tests green between every little step. I think this can be quite valuable, especially in dynamically typed languages, or languages with poor tooling support in general, where there’s no such thing as “the compiler will guide me through this refactor”, or where even a class/method rename can be non-trivial because of stringly-typed code calling things via reflection.

    1. 7

      My main gripe with this article is the bitter negative tone, but others have already commented on that.

      I guess I’m overly negative, because the book sells itself as OOP book, and people keep mentioning it to me as an OOP when I ask for examples of “Good OOP”, and $40 later turns outthe book have nothing to do with OOP. 99% of the time the self there goes unused and classes are used as namespaces. The OOP stuff in there doesn’t make any sense. How can there be any discussion about Liskov Principle, when there’s no interface or subclassing around?

      Had it been called “Basics of structuring your code well”, maybe I would just shruged and moved on. But then it would probably not sell as well, so catch-all OOP marketing has to be used.

      would really benefit from a code example of how the author would have solved the 99 bottles problem.

      Just like the version considered most simple in the Chapter 1 that I pasted verbatim. And then the sixpack requirement by adding the when 6 case. The book go on and on about “OOP for changeability” but actually handling this requirement was trivial in the simplest version already.

      1. 4

        Just like the version considered most simple in the Chapter 1 that I pasted verbatim. And then the sixpack requirement by adding the when 6 case.

        Even at such a simple level as this problem, i think it might have been valuable to actually write that solution and make the tests pass. It turns out that with that starting code, a when 6 is not enough; you also need a when 7 case to account for the modification on the verse that starts with 7 bottles:

        7 bottles of beer on the wall, 7 bottles of beer.

        Take one down and pass it around, 1 six-pack of beer on the wall.

        Still manageable with that when/case structure i think, but it exemplifies the issue that the author is trying to convey about that sort of code: you wanted to changed a single “concept”, but you needed to change two places in the code because that concept is spread through different branches of that when statement.

        I don’t think that the over-architected solution of inventing “BottleNumber”s is justified TBH; i’d personally would have gone for some helper formatting function for printing quantities of bottles and that’s it, but i digress.

        the book sells itself as OOP book, and people keep mentioning it to me as an OOP when I ask for examples of “Good OOP”

        I didn’t know about this. In that case, yes, i agree with the general conclusion of the book not really having any realistic example of “good” OOP code.

        1. 5

          I don’t think that the over-architected solution of inventing “BottleNumber”s is justified TBH; i’d personally would have gone for some helper formatting function for printing quantities of bottles and that’s it, but i digress.

          The author agrees with you! For something that is simple or unchanging, the procedural style is often most clear. The point of using such a simple example is to make the techniques used for refactoring stand out, not that they are the right fit for the tiny problem at hand “in the real world” but rather that they are the right fit for related-but-real problems of the same shape.

    1. 19

      Multiple of these are just the standard “I don’t understand floating point” nonsense questions :-/

      1. 5

        That doesn’t explain why a script language uses floating point as its default representation, let alone why that is its only numeric type.

        1. 4

          JavaScript has decimal numbers now fwiw, though I agree. Honestly I’ve been convinced that IEEE floating point is just a bad choice as a default floating point representation too. I’d prefer arbitrary size rationals.

          1. 2

            Arbitrary size rationals have pretty terrible properties. A long chain of operations where the numerator and denominator are relatively prime will blow the representation up in size.

        2. 5

          Indeed, same goes for the octal notation question (010 - 3 = ?)

          1. 7

            tbh the 010 octal format IS pretty awful. I don’t know what they were thinking putting that in C.

            1. 5

              well at least JS users have 0o10 - 0o5 now, if they find leading 0 octal notation to be confusing.

              1. 3

                Thanks for note, wasn’t aware of the ES2015 notation and MDN is helpful as always.

              2. 4

                I mean if you want fun 08 is valid JS, and that’s absurd :) (it falls back to decimal, nothing could go wrong with those semantics)

                1. 3

                  Amusing, I’ve seen people write PHP with leading 0s before. Newer PHP rejects if there are invalid octal digits - fun! Putting the leading zeroes is common for people used to i.e COBOL/RPG and SQL; business programming where they’ve never seen C.

              3. 2

                really? only like ~5 of the 25 appeared to be floating point releated: 0.1 + 0.2, x/0 behavior, 0 === -0 and NaN !== NaN. Correct me if I’m wrong. Most of them seem to be about operators and what type of valueOf/toString behavior one gets when faced with such operators. Only two I got wrong were because I forgot +undefined is NaN and I was a bit surprised that one could use postfix increment on NaN (and apparently undefined?).

                1. 1

                  Any arithmetic operation can be performed on NaN, but it always yields another NaN.

                  The undefined one is a bit weird but kinda makes sense, it is indeed not a number.

                  I actually think what’s weirder is how javascript will sometimes give you basically an integer. x|0 for example. The behavior makes a lot of sense when you know what it is actually doing with floating point, but it is still just a little strange that it even offers these things.

                  But again I actually think it is OK. I’m a weirdo in that I don’t hate javascript or even php.

                2. 1

                  i don’t see where is the contradiction there. JS numbers are IEEE 64-bit floating point numbers, so any weirdness/gotcha in IEEE floating point is also a weirdness/gotcha in JS too

                  i know that many (most) languages also use floating point numbers by default, but that doesn’t floating point gotchas any less weird, maybe just more familiar to already-seasoned programmers :)

                1. 4

                  Holy heck they didn’t half-ass this

                  1. 6

                    Well, they’re not entirely truthful either – Clojure for instance has solved this issue:

                    (+ 1/10 2/10) ;; => 3/10
                    (+ 0.1M 0.2M);; => 0.3M
                    

                    I get the point of the post, but it seems a tad awkward to point of the failings of languages that have solved this and doesn’t need a custom implementation of ratios…

                    1. 10

                      And Clojure solves it because it tries to follow in the tradition of older schemes/Lisps. I’ve ranted more than once to my colleagues that numbers in mainstream “app-level” (anything that’s not C/C++/Zig/Rust/etc) programming languages are utterly insane.

                      <soap-box>

                      Look, yeah- if you’re writing a system binary in C, or developing a physics simulation, or running some scientific number crunching- then you probably want to know how many bytes of memory your numbers will take up. And you should know if/when to use floats and the foot-guns they come with. (Even, then, though- why the HELL do most languages silently overflow on arithmetic instead of exploding?! I don’t want my simulation data to be silently corrupted.)

                      But for just about everything else, the programmer just wants the numbers to do actual number things. I shouldn’t have to guess that the number of files in a directory will never go above some arbitrary number that happens to fit in 4 bytes. I shouldn’t have to remember that you can’t compare floats because I had the audacity to try to compute the average of something.

                      We have this mantra for the last decade or so that “performance doesn’t matter”, “memory is cheap”, “storage is cheap”, “computers are fast”, etc, etc, yet our programming languages still ask us to commit to a number variable taking up an exact number of bytes? Meanwhile, it’s running a garbage collector thread, heap allocates everything, fragments memory, etc. Does anyone else think this is insane? You’re gonna heap allocate and pointer-chase all day, but you can’t grow my variable’s memory footprint when it gets too large for 2,4,8 bytes? You’re gonna lose precision for my third-grade arithmetic operations because you really need that extra performance? I don’t know about that…

                      </soap-box>

                      1. 3

                        Even, then, though- why the HELL do most languages silently overflow on arithmetic instead of exploding?! I don’t want my simulation data to be silently corrupted.

                        Oh man you just dredged up some bad memories. I was working on modifying another grad student’s C++ simulation code, and the performance we were seeing was shocking. Too good, way too good.

                        Turns out that they’d made some very specific assumptions that weren’t met by the changes I made so some numbers overflowed and triggered the stopping condition far too early.

                        1. 1

                          (Even, then, though- why the HELL do most languages silently overflow on arithmetic instead of exploding?! I don’t want my simulation data to be silently corrupted.)

                          In an alternate universe:

                          (Even, then, though- why the HELL do most languages insert all these bounds checks on arithmetic that slow everything down?! I know my simulation isn’t going to get anywhere near the limits of floating point.)

                          1. 1

                            Sure. But isn’t the obvious solution for this to be a compiler flag?

                            Less obvious is what the default should be, but I’d still advocate for safety as the default. Sure, you’re not likely to wrap around a Double or whatever, but I’m thinking more about integer-like types like Shorts (“Well, when I wrote it, there was no way to have that many widgets at a time!”).

                        2. 4

                          same thing with Ruby

                          $ irb
                          irb(main):001:0> 0.1 + 0.2
                          => 0.30000000000000004
                          irb(main):002:0> 0.1r + 0.2r
                          => (3/10)
                          

                          and i’m pretty sure that’s the case with Haskell too

                          it might be a fair criticism to question why the simplest and most obvious syntax (i.e., no suffix) doesn’t default to arbitrary-precision rationals, as is the case with integers in languages like Ruby, Haskell, etc.

                      1. 65

                        I got that banner once too, after a string of good faith but slightly controversial comments which got many upvotes and a few flags. From what I can tell, the banner is less serious than it sounds, but being nudged towards deleting your account definitely leaves a sour taste in the mouth.

                        I don’t think the ratio of upvotes to flags is taken into account, just the pure number of flags. That would mean that people who post frequently are likely to see the banner, unless everything they post is 100% uncontroversial.

                        The banner suggests talking to a mod, I tried sending a PM to a moderator asking what I should change in my behavior to not be prompted to delete my account again. I never got a reply. I suppose there are higher priority things to take care of.

                        1. 42

                          Yep. I’ve seen it twice.

                          The first time, I had no clue what it was about, and tried to PM every mod. I got a response from one about a week later I think, and then later from pushcx saying that he’d added a page to show you your own ‘standing’.

                          The “flagging” for me was based on just two comments:

                          1, where I expressed an opinion about systemd, that got 30+ upvotes and 1 “incorrect” downvote, and then replied to myself to question how an opinion can be “incorrect”, and that comment got 5 ‘off topic’ down votes.

                          2, I make a sarcastic comment about the irony of using docker to distribute all-in-one Go binaries, and of course, it was downvoted -5 as ‘trolling’.

                          I am convinced from my use here, HN, /. - using user input via ‘downvotes’ as any kind of trusted heuristic about the quality of a comment, is a stupid fucking idea. It’s never been done well, even here, which is already better than most places.

                          The only thing that makes it better here is that the banner is all that happens automatically - there’s no automatic banning or anything. But it really doesn’t make that clear, and the hint about closing your account is just ridiculous IMO.

                          1. 5

                            I remember that discussion (I was the one who responded). I did find it to be an important example of how sensitive the system is, precisely because it’s based on user input. I looked over those two comments carefully at the time, and I still bear them in mind every time we’re discussing feature changes.

                            1. 4

                              And I’m still thankful for your efforts!

                              I know moderation is generally a thankless task.

                              I hope it’s clear from my comments, that the actual moderation (ie the actual actions you take) on 🦞 is among the best Ive seen, if not the best.

                              My issue is very much with the way regular users use the tools available to them, and thus the tools that are available.

                              Lobsters doesn’t have downvotes, so (some) people use flags to signify stuff they disagree with (although I think someone mentioned the incorrect flag is gone now?) as well as flagging actually “bad” stuff.

                              In theory the orange site should do better at this because it has both downvotes and flagging - the problem is the downvote action has consequences that actively encourage the production of echo chambers.

                              🦞 still manages this much better overall, but I also wonder how much of that is down to sheer size. Would unpopular opinions be flagged to death here if the population grew ten-fold?

                              I don’t know. But I wouldn’t bet my carefully hoarded internet upvote points on it!

                              1. 3

                                Good thoughts, and it’s very welcome criticism.

                                Yes, “incorrect” is gone now.

                                1. 1

                                  “Incorrect” is gone, but “unkind” remains?

                                  That’s sus.

                            2. 5

                              (edit: I’ve removed a quote here, since the post I was replying to had been deleted by its author.)

                              (Slightly later edit: I suspect the author removed that post because it brought up the problem of flagging abuse, and mentioned their own post as an example. Taking a look at my standing page, I absolutely understand why that’s the case though. I have two flags this month: one flagged “troll”, which I don’t wanna argue about, and another one flagged “spam”. It’s on a post that’s on-topic, contains no links, no mention of any product except the one the topic is about, no self-promotion – actually no promotion of any kind. I’d love to know why someone thought it might be spam, but since there’s no way to appeal flags and no way to know who flagged a comment, that’s anyone’s guess.

                              That being said, since some decisions are taken based on flags, there should be a way to appeal them, just sayin’ ;-))

                              It’s also my experience that metrics really don’t help. Way back when phpBB was still a thing I was part of a moderator team that tried to test-drive one of those up/downvote plugins that started popping up around 2006 or so (or maybe earlier? I don’t recall anymore… anyway, it was a long time ago). It was terrible, and we tried a couple of “soft” versions (one that allowed upvotes but not downvotes, another one that allowed for various positive flags like helpful, funny, whatever, the way Slashdot did) – we eventually turned them off for good.

                              All of them had a negative impact not only on the community – which, 15 years of Facebook later, is probably easy to understand – but they had a negative impact on the moderation process, too. We routinely had to weigh obvious decisions against metrics that didn’t tell the whole story (e.g. banning users who slipped subtle neo-Nazi crap into their posts on a 400-page topic and rarely got called out on it because there were like 10 people keeping that topic alive anyway vs. not banning users expressing an unpopular opinion about a recent game or whatever and getting downvoted to hell).

                              There’s always a point at which you admit that the metrics just don’t tell the whole story, like the one above (I remember the systemd post, too). After that point, no metrics tell the whole story anymore. If you have to decide, for every post, if the metrics are trustworthy or not, then you’re already in subjective land, and the metrics only enforce a decision that’s already made. Dumping the metrics entirely at least enables some more freedom to articulate your thoughts and make a good call.

                              Large social networks, like Facebook and Twitter, need to show metrics because they depend on projecting an image of an objective information dissemination platform, otherwise the ad funding dries up. And even in their case it’s bullshit, and they gather more stats, and make more automated decisions, than anyone else. I don’t think acknowledging the subjective nature of mod actions would be hurtful for lobste.rs in any way. Many of us are here precisely because things don’t work the way they work on FB or HN – doing things exactly the way those platforms don’t do them, and could never do them, sounds like a good call ;-).

                              1. 3

                                It’s funny you mention Slashdot: I’ve always been interested in their moderation/meta-moderation approach and wonder why it hasn’t caught on in more places.

                                I think metamoderation could work well here. Present comments with churn, positive or negative, and have the community decide if the vote was appropriate. If the community says “you, user, are using your flags incorrectly”, perhaps they decay in value?

                                1. 5

                                  I wasn’t specifically talking about the metamoderation part, but Slashdot’s system has a problem related to that of downvote-based systems: when allowed to do something other than reply, butthurt users will abuse the flag system, too. If someone expresses an unpopular opinion, it won’t be downvoted, but it will be flagged as “flamebait”, “troll”, “redundant” and “offtopic” without any consideration, because that’s just what mobs do – if booing (downvotes) isn’t available, they’ll take slogans (flags) as well.

                                  I know this sounds cold-hearted but it is what it is, I’ve been a butthurt user who acted irrationally more times than I can count, and I still find myself indulging in flamewars and the like even when I’m perfectly aware it’s stupid. I try to keep away from flags for this precise reason. Flames are a whole different story :).

                                  That being said, it’s worth remembering that Slashdot’s policy dates from a whole other era. I think many younger people have slightly different exectations from moderation these days, shaped by large social media platforms and the like.

                                  Any moderation policy is going to have some impedance mismatch. Some people are going to find it intolerable, and many of them will be smart people who have a lot of interesting things to say. Such is life.

                                2. 1

                                  I’d love to know why someone thought it might be spam, but since there’s no way to appeal flags and no way to know who flagged a comment, that’s anyone’s guess.

                                  I imagine one could have a system where the flags would be required to be accompanied by a motivating comment by the flagger, only visible to the receiver, and perhaps moderators.

                                3. 1

                                  I am convinced from my use here, HN, /. - using user input via ‘downvotes’ as any kind of trusted heuristic about the quality of a comment, is a stupid fucking idea. It’s never been done well, even here, which is already better than most places.

                                  How would you do it then? You can’t expect moderator(s) to be on top of every thread, so you need some way to alert them that something’s up. AFAIK using downvotes (which Lobsters doesn’t really have, just “flags”) is still the best way to do that.

                                  1. 12

                                    I agree, I think lobste.rs is basically the best possible solution I can imagine. It has upvotes to show support, but not downvotes to show “disagreement”. Instead, it lets you flag comments for being off-topic, spam, troll, unkind or me-too; I suspect that the threshold for “I disagree with you, so I’m gonna flag your comment as a troll” is much higher for most people than the threshold for “I disagree with you, so I’m gonna downvote you”. It’s not like actual moderation decisions are made automatically based on the flags.

                                    To be honest, the only real issue I see with the lobste.rs system is that the message is so harshly worded. I wouldn’t even be against the current low flag limit if it just said something like, “Your recent comments have been heavily flagged. Maybe you should consider taking a break to cool down”. Maybe it would be nice if it also took into account the ratio between flags and upvotes, rather than just the flags. But it’s where the banner suggest deleting your account that it really goes off the rails IMO. It’s also a bit weird that it suggests contacting a moderator, when the moderation team clearly doesn’t have the time/patience/desire/whatever to respond to inquiries about it.

                                    1. 33

                                      If we must have such a warning, which I wouldn’t be in favour of really, then I’d phrase it as “Your comments have been flagged a lot, this may or may not be a problem but here are your comments to review; kindly take a look and see if there’s something you could have done better” or something to that effect. Right now, and in your suggestion as well, it kind of assumes you did something wrong, which may not be the case at all.

                                      1. 9

                                        I would also change the background from red to something more neutral. It would still be visible, just not that “alarming”.

                                        1. 5

                                          This is really nicely worded and I can’t agree with you more. Cooling off assumes it was a heated debate, which itself might not be bad, yet the original text was quite aggressive in blaming the recipient, instead of following though that it might have been an honest mistake, or even no mistake at all.

                                        2. 4

                                          I suspect that the threshold for “I disagree with you, so I’m gonna flag your comment as a troll” is much higher for most people than the threshold for “I disagree with you, so I’m gonna downvote you”

                                          I suspect so too, but maybe i’m just projecting.

                                          What feels weird to me about Lobsters flagging system (or at least of the impression i get of it form reading this thread) is that while flags definitely have a cost for the flagged person, they seem to not have any cost on the flagging one? If that’s true, then i think that’s a glaring problem and should be addressed. Someone that’s mass-flagging comments should be as much a red flag for moderation as someone who gets mass flagged.

                                          Regarding the wording of the flag notice itself, i completely agree with others in that it’s quite bad and should be improved in tone and clarity (and probably in color too).

                                          NB: take this comment with a grain of salt, as i’m mostly a lurker here and not much of an active member :)

                                          1. 2

                                            while flags definitely have a cost for the flagged person, they seem to not have any cost on the flagging one?

                                            I got told-off once for flagging something that I shouldn’t have (the mod was correct), though I also didn’t understand that flagging actually got a human involved. My mental model was more like a downvote (from other comments here, I don’t think I’m the only one). So I felt bad about wasting a mod’s time. It probably says how flags work somewhere on the site, but it’s not on the “flag” dropdown :)

                                            Maybe there should be a low limit on flags-per-week, or something like that. You could get really economicsy and a debt system - if you’re out of flags, and you see something you really think should be flagged, well that’s going to put you in flag-debt and cost you two of your flags from next week. With a limit on how far into flag-debt a user can go.

                                            And or some down-weighting of users who flag heavily vs those who flag rarely.

                                        3. 7

                                          As @hauleth correctly points out, the issue is not that people can signal they see a problem with a post.

                                          The problem is assuming that signal is (a) trustworthy and (b) even remotely close to correct.

                                          The idea that people don’t downvote (or flag, in lobster’s terminology, the effect is the same) comments simply because they disagree with the view, is laughable. It definitely seems to happen less here than the orange site, but that’s like saying America has less gun violence than a literal war zone, so there is no problem.

                                          As I said, Lobsters gets a lot of things right, and it wouldn’t take much to improve it.

                                          The threshold for the warning message definitely should be smarter - a fixed number of flags makes zero sense if the goal is to have other users feedback be meaningful. 100 people upvoting and 11 people marking as ‘off topic’ or ‘troll’ because they don’t like the content, doesn’t really signify “you should reconsider your words” to me, unless of course the goal is an echo chamber.

                                          If a post doesn’t go below “0” effective ‘score’, it should not qualify, and even then I’d expect a much higher threshold than 11 such instances.

                                          As multiple people have said, the message itself is just bizarre right now. If you have to have a message it should be a lot more aware of the context of how it’s probably being read.

                                          If someone is genuinely just trolling, the message won’t mean shit to them anyway, they’re not likely to stop because of it.

                                          1. 4

                                            That this warning is not great because of the wording and threshold is something we can quickly agree on, as I already expanded on in some other messages in this thread.

                                            I’m not so cynical about the value of downvotes in general though;I don’t think that “flag for disagreement” are “flag for unconstructive” mutually exclusive. We’re all more sensitive when someone is being an ass about something we disagree with and less sensitive when we do agree with it.

                                            It’s a bit of a tricky balance; early today I saw a thread where an author was just being obtuse IMHO, responding with short messages that were essentially just refutations instead of actually having a conversation. I considered flagging it as it’s not a constructive conversation, or … because I don’t agree with it? Kind of both. I didn’t end up flagging it btw.

                                            I did flag another comment a few days ago which consisted of little more than “oh, you must not have understood it, let me explain it to you again like you’re an idiot who needs to be educated”. It was actually a fairly substantive comment, but also very condensing and not constructive. At that point you’re just being an ass, so -1 troll. I probably wouldn’t have if I had agreed with the gist of the post.

                                            And this also works two ways. I mean, Drew DeVault got plenty of upvotes as well even when he was demonstrably outright lying in his posts just because people vaguely agreed with the sentiment.

                                            Overall, “+1 because I agree with it” is actually a far bigger issue than “-1 because I disagree” IMHO.

                                            1. 3

                                              You’re right. I don’t really agree with the concept of simple ‘upvoting’ or ‘downvoting’. I think it encourages knee-jerk “ooh I agree with one sentence so clicky clicky” responses, rather than requiring people to actually articulate when they agree or disagree with something.

                                              Of course then you end up with “+1” etc type comments.

                                              But the bigger issue IMO is still the conflation of agree/disagree and “this is inappropriate”.

                                              Flagging something means a moderator should intervene and review the comment. It should be unrelated to whether the person agrees or disagrees with the content.

                                              1. 4

                                                I don’t really agree with the concept of simple ‘upvoting’ or ‘downvoting’. I think it encourages knee-jerk “ooh I agree with one sentence so clicky clicky” responses, rather than requiring people to actually articulate when they agree or disagree with something.

                                                How would you sort comments then? Perhaps Lobsters is small enough that it can get away without them, but on HN with hundreds of comments it gets hard and you need some form of mechanism. In spite of the problems with voting, I don’t really know of anything better.

                                                1. 3

                                                  Posting order (i.e. chronological) wouldn’t be terrible.

                                                  On a small site like this, sorting by ‘agree’/‘disagree’ is probably not necessarily as bad, it that’s all it’s used for.

                                                  On the orange site the problem is that they encourage ‘downvote to disagree’ and then hide downvoted comments both visually, and then literally.

                                                  If that’s not the poster child for group-think and echo-chambers, I don’t know what is.

                                                  1. 4

                                                    I want to say that I’m reading this whole discussion and I appreciate it, though I’ll resist the temptation to weigh in on every single point.

                                                    Lobsters is what it is and I think removing the use of upvotes to sort comments would significantly change the site and the kinds of discussions it’s good for. Many people would leave. When I see people building their own new spaces, however, I do advocate for chronological order. I think it’s very difficult to have anything that even remotely resembles a game mechanic, without attracting users who treat social interaction as a game that they want to win.

                                                    1. 1

                                                      You’re probably right that removing upvotes would change lobsters somewhat. Perhaps then the solution is the downvote mechanism that I detest so much, because if it’s purely attached to sorting order, that’s still a better outcome than having posts flagged simply because someone disagrees.

                                                      1. 1

                                                        Would it be possible to display separate upvote and downvote counts, but still sort by the sum (“overall score”)? That way voting still does affect reading order, but the UI makes it feel less onerous if you’ve been downvoted. In essence, hopefully normalizing a UI pattern to indicate disagreement quickly.

                                              2. 1

                                                And this also works two ways. I mean, Drew DeVault got plenty of upvotes as well even when he was demonstrably outright lying in his posts just because people vaguely agreed with the sentiment.

                                                Is the lying still demonstrable, or was it only demonstrable back then?

                                                1. 8

                                                  Stuff like this (and some more on the same topic at HN), and stuff like this. There have been some other discussions as well. I can’t be bothered to track them all down.

                                                  1. 2

                                                    I’m sorry to say it, but the web browser scope looks less like lies and more like methodology that you do not like. I cannot judge the other one, though.

                                                    1. 5

                                                      I’ve looked at now 100+ documents from that list. Not a single one has had actual content related to the web standard.

                                                      That’s not a minor methodology error; that’s just completely wrong and he’s more than smart enough to see that too, especially after multiple people pointed it out to him. An honest response would be to fix and correct it.

                                                      1. 1

                                                        I disagree. At the very least, a person still has to sift through all of those documents, even if they don’t have to read them.

                                                    2. 2

                                                      “Demonstrably outright lying” doesn’t fit what I see here. Maybe there were better examples at the time; I know much of the record was lost when drewdevault was banned due to Lobsters’s policy of deleting posts.

                                                      1. 5

                                                        He deliberately said things that were not true and defended it with “but my point us correct anyway”; I don’t know how to call that anything else than lying. Granted, he’s probably just a victim of his own anger and bias, but that’s a poor excuse and the end result is the same.

                                                        Anyway, this thread isn’t about Drew, so I’ll leave it at that.

                                                        1. 3

                                                          Deliberate outright lies could be demonstrated by a direct quote of the lie. What I see is a disagreement over whether an estimate is fair and what it means.

                                                          1. 9

                                                            The estimate makes a really serious methodological error, one that can scupper an otherwise strong paper. It’s fine to make mistakes, but doubling down on them is bad.

                                              3. 3

                                                I think the keyword there is trusted heuristic. No-one says that downvotes/flags cannot be one of the metric that there is something wrong, just it shouldn’t be used to “automatically notify users”. Human interaction for showing “big red banner with “go f… delete account” should be required.

                                                1. 3

                                                  It seems to me that the problem is determining who are the trolls - eg the person criticising Go, or the Go fans downvoting the criticiser. One solution might therefore be to limit the downvote to never less than -1, and greyed. Downvote trolls might be satisfied by this enough to not flag, and anything serious would still get flagged, and genuine criticisers wouldn’t be harassed by people who can’t handle criticism of their favourite whatever.

                                                  1. 2

                                                    I don’t know if you’re talking about a specific discussion, but in general I find Go discussions tiring because it’s always the same “Go bad” arguments over and over again, whether that’s relevant to the story posted or not. It’s really tiresome.

                                                    If you don’t like Go then that’s fine, but maybe you should be careful interjecting on Go stories unless you really have something of value to add. I don’t go around “C++ bad” or “PHP bad” on every C++ or PHP story.

                                                    I think the same applies to Rust from what I’ve seen on occasion, although I don’t read most Rust stories so I’m not sure.

                                                    1. 1

                                                      Your response seems to have nothing to do with my comment.

                                              4. 12

                                                Previous: Flagged comment warning should have tiers.

                                                IIRC there were some other discussions as well, but I can’t find them right now. I actually thought this warning got removed last year, but it seems not.

                                                I have the impression false positives are fewer since the “incorrect” flag reason got removed; I used to get this warning fairly regularly before that, but haven’t since.

                                                According to the standing page (https://lobste.rs/u/arp242/standing, put in your own username in there) you need to net 11 in the last month to see that page. End up in two or three conversations where one or two people get their panties all in a knot, and yeah … say hello to your 11 flags.

                                                Either way, automatic moderation never really works all that well IMO, or at least should have a really high bar. There is automatic moderation on Stack Overflow (and other SE sites), but the bars are so high that if you hit them, you almost certainly deserved it. And before you get to that point, you usually get flagged in the moderator interface first. IIRC there isn’t even a way for moderators to override these bans, because it’s simply not needed.

                                                I don’t know the details of the single person who has 59(!) flags, but that’s really a excessive outlier (and almost certainly not burntsushi, who is probably close to those 11 flags) so doing something about that automatically might be okay. But 11 flags in 30 days seems really low. And given there are just 7 users in total who see this warning it seems to me that automating this costs most than it’s worth. Lobsters isn’t that large.

                                                1. 2

                                                  IIRC there were some other discussions as well, but I can’t find them right now. I actually thought this warning got removed last year, but it seems not.

                                                  It was shown on the Replies page, which was offline for performance reasons for a long time.

                                                  I’m probably one of the few who took a peek at my /standing page nevertheless.

                                                2. 5

                                                  I can promise we’re aware that the voting/flagging system penalizes controversy. The formula doesn’t have any way of knowing which posts and comments are difficult-but-necessary conversations vs. which ones are behavior that should be changed, but we do take it into account behind the scenes.

                                                1. 7

                                                  Dealing with “field of a field” is what kills pluralization in languages that do not support it natively.

                                                  Dealing with the multiplicity of a field is not a big deal when dealing in a imperative way with a single level of depth (print(user.team) becomes user.teams.each {|team| print(team)}). The real issues arise you need to access the “field of a field” in a language that does not natively support “plural-first” expressions (like XPath, see other comment).

                                                  Suppose you want to extract the name out of the (single) Team to which a user belongs. Simple: user.team.name"RedTeam".

                                                  Now suppose a user can belong to multiple teams, like in the article. user.teams.nameNoMethodError: undefined method name’ for []:Array`.

                                                  OK, let’s change that to user.teams.map(&:name)["RedTeam", "SkyTeam"]. Works, but you can feel that it is not as well supported as the single case.

                                                  But wait, why does a team have a single name? Let’s pluralize the team name as well. user.teams.map(&:names)[["RedTeam", "SecurityTeam"], ["SkyTeam"]]. Again, it works, but it is much hard to process. Should we now process the team tames individually (as a flattened array) or by team (carring around arrays of arrays)?

                                                  And once you introduce optionality all these things become even more complicated.

                                                  Language support is necessary when you want to deal in a nice way with the pluralization of fields. But which programming languages do count as “plural-first”? I know of XPath. Which other languages are there?

                                                  1. 5

                                                    I think Haskell + one of the various lens libraries could approach this, with the caveat that going from “one” on “many” in a field would still require changing existing “lens expressions” (which loosely resemble XPath) unless you wrapped all your fields in a size-1 container (like the Identity functor) from the beginning.

                                                    If you did that, you could change the Identity into Maybe or [] and still use traverse to “go through” that container and change it, because all of those containers are Traversable.

                                                    1. 3

                                                      But which programming languages do count as “plural-first”?

                                                      Does jQuery count as a language? /s

                                                      APL and its descendants maybe. But they are far from the kind of languages into which we would normally encode business rules today. I cannot think of a mainstream language that could handle this “field of a field” problem you identified in a way that is as simple as the singular case.

                                                      My most recent experiences dealing with these sort of pluralization problems have not been so traumatic though. I think what really helps is to try to do the change incrementally. E.g., implement the pluralization at the lowest level (e.g. DB schema) and then switch the singular code to be implemented in terms of this new plurality (e.g. have a User#team method in the model layer that would do teams.first) and keep all the the rest of the code that relies on the singular assumption. You can then start moving away from that singular assumption piece by piece, or even start implementing the new functionality that required plurality, without it being a huge headache.

                                                      1. 3

                                                        jq.

                                                      1. 14

                                                        I don’t really agree with your take on webfonts; I use it on my personal website because … I think it just looks nice. Call that “branding” if you will, but I don’t think there’s anything wrong with making your site look nice according to your personal aesthetics. You may dislike these aesthetics, but I don’t really subscribe to the “functionality over form”-ethos.

                                                        This adds about 140k, which is comparatively a lot considering the actual content is ~35k (13k gzip’d, and depending on page length), but it’s not really that large and it’s optional – the site will work fine without it. It’s still small enough to be in the “250k club”.

                                                        One of the great features of the web is that you can override the site’s choices if you don’t like them. This is what “reader mode” is all about, but I tend to use a little bookmarklet if I don’t like the font size, colour, or style and which preserves the layout and such:

                                                        javascript:(function() {
                                                            document.querySelectorAll('p, li, div').forEach(function(n) {
                                                                n.style.color = '#000';
                                                                n.style.font = '500 16px/1.7em sans-serif';
                                                            });
                                                        })();
                                                        

                                                        This is really simple, but works well on ~90% of websites, the biggest omission being that it doesn’t deal well with dark background colours (should probably spend some time on that, since I really hate “dark mode” and will typically just close a site with a dark background as it’s so hard to read for me). You can get a lot more advanced with stuff like Helperbird if you want.

                                                        More practically, there are differences between font metrics on various platforms, and “word” in font A may render at 20px wide, but 22px wide in font B. I use DejaVu Sans Serif instead of Arial, which is a bit wider, and some labels and the like can break. And “12px” in one font may be quite legible, but difficult to read in another font. Different fonts also work best with different line-height values. These aren’t really big issues on personal sites and the like, but if you build an UI then it can become an issue, and “just rely on whatever the user wants as font-family: sans-serif doesn’t really work all that well.

                                                        1. 9

                                                          In my opinion, web fonts kind of suck. You’re just adding multiple seconds of load time before the text shows up, and it the network happens to be slow, you’ll get a flash of text with one font before it switches to the web font. Just not a very good experience. The amount of times I’ve sat there for seconds waiting for text to show up after everything else has loaded, due to the extra web font request, is infuriating.

                                                          Just trust the user’s browser to have good default fonts.

                                                          Of course this might not be the best idea for web apps with things like labels which must be of a given size, as you point out. But this is for text-based websites like blogs.

                                                          1. 3

                                                            Yeah, this can be an issue, but you can improve on that with font-display (optional or fallback). With the default of block there’s a 3s blocking timeout, but with fallback it’s more like 100ms which is a reasonable compromise. Also not loading 3 different webfonts in regular, bold, and italics helps (you can definitely overdo it), but ~140k is still reasonable even for slower connections (especially if you self-host it so you don’t have the extra overhead of DNS/TLS/HTTP).

                                                          2. 6

                                                            I don’t think there’s anything wrong with making your site look nice to your personal aesthetics.

                                                            I totally agree with you on this, however I don’t think the solution is to use a webfont. My own websites use “monospace” and “sans-serif” as the only fonts, and then I tweak my system/browser settings (using fontconfig) so they map to my personal font tastes. This way, my website looks exactly as I want too, and everyone can make it look however they want by setting their own font mapping. Here is my ~/.config/fontconfig/fonts.conf:

                                                            <?xml version="1.0" encoding="UTF-8"?>
                                                            <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
                                                            <fontconfig>
                                                              <!-- Override the ugly helvetica font too… -->
                                                              <alias>
                                                                <family>Helvetica</family>
                                                                <prefer><family>IBM Plex Sans</family></prefer>
                                                              </alias>
                                                              <alias>
                                                                <family>sans-serif</family>
                                                                <prefer><family>IBM Plex Sans</family></prefer>
                                                              </alias>
                                                              <alias>
                                                                <family>monospace</family>
                                                                <prefer><family>IBM Plex Mono</family></prefer>
                                                              </alias>
                                                            </fontconfig>
                                                            
                                                            1. 6

                                                              But then it looks nice for the 0.1% that take the effort to do this (and can stomach fontconfig’s XML), and not for the vast majority of people reading your site.

                                                              CC: @Seirdy

                                                              1. 7

                                                                chances are the vast majority of people won’t share your aesthetic sensibilities and will appreciate seeing a font they are familiar with (and looks good with their system settings and screen resolution)

                                                                1. 8

                                                                  The problem is that the vast majority of people (probably even the majority of users on this site, including me) don’t bother setting fonts in their browser. Plus, fonts can convey a style/mood for the site, which is nice to see when well-done.

                                                                  Plus plus, power users can have their browser ignore fonts on a website, not download them, and just use their chosen fonts.

                                                                  1. 2

                                                                    The problem is that the vast majority of people (probably even the majority of users on this site, including me) don’t bother setting fonts in their browser.

                                                                    I figured this response would come up, so I addressed it in a dedicated section.

                                                                    Fonts can convey a style/mood for the site, which is nice to see when well-done.

                                                                    This makes sense for more complex websites, but I’d argue that textual websites should be personalized with content rather than form.

                                                                    Plus plus, power users can have their browser ignore fonts on a website, not download them, and just use their chosen fonts.

                                                                    I addressed this in another dedicated section.

                                                                    1. 3

                                                                      I personally think that things like Font Awesome are a problematic hack. The very fact that system fonts don’t have a good fallback for the symbols should really tell us something—namely that we’re abusing fonts. That said, if you need Font Awesome, just set the browser to a patched font with FA symbols.

                                                                      Back to the main discussion, though. Likely the vast majority of people on the internet enjoy a nice-looking web page—i.e. a website that employs good graphical design. And the authors who want to design them often don’t do it for branding, which implies a desire for recognition, but rather for quality. The authors of “simple” pages (not companies) just want to think their own site looks nice. So there’s a demand for these stylized sites, and the creators of them don’t have to have some kind of evil, manipulative intention.

                                                                      In general, asking people to stop loading custom fonts makes me think that browsers need more work, or that some layer other than the site itself is at fault. The whole point of a browser is that it will enable you to browse and view the Web how you want. If a website suggesting a font to you breaks everything, then we have bigger problems.

                                                                  2. 4

                                                                    While there is a place for consistency, i think there’s also a place for personal style. For example, when visiting someone’s house, i like to see that it has its own style, different than mine. And in a similar way, i like seeing people’s styles when visiting their personal websites. It makes them more memorable to me than if they all looked the same, like Medium or FB posts. And it can also give some nice ideas to steal to try out on my own projects/house.

                                                                    But i guess there’s something to say about consistency too. After all, books can “all look the same” in the sense they they are only text, but of course their content can be vastly different. So, i don’t know, maybe these two different viewpoints can co-exist? Maybe have some personal presentation, but also let readers easily “extract” the content into their own format/devices?

                                                                    I feel i’ve been doing something like this for a while: when reading articles on my computer, i usually use the page’s style instead of the browser reader mode, but sometimes i send the article to a e-reader to read later (using this extension), which strips all the website personalized styles and converts the article into ebook-friendly format.

                                                                    1. 3

                                                                      Thus far the only feedback I’ve got “hey, looks nice”, and the only negative feedback has been on some minor technical issues. Personally I’m rarely bothered by a webfont unless it’s some crazy stuff like a very thin font (or a low contrast colour). This probably applies to most people, and the people who are really bothered by it are very few, and they all hang out on sites like Lobsters. I don’t think it’s representative for all people viewing your site.

                                                                      1. 1

                                                                        What is the DPI of your monitor

                                                                        1. 1

                                                                          I used a 14” 1366x768 screen up until a few weeks ago, and I have a 26” 1920x1080 screen. I’m too lazy to calculate the exact DPI, but neither are very high. I’m not sure how this is important though?

                                                                          1. 1

                                                                            IME web font hinting is worse than hinting on native fonts, which is more of a problem on low DPI screens. But I guess people get used to it.

                                                                            1. 1

                                                                              Can’t say I ever noticed this, but to be honest I don’t really have a good eye for these kind of things either. I’m happy with just “DVD quality” for films too 🤷‍♂️

                                                                            2. 1

                                                                              Serif fonts aren’t usually as good on low-DPI screens, which is why computers tend to use sans-serif fonts.

                                                                              1. 2

                                                                                Only at small sizes, and not even with all serif fonts. “Serif fonts don’t work well on low DPI screens” is extremely simplistic to the point of uselessness. And it also has nothing to do with webfonts (actually, with webfonts you can choose a serif font that you know will work well for your particular use case).

                                                                                1. 1

                                                                                  Only at small sizes, and not even with all serif fonts. “Serif fonts don’t work well on low DPI screens” is extremely simplistic to the point of uselessness.

                                                                                  True, but browser-default sans-serif fonts are also far more likely to display well than custom fonts, in my experience. Far too many websites with custom fonts end up being harder to read. For example:

                                                                                  Thus far the only feedback I’ve got “hey, looks nice”, and the only negative feedback has been on some minor technical issues.

                                                                                  Your site looks pretty good (I knew you seemed familiar!). I’m not sure I’m a fan of the font choice, though.

                                                                                  Here’s a side-by-side comparison of how your website looks on my laptop with its default fonts and with my preferred sans-serif font: https://seirdy.one/misc/arp242.net_fonts.png

                                                                                  I didn’t zoom out; that’s how it looks out of the box on my default browser with my dark-mode addon. The italic text–especially the small italic text–is much more readable in sans-serif. That isn’t even the lowest-resolution screen I use; if I used one of the campus library’s spares, the italic text would probably be unreadable.

                                                                                  Low-res screen users aren’t the only demographic with strong font preferences. Another example: dyslexic users might set their preferred font to Dyslexie; it’s not the prettiest, but it does help with this disability.

                                                                                  Branding isn’t evil, but it can have big trade-offs. I’d rather have text-centric websites distinguish themselves through content, and allow users to dictate presentation.

                                                                                  Also: would you be okay with me updating the article to include the screenshot of your website? I’ll pair it with a shout-out since I have found some interesting content there in the past.

                                                                                  1. 2

                                                                                    Low-res screen users aren’t the only demographic with strong font preferences. Another example: dyslexic users might set their preferred font to Dyslexie; it’s not the prettiest, but it does help with this disability.

                                                                                    Sure, I appreciate that, but one of the great features of the web is that it’s all so easy to modify with client-side tools. For example with the bookmarklet I posted earlier, or the myriad of extensions that are out there. I’m not “forcing” my font preferences on anyone, or “dictating” the presentation, they’re just a default that’s fairly easy to alter if you want, just as you modified the colour scheme.

                                                                                    Arguably, browsers should capitalize a bit more on this; the “reader mode” that Firefox and Safari come with are a bit too invasive IMO since it mucks with the layout too much. I worked a bit on a less invasive widget/extension last year which swaps out just the colours and fonts, but never finished that.

                                                                                    Branding isn’t evil, but it can have big trade-offs.

                                                                                    I don’t really see it as “branding”; it’s just a font I like. I set up my email client to use the same font, as well as the “light-weight reader mode” extension that I mentioned earlier.

                                                                                    I wouldn’t use a non-standard font like this on a product website or the like by the way, but my personal website is my, well, personal space. While “conveying ideas” is certainly part of the reason I write stuff on there, the main reason is more about personal development and ordering my own thoughts on matters. I was happily putting stuff up for years without anyone taking much notice or reading it.

                                                                                    If I had my way then I’d also enable the old-fashioned ligatures on the main body text (right now it’s just for headers), as I feel it looks handsome 😅 But since most people aren’t used to it, it’s probably more distracting than anything else.

                                                                                    Also: would you be okay with me updating the article to include the screenshot of your website? I’ll pair it with a shout-out since I have found some interesting content there in the past.

                                                                                    Yeah, sure, I have no problems with that. Thanks for asking.

                                                                      2. 1

                                                                        I addressed this in the article in a dedicated section.

                                                                        Furthermore, fontconfig isn’t the only way to change fonts; most browsers’ settings pages let you change default fonts with a drop-down menu that’s a bit less intimidating for non-technical users.

                                                                    2. 3

                                                                      Edit: I updated the article to contain this information. Diff.

                                                                      I agree that the default sans-serif font family doesn’t look good, which is why I change it in my computer’s gtk3/fontconfig settings. Now every website that uses sans-serif will have my preferred font. By setting your default font family to sans-serif, you automatically use the font family of the user’s browser. Users who care very much about fonts will be pleased to see their favorite font automatically selected.

                                                                      I should address this more clearly. Thanks for the feedback!

                                                                      1. 1

                                                                        As for the size, you can consider subsetting your font with pysubset. On my website, I get 23k for the text font (regular and italic) and 7k for the code font (regular). It also enables you to start from a font with extensive coverage to get most characters.

                                                                        Another argument for a web font is that you can ensure the text font and the code font matches. You can’t really get that with a font stack and you definitely don’t get that with the default fonts. Many websites apply a size correction for the code font to make it fit more with the text font. Code font also often have a background to make it less visible there is a mismatch. There is also often a difference with boldness. In my case, I have matched both boldness and x-height of text and code fonts and I find it easier to read this way.

                                                                        1. 1

                                                                          you definitely don’t get that with the default fonts.

                                                                          Most OSes and browsers set default sans-serif and monospace fonts that fit together, and users are free to change these if they like.

                                                                          The article also explicitly addressed how to change colors (such as code backgrounds) properly. Nowhere in the article did I mention font sizes. Maybe I wasn’t clear enough.

                                                                          The article itself practices what it preaches; it uses default fonts without the resizing issues you describe, at least on the graphical browser engines I tested (Blink, Webkit, Gecko, Links, Netsurf, Dillo, and Trident [Trident tested via webpagetest.org]).

                                                                          1. 1

                                                                            Most browsers default to Courier and Helvetica or a variation (Courier New and Arial). They absolutely do not match. Courier is a slab serif font. Remove the gray background and you should see there is quite a mismatch between the two.

                                                                            1. 1

                                                                              I’ve since replaced the grey background with a soft border to better accommodate users who override the default fg/bg colors; try reloading and skipping the browser cache. I don’t see too great a mismatch, but this probably comes down to personal preference. And the best way to satisfy users with the strongest personal preferences is to use their preferred fonts.

                                                                        2. 1

                                                                          The problem with very many sites using web fonts is that a) they don’t specify any fallback fonts, or at least b) they are not designed with the fallback fonts in mind.

                                                                          I block all web fonts (except icon fonts, which don’t even get me started…) in my browser, and many sites look terrible.

                                                                          1. 2

                                                                            That just seems like an implementation defect rather than a problem with the concept of webfonts. I always test with webfonts disabled to make sure the results are reasonable.

                                                                        1. 8

                                                                          I’d have a test like: t.equal(ss.gamma(11.54), 13098426.039156161);

                                                                          record scratch

                                                                          OK, that’s your problem right there. It’s well known that you don’t write tests like this: instead you always leave some margin for error in FP equality assertions.

                                                                          There’s difference between precision and accuracy. Just because IEEE doubles give you 52(?) bits of mantissa doesn’t mean those bits are all correct down to the LSB. And in cross platform code, like anything JS, you can’t even trust those bits will be 100% consistent from one platform/version to the next.

                                                                          If you make assertions like that test, you’re basically asserting that the implementation of every math function you call remains exactly the same, which is a bad idea. You’re testing stuff that’s not part of the contract of the API, basically.

                                                                          1. 12

                                                                            Did you read the rest of the post? It explains this, just less condescendingly. You write that “It’s well known” not to write tests like this, but where exactly are people supposed to learn that? Posts like this seem like as good a place as any.

                                                                            1. 4

                                                                              Yeah, for sure. It nearly always comes off as gatekeepey and obnoxious to write “It’s well known that …” (comparable to the “It’s obvious that …” in a lot of math textbooks), and even when it doesn’t, it is never to the benefit of the reader. So cut it out if you do it!

                                                                              I learned something from this blog post because I’ve run into this exact behavior when writing unit tests. I used the epsilon approach to dealing with it mostly because that was the only way that made sense to me – glad to know that is a reasonable approach, and good to know about the others

                                                                              1. 1

                                                                                Well, I was told about floating point arithmetic’s gotchas at least on 8 different courses on the university. Is learning what you are doing gatekeeping? Such is life. ¯_(ツ)_/¯

                                                                                1. 4

                                                                                  No, learning is not gatekeeping. It’s the tone one uses to express that learned knowledge what can be perceived as gatekeeping. Some people are great at enthusiastically sharing their knowledge with others, which is completely different than simply stating “it is well known”, which sounds very much like “you should have already known this”.

                                                                                  About this topic in particular, i think it is totally reasonable to conclude that floating point operations are stable and well defined given the admittedly limited experience of noting that Math.sin(x) has always returned the same value when called with the same argument. It’s learning by doing, and that’s how many many people learn programming. Only when the result changes, because of a different browser or Node version, this assumption would be challenged, which i think is what the blog post is trying to convey :)

                                                                              2. 3

                                                                                I did read it; see my reply to @hwayne. I think the author misunderstands the nature of FP math: complex operations are always approximations, and roundoff errors always occur. (Trig functions are mostly computed as Taylor series, and there’s always a decision of how many terms to add before stopping.)

                                                                                Sorry for sounding snarky. This is a bit of a pet peeve of mine, but I shouldn’t have climbed on my high horse so readily.

                                                                                1. 1

                                                                                  where exactly are people supposed to learn that?

                                                                                  In just about any course on floating-point arithmetic. This error is not even a quirk of a hardware implementation. It shows that this person has never seen how errors propagate through FP operations, how FP works in the abstract (with all those (1 + ε) factors). It’s fundamental knowledge. Similarly, I wouldn’t expect an article about strcpy(3) causing buffer overflow in some situations or the discovery of two zeros in FP to get this much attention.

                                                                                  Posts like this seem like as good a place as any.

                                                                                  Learning programming from blog posts is a terrible idea, akin to learning programming from Stack Overflow answers. That’s how you learn trivia, not systematic knowledge. It’s also how you assimilate a lot of misinformation. Well-reviewed books (or lectures) are the way.

                                                                                2. 5

                                                                                  He explicitly discusses epsilons in the article.

                                                                                  1. 4

                                                                                    Yes, but only as a workaround for when you can’t afford to lug a custom JS reimplementation of the entire math library around with you. IMHO that’s the wrong way to look at it. Asking for accuracy down to the last bit in complex FP operations is not realistic. (For example, what happens if someone in the future finds a bug in that JS math lib, or an optimization, but can’t deploy it because it’ll break every use of it that expects perfect precision?)

                                                                                    1. 3

                                                                                      This is why the generally accepted modus operandi is to use binary coded decimal arithmetic for financial calculations, where “exact” solutions are needed (and usually only addition/subrtraction/mutiplication and in extreme cases division are used), and floating point arithmetic is used for engineering (as in real engineering, not ad-tech and div layout engineering) , where working with tolerances has been the norm since centuries.

                                                                                1. 8

                                                                                  “Unison is a language in which programs are not text. That is, the source of truth for a program is not its textual representation as source code, but its structured representation as an abstract syntax tree.”

                                                                                  I keep debating this idea and it seems to meet with lots of resistance. I love it, because it means we can have non-text-based editors and multiple text-based syntaxes, meaning you can write in (within reason) a style you enjoy.

                                                                                  You might write this code:

                                                                                  function sum(numbers: enumerable of integer) returns integer =>
                                                                                      numbers
                                                                                      |> Enum.reduce(0) { |acc, n| acc + n } )
                                                                                  

                                                                                  But when someone else goes to edit it, they see this.

                                                                                  def sum(integer[] numbers) : integer {
                                                                                      reduce(numbers, 0, lambda acc, n => { acc + n } )
                                                                                  }
                                                                                  

                                                                                  And when you come back to it - it looks exactly as you wrote it.

                                                                                  We’re already part way there with some languages having an agreed-upon style enforcing tool, e.g. ReSharper, IDEA-based editors, mix format for Elixir…

                                                                                  Here, though, we’re doing the opposite - saying style is up to you and it won’t affect anyone else.

                                                                                  Here’s another way someone might see - and edit - the code above. Similar in terms of syntax but different layout.

                                                                                  def sum( integer[] numbers )
                                                                                    : integer
                                                                                  {
                                                                                      reduce(
                                                                                          numbers,
                                                                                          0,
                                                                                          λ acc, n => {
                                                                                             acc + n
                                                                                          }
                                                                                      )
                                                                                  }
                                                                                  

                                                                                  This doesn’t change the higher level code structure, of course. If you implement the function using reduce(), it’s reduce() for everyone.

                                                                                  What, though, about diffs? Don’t we break them?

                                                                                  Actually no, I think we make them better. No more trying to see functional changes amidst a sea of formatting differences applied by a developer or an IDE/editor. I know people ‘shouldn’t’ make commits which combine both, but the reality is that they do.

                                                                                  An AST based storage system would mean that you’d never have formatting changes - and - crucially - Diffs will be in the style you prefer!

                                                                                  Just one more thing: You can indent with tabs, spaces, anything you like!

                                                                                  1. 2

                                                                                    I may be missing some important pieces, but this looks like the coolest tech story I’ve read in years.

                                                                                    Each coder could have their own code annotations if they wanted. Combine that with including the deployment environment inside the code? With the Erlang roots, you could write code and have it run any place from javascript in an html page to a massively-distributed cloud deployment, all either without changing anything (and having it scale automatically, presumably) or changing very little.

                                                                                    The cross-language thing is also amazing. The biggest downside I can see is that it would be possible to look at code and think it should work when it doesn’t. But hell, that’s what we have already today. With this setup, if you plug part A into part B, it’s always going to work the same way. There would be no such thing as CI/CD/etc pipelines and testing. There’d be no need for them.

                                                                                    You could work on a team internationally where each person had the code in their own native tongue and using the programming language of their choice, and it’s all integrated by default.

                                                                                    Amazing.

                                                                                    1. 4

                                                                                      I agree in that the idea has a lot of potential. I’ve known people who tried to implement some of this ideas on top of existing languages (e.g. “what if we could save Ruby code in AST format and then display it with syntax of choice”).

                                                                                      Another application I can think of this is localizing code to be less English-centric. It sucks that in order to learn to program, you also need to learn a foreign language, or at least a subset of it. It makes programming less accessible to a lot of people.

                                                                                      But I think that for this idea of coding with ASTs instead of text to have any substantial success, it would need such a level of adoption across all sort of media that it is practically infeasible. Because today source code is text, so it’s “compatible” with all media that accepts text. But if source code would be the AST that would not be the case.

                                                                                      Of course we could imagine our desktop environments and code editors knowing that source files for X programming language should not be displayed as text, but first converted to text using the user’s syntactic preferences and then displayed. And we could imagine teaching other tools such as git diff, less to do the same, or maybe implement replacements for those. But, could we also expect that messaging systems that allow for code snippets like reduce (+) 0 numbers to implement that logic such that I could see that snippet in a more familiar syntax here in Lobsters? Or what about code in articles, blog posts, ebooks, or even printed in physical books or on videos? Or what about programming classes, which syntax should they use?

                                                                                      I think having such level of syntactic freedom, but only on a limited range of media, would probably dilute the benefits of said syntactic freedom quite a lot. After all, code is for communication, and if we can’t communicate seamlessly, because at some point we realize we’re not “speaking the same language”, maybe it’s better to give up some of that personal syntactic freedom, in lieu of greater freedom of communication across people using a common lingua franca.

                                                                                      But IDK, the idea is still interesting! :D

                                                                                      1. 2

                                                                                        That’s a nice identification of the issues and some suggestions.

                                                                                        I wonder if we’re still just not talking about a load/save filter. The input, whether it’s from a code snippet tool or a repo, has a certain hash. Whatever tool you’re using also has a certain hash. As long as you had the symbol information handy (also a hash), shouldn’t there be some sort of lookup back and forth?

                                                                                        Maybe I missed something. Apologies if I did. I’m just spitballing. The insight here, I think, is that the hash and trees sit on top of whatever we’re doing anyway, and as long as we keep track of the users metadata at the same time, we should be able treat the code separately from how the user thinks of the code.

                                                                                        So at some point beyond the implementation details, this is all just a higher-level git, with matching, hashing, and so forth. The only difference is it’s at the meta level, and the underlying code must be pure FP. It fails otherwise.

                                                                                        Definitely fun to think about! :)

                                                                                        1. 2

                                                                                          Oh, thanks for the reply. It made me realize that I wasn’t connecting all the dots. I had read about Unison before. And also had discussed the concept of saving code as ASTs instead of text. But i hadn’t fully made the connection of the later with the idea of referencing by hashes.

                                                                                          And yeah, the two concepts seem to mash up together very nicely. Referencing things by hashes would definitely help in not falling into that sort of “uncanny valley” I mentioned of tools not understanding this. Because, even if the tool didn’t know how to display the code related to that hash, at least you’d have the hash to look it up :)

                                                                                          And, couple that with some URI protocol that browsers or other tools might be modified to understand and display properly, like unison:<THE_HASH>, and you get a pretty universal way of referencing these things (URIs are text, so yay: text again! :D).

                                                                                          Definitely fun to think about! :)

                                                                                          Definitely, yes

                                                                                    2. 1

                                                                                      Question: I think this looks really cool, but how do you think Unison will fly in practice? You seem to have a lot more insight into this stuff than I do. I wonder if it’s just going to be a cool academic idea that never really grounds out to any adoption because it’s just a few steps too far for people (although I guess this was also true of Rust, but Rust had the full force of Mozilla and a need for Gecko to improve).

                                                                                    1. 1

                                                                                      I tend to find lazy evaluation directly antithetical to performance. Am I mistaken?

                                                                                      1. 7

                                                                                        I don’t think that lazy evaluation is antithetical to performance, but it is hard to get right in a language. I think Haskell and Rust get lazy evaluation right most of the time in their respective domains (Haskell: everywhere; Rust: iterators and async/await), but it can be a bit tricky to debug for folks not expecting lazy evaluation. It does help reduce how much work needs to be done at runtime, and in some cases, dramatically reduce how many allocations are needed for a given unit of work.

                                                                                        1. 2

                                                                                          I think Haskell and Rust get lazy evaluation right most of the time in their respective domains (Haskell: everywhere; Rust: iterators and async/await)

                                                                                          A lot of modern languages (Rust, Python, Clojure, Elixir, even Java) have gotten far just by making lazy iterators first-class. To me this seems like a reasonable enough compromise; I guess I’m still confused as to what we gain by making laziness more pervasive and consequently harder to get right. Of course, pervasive laziness doesn’t make sense in any of the languages I mentioned since none of them enforce functional purity, but it doesn’t immediately follow in my mind that pure should mean lazy.

                                                                                          I’d be interested in seeing a good example of Haskell code that becomes more expressive/performant than its equivalent in another language thanks to laziness features that aren’t lists.

                                                                                          1. 4

                                                                                            I’d be interested in seeing a good example of Haskell code that becomes more expressive/performant than its equivalent in another language thanks to laziness features that aren’t lists.

                                                                                            IIRC, the second half of the paper Why Functional Programming Matters has a few examples of lazy evaluation as a means for better function composition, i.e., building more complex/interesting stuff from simpler parts. Bear in mind that some of these examples rely on generating infinite data structures, like all the possibilities of a board game, and then computing things over them, reducing them, pruning them, and finally only evaluating what is needed.

                                                                                            Even if the examples are not all that convincing, I highly encourage anyone who hasn’t already to read that paper. I found the explanations of the core concepts of functional programming very clear and inspiring, and the approach of focusing on purely on the code and its behavior instead of accessory stuff like types (I think the paper doesn’t even mention them) quite enlightening compared to some more modern approaches to FP :)

                                                                                            1. 2

                                                                                              Bookmarked the paper for later. Thanks!

                                                                                            2. 4

                                                                                              I’d be interested in seeing a good example of Haskell code that becomes more expressive/performant than its equivalent in another language thanks to laziness features that aren’t lists.

                                                                                              I’ve barely done any Haskell so take this with a grain of salt, but one benefit I’ve been told is that there’s no need to build seperate “streaming” APIs. Everything is streaming by default due to laziness — network interaction, parsing, decompression, etc.

                                                                                              1. 1

                                                                                                I’ve seen talks in which SPJ refers to laziness as “the hair shirt”: the metaphor here is that he finds it uncomfortable but having it in the language makes it easier for the community to stick with the functional purity convention.

                                                                                            3. 5

                                                                                              Yes you are mistaken. Laziness gives a bunch of performance; you do less work, even with simple/naive implementations. You also get composition of these implementations, e.g. quick select is take n . quicksort.

                                                                                              Want to explain why you think it’s directly antithetical?

                                                                                              1. 1

                                                                                                How true is that if you’re using an actually decent quicksort (one in place, on an array, not the toy example)? Does take n still benefit from lazyness? I think providing an actual function for that (like C++ does) will be more predictable and faster in the end.

                                                                                                1. 2

                                                                                                  In-place and lazy?

                                                                                              2. 2

                                                                                                People will say you are and then write 10,000 word posts on how to make it fast (by making it more strict) and how to detect memory leaks that are impossible to reason about.

                                                                                                1. 1

                                                                                                  Often the problem is that something in the program is already strict, for various reasons, so you have to start giving in and that unravels to “make X strict, make Y strict, make Z strict, alright you can stop there, ok don’t touch things”

                                                                                                  1. 4

                                                                                                    I think there’s a reasonable argument to be made that most code should be eagerly evaluated by default with some exceptions made for lazy evaluation. There’s a good reason why Idris and PureScript opted for eager evaluation as the default.

                                                                                                    1. 2

                                                                                                      As someone who worked on PureScript and have used it quite a bit professionally, it’s completely a concession to the JavaScript runtime. There’s a bunch of times you have to put up with code duplication because PureScript is strict. It’s not because it’s a good default; PureScript’s goal is to have simple JS output, therefore it has to be strict.

                                                                                                      1. 1

                                                                                                        Thanks for your insights! I also found Idris’ answer to why it isn’t lazily evaluated to be interesting as well: https://github.com/idris-lang/Idris-dev/wiki/Unofficial-FAQ#why-isnt-idris-lazy.

                                                                                              1. 3

                                                                                                Pretty fun to figure out how this works using Firefox developer tools. The hair and lace works really well for me, but the eyes seem a little dead, no?

                                                                                                1. 6

                                                                                                  but the eyes seem a little dead, no?

                                                                                                  Yes, they look super spooky on Firefox. The site in only compatible with Chrome really. From the project readme:

                                                                                                  Because of the artistic nature of this project I have not concerned myself with cross-browser-compatibility, so the live preview will most likely look laughable in anything other than chrome.

                                                                                                1. 3

                                                                                                  Microkernels. Micro services. Micro front ends. I have concluded that all micro things are all hype and best avoided. Reasonable rule?

                                                                                                  1. 1

                                                                                                    I’d sort of agree. At least in the cases of micro services and micro frontends (don’t know anything about kernel development), i think they can be avoided in most cases by having reasonable modularization within the codebase. If something is to be extracted into its own separate (non-micro) service or front-end, it should be because of an actual technical or organizational necessity (e.g., different domain, different lifecycle, etc), and a reasonably-modularized codebase would allow this separation to be made without that much pain :)

                                                                                                  1. 5

                                                                                                    Microservices make sense in some use cases:

                                                                                                    • You want to use a different language for a certain bit of functionality
                                                                                                    • You have a large number of dependencies for a project, which makes the monolithic approach no fun to work with (certain machine learning libraries can be a huge pain to install)
                                                                                                    • There is very little overlap between the two components and it improves your ability to monitor the system to separate them. (IE. I could run Thumbor on my main API, but its much easier to have it running on its own cluster)

                                                                                                    I’m curious, when do you like to use micro services? Or you prefer 100% monolithic?

                                                                                                    1. 5

                                                                                                      I’m curious, when do you like to use micro services? Or you prefer 100% monolithic?

                                                                                                      I’m not a microservices proponent; i agree with the article. But i don’t think that not going for a microservice architecture implies going 100% monolithic. You can have different services without going micro ;)

                                                                                                      For instance, a common architecture for websites nowadays is having an API backend as one service/project/thing, and the webapp frontend as another service/project/thing. I think this kind of separation, without going to ridiculous lengths of separating every functionality into its own microservice, makes a lot of sense. And it’s not a 100% monolithic solution, as you have the freedom of making architectural changes to either the frontend or backend services (like change the language/framework it is written in) without affecting the other.

                                                                                                      1. 5

                                                                                                        Yeah, there’s a big difference between a few sevices, and a few hundred services (uber style).

                                                                                                      2. 4

                                                                                                        As patrickdlogan points out above, you don’t really have to choose, since it’s a false dichotomy. It’s only about the size and responsibilities of the service, and that metric is absolutely relative, in the context of the developing organization.

                                                                                                        1. 1

                                                                                                          I second this. At my workplace there used to be two monolithic applications and they are getting converted into two microservices (billing and session management) and another big application (a backoffice app). It doesn’t have to be an all-or-nothing type of approach.

                                                                                                      1. 24
                                                                                                        var weAreConnected = Math.floor(Math.random() * 10) > 5;
                                                                                                        
                                                                                                        if (weAreConnected === true) {
                                                                                                          this.setState({
                                                                                                            isConnected: true
                                                                                                          })
                                                                                                        } 
                                                                                                        else {
                                                                                                          this.setState({
                                                                                                            isConnected: false
                                                                                                          })
                                                                                                        }
                                                                                                        

                                                                                                        What? It’s difficult to take the article seriously after that. Seems like a purposely obfuscated example for saying:

                                                                                                        var connected = Math.random() > 0.5;
                                                                                                        this.setState({isConnected: connected});
                                                                                                        

                                                                                                        And it’s not about not being fluent with JS either. This is just basic boolean stuff.

                                                                                                        1. 6

                                                                                                          The connected variable isn’t reused anywhere either so couldn’t you just do this?

                                                                                                          this.setState({isConnected: Math.random() > 0.5});
                                                                                                          

                                                                                                          I’d use a ternary statement for setting the color too, but I know some people don’t like those.

                                                                                                          1. 4

                                                                                                            The connected variable isn’t reused anywhere either so couldn’t you just do this?

                                                                                                            Yep, absolutely, in this simple case, i wouldn’t mind either way. But splitting the calculation into its own variable, even though the variable is not reused anywhere else, has some benefits:

                                                                                                            1. Each line is does a one simpler thing: first determine whether we’re connected using a random value, and then set the component state to that.

                                                                                                            2. The code is more debugger-friendly. You can easily tell the value of the connected variable before setting the state by stepping between the two lines.

                                                                                                            I’d use a ternary statement for setting the color too, but I know some people don’t like those.

                                                                                                            Well, ifs in JavaScript are not expressions, so i’d use ?: too :)

                                                                                                            1. 1

                                                                                                              I’d use a ternary statement for setting the color too, but I know some people don’t like those.

                                                                                                              Do you know why ternary statements would be frowned upon? I don’t like nested ternaries, but other than that I find them extremely useful and they aren’t really that hard to use…

                                                                                                              1. 3

                                                                                                                It’s because they’re often used with poor taste. I use them for one-line assignments all the time, but they’re sometimes used nested or with conditions/values complex enough that they span multiple lines.

                                                                                                                1. 1

                                                                                                                  The new do expression in the early parts of the standardization process will make this process much nicer if it makes it.

                                                                                                                2. 2

                                                                                                                  I had a CS professor from Bulgaria in college that would always chastise me for using them in C telling me “You’re being clever; be clear, not clever.”

                                                                                                                  1. 2

                                                                                                                    To me, any C code is clever, not clear.

                                                                                                              2. 6

                                                                                                                You’re just too much of a hacker. Not everybody can write this kind of code.

                                                                                                              1. 3

                                                                                                                @swifthand You’re completely correct re: never trust the client and such. I’m a big fan of this quote by thomas ptacek:

                                                                                                                I am wary of software security advice that leads with “don’t trust user input”, or revolves around “validate user input”. That principle has been the core of software security strategy for going on 20 years, and has bought us very little. In the real world, we have to tstart by acknowledging that the verb “trust” is situational, and that in some circumstances virtually all user input is “trusted” somehow. You could phrase this less tactfully as “Validate user input? No shit? Now what?”

                                                                                                                The security industry has banged the drum of sanitize everything and yet this stuff still slips by! And I’m in agreement with you that the majority of code bases aren’t written like the example I posted, however I’ve seen variations of that pattern in live code bases. Shitty code exists everywhere! Likely not written by those that read these types of posts on reddit / lobsters / et al.

                                                                                                                1. 1

                                                                                                                  Agreed. I am perplexed about String#constantize’s docs not having a big warning about it being a possible code injection vector, instructing that the string should always be validated. Or at least being tagged as “insecure/unsafe” in some way.

                                                                                                                  Skimming through the Rails docs, it seems that these security matters are not given the importance they should. Even ActiveRecord’s where only says:

                                                                                                                  Note that building your own string from user input may expose your application to injection attacks if not done properly. As an alternative, it is recommended to use one of the following methods.