Threads for dbousamra

  1. 5

    This was great thank you. Very motivating examples which is different from most monad tutorials

    1. 19

      Soundness is definitely a thing that can come up, though in handling tens of thousands of lines I don’t feel like I’ve hit it directly.

      On the other hand, Typescript’s type system is still the most useful typesystem I have ever used. The way unions, “everything is a dictionary”, being able to filter out keys and the like, and everything else work together mean that I can write business logic that handles really dynamic data shapes, and still get guarantees that are basically impossible in other languages without generating loads of wrapper types.

      For example just being able to inline declare a variable of having “type A and type B” is such a great way of allowing for new APIs.

      Ultimately Typescript not seeing typing as a mechanism for implementing the language execution semantics, but really as a checker of code validity, opened it up to really practical advantages.

      1. -2

        On the other hand, Typescript’s type system is still the most useful typesystem I have ever used.

        I have a canary of sorts which I use to guess whether I will appreciate a type system.

        1 == "1"
        

        The correct way to handle this is to issue a type error at compile time (or at least runtime if the language doesn’t have a significant check phase in the compiler). The two ways to fail this are:

        • typecheck, return false (python2, python3, ruby, crystal do this)
        • typecheck, return true (typescript, javascript, php do this)

        I haven’t made final decisions which of these is scarier.

        Interestingly, some of the above languages do fine if we use inequality instead:

        1 >= "1"
        

        Some languages from the top of my head that do this the way I like it: Haskell (and I assume many of the other strongly typed functional languages as well), Common Lisp (at least sbcl, dunno if it’s standard), Rust, Zig, Nim.

        1. 9

          To be fair you should always use === in TypeScript, then it works as expected.

          1. 6

            To be fair you should always use === in TypeScript

            To be even fairer, this is not even a Typescript thing, it’s a Javascript thing? A linter on a JS project will complain about the use of ==, without going near Typescript.

            1. 3

              Throwing my 2-cents in here, PHP is the same. Using === will enforce type checking on the comparison.

              1. 3

                I don’t think it “type checks” per se in PHP, but rather avoids doing an implicit conversion.

                1 == "1" evaluates to true, while 1 === "1" evaluates to false. It won’t error out, like a type checker will typically do for you.

              2. 1

                To be fairest, Typescript actually does this the way I want. See https://lobste.rs/s/qfpbk9/is_typescript_worth_it#c_hs0olb

              3. 2

                Does it error, or does it return false like python, ruby, crystal (and js with ===)?

                1. 2

                  It does error at compile time.

                  1. 1

                    Yeah, seems like both == and === work as I want in Typescript. See https://lobste.rs/s/qfpbk9/is_typescript_worth_it#c_hs0olb

                    I’m liking Typescript right now.

                2. 1

                  Ah, forgot about that. Do ts linters warn about ==?

                  1. 2

                    Yeah they do.

                3. 2

                  I don’t understand why a typecheck of the integer numeral 1 and a string happening to contain the numeral one returning false is scary.

                  I know nearly zero about type theory. Could you please explain?

                  1. 6

                    Because it’s a category mistake – it’s a nonsensical question.

                    1. 5

                      Ah I think I see, so that’s what demands that the response be an exception rather than false.

                      It’s not just “Is a number equal to a string?” “No.” it’s “That’s not even a sensical question to ask.”

                      I guess I feel like that’s a bit counter intuitive, since I generally want boolean operators to provide answers in boolean form, but then I don’t know anything about category theory either.

                      sigh clearly I have a lot to learn :)

                      1. 9

                        Well, it depends. Mathematically there’s nothing “wrong” with it, but it raises some uncomfortable questions. Like “what’s the domain of the == function?” Turns out, equality is not a mathematical function! If it was, everything would be in its domain, aka the forbidden Set Of All Sets. There’s a couple ways around this: the type way is to say that == is actually a collection of functions, one for each type. This ends up working out, and makes comparing different types impossible.

                        But there are other formulations! Like there’s nothing wrong with saying int and str always compare false, you just have to be clear what your mathematical axioms are.

                        1. 4

                          I think it might help to look at the Haskell signature for ==:

                          (==) :: a -> a -> Bool

                          It makes it clear that you can only compare two values of the same type.

                          1. 4

                            In Lisps, you typically have = and equal?/equalp. With = you’re asking “are these two things numerically equal”, which is a nonsensical thing to ask about a string and an integer (or a vector and a list, or a character and a boolean, or two other non-number objects). With equal? you’re asking “are these two objects structurally the same thing?”, which makes sense and “false” would be the obvious answer for objects of different types.

                            So presumably in many languages, == is the equal? in the above description, but there’s no separate = predicate.

                            And then there’s eq?/eqp, which asks “are these things the same object?”, which is a question of identity, not equality. That’s similar to what the is operator does in Python, for example. But yeah, this stuff is confusing if you’ve only been exposed to languages that conflate these different ways of comparing because you’re not used to having to make the choice of which kind of comparison to use in different situations.

                            1. 1

                              so that’s what demands that the response be an exception rather than false

                              I think no one wants it to throw an exception, but to simply not compile.

                        2. 2

                          1 == "1" is a classic JS gotcha (double equals is not “check for equality” but “check for equality and if it fails check for toString equality”) and 1 === "1" does what you expect.

                          I have decently used “fancy type” languages like Haskell, Purescript and Rust. Their type systems still make me somewhat unhappy compared to TS for “enterprise apps” (the one thing that I kinda wish that TS had but would bef impossible given soundness and how stuff works is the return type polymorphism).

                          1. 2

                            1 == "1" is a classic JS gotcha

                            I call it a classic maldesign, but ok :)

                            1. 3

                              I mean it’s not good, and there’s a reason you don’t see == anywhere in most codebases.

                              I guess it’s just not an issue that one hits in practice if you’re an experienced practitioner (compare to…. array bounds errors that even experienced C programmers will hit often). It’s a thing you set your linter to notice, and then never do it.

                          2. 1

                            Couldn’t edit this any longer, so will make an errata to my comment and mark it incorrect:

                            Contrary to what I stated, Typescript does this exactly as I think is best, i.e. signal an error at compile time.

                            vegai@Vesas-iMac ~/tmp> cat derp.ts
                            
                            let derp1 = 1 == "1";
                            let derp2 = 1 === "1";
                            
                            
                            vegai@Vesas-iMac ~/tmp> tsc derp.ts
                            derp.ts:2:13 - error TS2367: This condition will always return 'false' since the types 'number' and 'string' have no overlap.
                            
                            2 let derp1 = 1 == "1";
                                          ~~~~~~~~
                            
                            derp.ts:3:13 - error TS2367: This condition will always return 'false' since the types 'number' and 'string' have no overlap.
                            
                            3 let derp2 = 1 === "1";
                                          ~~~~~~~~~
                            
                            
                            Found 2 errors.
                            

                            Don’t even need the strict mode. So apologies to everyone for that bit of bullshitting – I went to check the behaviour in the first typescript playground I found, which for some reason did not behave like this.

                        1. 4

                          I like to think my Hython project is mostly written in this subset, excepting the imperative flow control effect monad. However, I’m a bit biased here. :) FWIW I still strongly dislike using MTL even if I really like what it gives you.

                          TBH I recall being slightly embarrassed that I used a fairly vanilla dialect of Haskell. Nobody hassled me about this, but I think the issue is the intellectual distance between what is needed to get things done vs what the community gets excited about can be large.

                          1. 2

                            I think the issue is the intellectual distance between what is needed to get things done vs what the community gets excited about can be large.

                            Maybe it would be useful to clearly declare what is the goal. Whether it is implementing the software that fulfills its business requirements („get things done“) or something else.

                            1. 1

                              This is really nice Haskell.

                              1. 1

                                Thank you! It was a fun project.

                            1. 3

                              I have a handful of project ideas I like to use when learning a new language, or trying a new technique:

                              • Interpreted emulator: Something small like a CHIP-8 or Gameboy. It touches a lot of areas (IO, graphics, tests etc), but the domain is straightforward (essentially implementing a well understood spec) so you can concentrate on your code.
                              • Ray tracer. Easy to get something started, and can make it as complex as you want from there.
                              • Parsing a small toy language.
                              • Clone of https://httpbin.org/
                              1. 2

                                If you want to go beyond parsing, reimplementing TCL is a manageable task. Look at picol. 500 lines of C.

                              1. 9

                                I’ve written Java code professionally for about 15 years. My relationship with singletons have gone through these phases:

                                1. Singletons are cool! Let’s use them everywhere. (About a year)
                                2. Never use singletons! Singletons are code smell. It breaks single-responsibility principle, causes contention problems, means very tight coupling, means code is often hard to test. (About 5-7 years)

                                Until finally, where I am today:

                                1. Ok. Let’s use singletons where it makes sense.

                                We have a very large enterprise Java application and use singletons in a couple of places. Client-side caches, server-side caches, connectivity classes from client to server, global statistics framework, logging framework, global system wide properties and defaults. That’s about it.

                                As with everything in programming, I say as in The Hillstreet Blues; “Let’s be careful out there”

                                1. 4

                                  From the examples you listed, why not just inject those as dependencies into the calling scope? Why do they have to be singletons?

                                  1. 4

                                    Because they are literally used everywhere. We don’t want to be injecting them everywhere.

                                    Also, singletons are easy to use safely, if well designed. Sadly, the majority of our developers are very inexperienced, and to be frank, not all that great developers. It’s easier for them to get connections right, logging, or proper use of caches, when it is available, looks, and feels the same everywhere.

                                    Also, some core code that is highly sensitive to concurrency problems is hidden and handled behind the singleton. Such that the developers don’t have to think about things like that.

                                    1. 1

                                      Don’t they make testing harder?

                                      1. 2

                                        Yes. Definitely. Testing wise, it’s a mess. We have had to create very specialised mock versions of them that are as easy to use such that we can switch them out for mocks altogether for unit tests.

                                        We have very few unit tests compared to lines of production code. Instead we try to do more continuous testing using BDD with Gherkin that runs against live environments where we can do more system and end-to-end testing.

                                        But yes. For unit testing. These large singletons are a headache.

                                1. 4

                                  Can’t we just remove the “data” and say science in general? Any systematic approach to knowledge about our world that is built around categorization or definition is doomed to marginalize those that defy categorization or definition.

                                  1. 7

                                    Most science done has ethical boundaries they attempt to follow. Some of these boundaries may be more or less compromised. Most scientific studies for example won’t include you without your explicit consent. Data science is more slippery than typical scientific practice because it revolves around data already gathered. Bypassing your consent is MUCH easier. The problem then gets further compromised when we start talking about businesses who may have a profit motive in ignoring scientific norms. Without any of the normal rules, regulations, and protections provided in a normal study they can really go off the rails. Without protection and oversight most businesses will be too tempted by the prospect of profits, and they will always choose what they perceive shareholders will value. Of course, mined data is a toxic asset, especially without consent. It can be illegal, or worse reputation destroying, and I suspect that will only get more so over time. Businesses that “mine data” as their primary way of doing business might lead to a bubble like crash that would be pretty bad for us devs. When that day comes it’s possible we won’t have to worry about this conversation so much, but until then it’s important to talk about specifically where the problems arise.

                                    1. 4

                                      Nice strawman argument. But, there’s a large jump between science and Seeing Like a State. See: the vast majority of human history.

                                      To wit, we are not resources for a state to manage in order to maximise GDP growth.

                                      1. 5

                                        I’m not sure what about my argument is strawman. In the article the argument is that data science can be used to subjugate or violate the rights of queer people. To quote the article:

                                        There’s no test that you give someone to determine they’re “actually” trans, unless you’re a doctor, or a neuroscience researcher, or a bigot (but I repeat myself).

                                        If we’re going to argue that data science threatens transexuality because it attempts to understand it or at the very least to categorize it, then we can just throw most natural science efforts out the window too. I don’t think the leap from the scientific method to panopticism is as great as you seem to think it is. The problem is that scientific reasoning can be used for many things, but what it’s best at is systemizing knowledge and define things against other things. That happens to be very useful at building knowledge, and those with knowledge have power, and eventually GDP. I’d love a counter example of a ludite culture that has a thriving GDP and loose definitions around their beliefs.

                                        1. 3

                                          Whether a person is trans or not, isn’t a scientific question. Cool that you’re going to bring that strawman to your grave tho.

                                          1. 3

                                            Whether a person is trans or not, isn’t a scientific question.

                                            As someone totally not in the loop, why isn’t it a scientific question? Somewhat related to that, why wouldn’t everything also be a scientific question?

                                            1. 2

                                              It’s currently what many scientists are studying and debating. There’s knowledge, theory, and practices around the subject. It’s definitely a scientific question. Further, it’s a settled question for some while a debated one for others. All depends on one’s views.

                                              1. 4

                                                Whether a single person or not is trans is - for now - a question of their subjective experience.

                                                There’s definitely science to be done about whether there are commonalities, biological markers, etc.

                                                1. 2

                                                  That’s all I’m saying. Especially the subjective experience. That biological gender is objective with objective data, but trans identity is subjective, is exactly why there’s such a strong debate about whether to accept or reject it. Science has been making the situation just a little more objective. That might help in some ways down the road.

                                                  Or make it worse. Never know how scientific results will be [ab]used… Just gotta take the chance since the subject is too important to not investigate.

                                                  1. 7

                                                    It seems a subtle nitpick to the uninitiated, but receiving the suggestion that a scientist could ‘set them straight’ about their subjective, personal experience is a common enough occurrence that you’ll enrage people if they think you’re doing it, which makes reasonable discussion hard.

                                                    Rereading “Whether a person is trans or not, isn’t a scientific question” with that context might make more sense of the reaction.

                                                    1. 6

                                                      This is the real MVP comment of the conversation. The same way science can’t tell you if you’re “objectively” sad or “objectively” a baseball fan, it makes no sense to ask if someone is “objectively” trans, but that doesn’t mean we get upset at people for crying when their grandparents die or spending hours watching people run around on a field.

                                                      1. 4

                                                        This response has been absolutely boggling my mind since I’ve first read it. Are you actually comparing gender with an interest for a sport? Then are you trivialising the implications of self-id (which is a thing). I mean, the entire discussion has been one of the catalysts of the alt-right, something I hardly think something like “baseball” could have had brought into life. I guess what they share in common, is that there is big money pushing both (after all, there’s a lot of profits one can make off people who depend on permanent medical supervision).

                                                        It’s not a surprise that Gender cannot be scientifically determined (as compared to sex), since it’s social, and has become meaningless in a society that’s relying less and less on gendered division of labour. But how that means that gender becomes individual (an apparent paradox) is foreign to me. People often say self-id is the best solution, because nothing else works. But that doesn’t mean it is good in itself. Nothing works! Because gender is dead!

                                                        To clarify this: None of this is meant as an insult against you or anyone else. None of this can be used an excuse of violence or smears. None of what I say is an attack on gender non-conformance. I don’t know you, and don’t wish to comment on your opinions. Ignore me if that’s what you want, I demand no response or attention. I just had to write this, even if it it were all wrong. This thread has already become so off topic, that there’s little more to care about. This topic has severely dealt damage to my mental well-being over the last few months, and suppressing it hasn’t done me well. I’ve been trying to get over it, but at no avail.

                                                        1. 3

                                                          I agree with you here; I was just using that as an example to help other people see why the specific idea I was referring to was a bit silly. It’s reductio ad not-quite-absurdum to illustrate a point.

                                                          This topic has severely dealt damage to my mental well-being over the last few months, and suppressing it hasn’t done me well.

                                                          I’m very happy to talk about this privately, if you want.

                                                          1. 1

                                                            Very kind, but there’s no point to burden anyone with my issues. The usage of the term “severely” was wrong, and I would edit it out if I could.

                                                    2. 6

                                                      If we’re going to talk in scientific terms it is important that we get the terms correct. So please don’t take this as me being pedantic because most people don’t know the precise definitions of these words. Heck even I didn’t before I had a close friend transition. I think it will help disambiguate and dissolve conflict. Gender specifically refers to the cultural construct, and therefore is subjective. You can have a gender even if you were a cybernetic brain in a box, no body required. Sex is the sexual dimorphism we observe, genitalia, hip size, bone structure, muscle mass, hair presentation, etc. As sexual dimorphism is not a binary, so even though yes your chromosomes may be XX or XY you can be XX with several male features. For example if you found out Hugh Jackman had XX chromosomes you wouldn’t more more likely to marry him, so the sexual dimorphism actually matters a great deal. Traits we generally think of as “male” or “female” often end up on people of either sex. In more extreme cases those traits are “fixed” surgically to fit the “birth sex” (what is perceived to be their sex by the parent, or the preferred sex by the parent). So sex as we talk about it in everyday language is not the chromosomes but rather the sexual dimorphism we observe.It’s quite a bit more common than people would like to think when we start to consider the full gamut of possible traits that can be considered sexually dimorphic. A woman at birth can have a “male” jawline, or a mustache, or a beard, or “male” muscles etc.

                                                      Identity itself is a construct, so the only measure we can have is how real it feels to them, the one who is perceiving it. So, the very question of “Is this person’s perceptions about their own identity real” is a vacuous question to answer. It’s akin to debating the tautology ⊤ = ⊤, because you’re debating the reality of a fundamentally immaterial thing. More importantly when a person perceives something about their body, concretely, that doesn’t agree with how their body presents they will go to the ends of the earth resolve that cognitive dissonance. It will cause them great anguish until they fix that. It’s akin to if you woke up one morning with tiny hands coming out of your stomach. Body horror is an entire genre for a reason. There can be an element of body horror for someone like us when we observe someone transitioning, because we are projecting our identity on that person, and imagining how horrible it would be to change our bodies. However this body horror is precisely what many trans people live with when they do not transition. Therefore we should not put our own discomfort above theirs, as what they live with is an order of magnitude more intense than what we experience as an observer.

                                                      The debate that arises around this subject is almost exclusively among lay people like you and me, and not researchers. The debates almost exclusively arise from the kinds of loose wiggly terms and the misconceptions around those terms that lay people use. The scientifically incorrect perception of sexual dimorphism as a binary, the conflation of sexual dimorphism and gender, and the conflation of sexual dimorphism and chromosomes are common contributors to why lay people debate on this until their lungs give out. The scientific consensus isn’t particularly divided on this subject. Some people don’t like the results, maybe some find them a bit disturbing, but that’s not the same thing as having a sound basis to doubt the conclusions. As we start unraveling the strings that hold together our consciousness, I suspect we will soon find things that are a great deal more upsetting than this.

                                                      1. 1

                                                        Very interesting read, thank you.

                                              2. 1

                                                Why is GDP even relevant? Lol, life is not a competition to get rich dude, chill down. Also if you believe that ludites or neoludites are against science and tech, you should maybe spend your fraction of the GDP on some book about the subject.

                                                Science is a tool and as such should be treated. You elevate it to a source of truth, which is not. To each problem its tools. Understanding subjective experiences and the formation of identities is not a problem for natural sciences.

                                                1. 1

                                                  I certainly didn’t say anyting about GDP being the alpha and the omega. I was meerly making the point–a point which often lost on many counter-culturalists—that the scientific method has proved itself over the last few hundred years to be VERY effective at stockpiling resources: knowledge, material and spiritual. I am actually pretty left-leaning in my own right and have very pessimistic views about the current trajectory of the application of the scientific method to our world. But this isn’t the right forum for those arguments.

                                                  I was just trying to make an intellectual argument based on the claims of the original story that if you’re going to attack data science as hostile to the subjective quality of being human, you can go ahead and throw out biology, physics and chemistry which all attempt to categorize and objectify our gender with just as many horrible effects as data science.

                                                  1. 1

                                                    I don’t think any of those disciplines ever concerned itself with gender. Sex yes, gender no. Gender, if any, is studied by sociologists, anthropologist and so on. Biology has nothing to say about gender. Also it’s not clear what the scientific method told us about spirituality

                                                    1. 1

                                                      Those disciplines should not concern themselves with gender, but they certainly do. The scientific method has certainly been used to attempt to explain our process of belief from a biologically necessary perspective.

                                                      1. 2

                                                        If you’re talking about stuff like evolutionary psychology, it’s still hotly debated if, epistemically, they fall into modern science. Otherwise it’s not clear what you’re talking about. I mean, clearly at some point some scientist that never concerned themselves with humanities for sure tried to apply science where it was inappropriate, but Science as a discipline is something else.

                                            2. 6

                                              Science is essentially the process by which humans seek verifiable knowledge. It is the only tool we have to try to understand the universe we live in without simply taking someone else’s word for it. What would you replace it with?

                                              1. 1

                                                I’m not arguing for replacing science. But in the context of the article, the nature of science is to categorize and define, and to do so with a decent amount of ruthlessness with regards to personal privacy and subjective feelings. It is not data science alone that is threatening to queer people. All of science is positioned against the more fluid and unexplainable aspects of being alive.

                                            1. 2

                                              TypeScript: if and switch are statements rather than expressions. In Rust you can assign to the result of an if but in TypeScript you have to use either a ternary or a mutable variable.

                                              1. 1

                                                Yeah, not having expression oriented constructs is very annoying.

                                              1. 2

                                                Ruby: the Array() constructor doesn’t really do what people want but people keep using it because they think they “should” do that when they want to wrap a pre-existing object instead of just using a literal. It’s a bit too easy to accidentally create a local variable when you were trying to call a peer instance method. Rubocop’s constantly expanding and ever more squirrelly and specific formatting rules have long since passed the point of diminishing returns, but the updates and new rules continue apace. Also the community has a significant, frustrating portion of developers and bloggers who think they’re writing in Java or some other static language, and really mis-apply patterns from those languages in Ruby without doing enough thinking about whether or not there’s a less tortured way of accomplishing what they want that would make more idiomatic use of Ruby’s strengths (blind enthusiam for an overuse of parameter-based dependence injection being a super obvious example of this).

                                                Scala: SBT fucking sucks, and the spotty documentation does absolutely nothing to improve the situation. Scala’s Either with Left and Right having “conventional meanings” is fuckawful and insane and coworkers seem to love using it to write impenetrable, opaque code – about half the time they get the convention backwards, probably because the convention is backwards. Implicits were a mistake. Also the community also seems to be drifting away, and there’s a lot of wheel-reinventing required if you want something native feeling instead of using Java libs and feeling like you’re writing Java in Scala.

                                                1. 2

                                                  As a non-rubyist, I’m curious what the alternative to the overuse of paramater-based DI is?

                                                  1. 4

                                                    It basically boils down to, someone wants to do something like test some class that has some functionality that depends on (picking an example off the top of my head) Time.

                                                    class Foo
                                                        ....
                                                       def some_function_that_depends_on_time
                                                          Time.now + some_other_values
                                                       end
                                                    end
                                                    

                                                    And then someone comes along and says: “that’s not easily unit testable. The Right Way™ to do this is to pass in the dependency on Time!”. So they write something like:

                                                    class Foo
                                                        
                                                        def initialize(time_impl)
                                                            @time_impl = time_impl
                                                         end
                                                    
                                                       def some_function_that_depends_on_time
                                                          @time_impl.now + some_other_values
                                                       end
                                                    end
                                                    
                                                    # in your unit test:
                                                    
                                                    class FooTest
                                                      def test
                                                         foo = Foo.new(TimeMock)
                                                         # do some testing with foo
                                                      end
                                                    end
                                                    

                                                    or they use a default argument on the method itself

                                                    class Foo
                                                        ....
                                                       def some_function_that_depends_on_time(time_impl = Time)
                                                          time_impl.now + some_other_values
                                                       end
                                                    end
                                                    
                                                    # in your unit test:
                                                    
                                                    class FooTest
                                                      def test
                                                         foo = Foo.new
                                                        #  some test involving foo. some_function_that_depends_on_time(TimeMock)
                                                      end
                                                    end
                                                    

                                                    and then they all pat themselves on the back and congratulate each other for loosening encapsulation, increasing API surface area, leaking implementation details into the public API contract, and just all around making refactoring code and reasoning about things harder. But hey, it’s the only way to make it predictably testable, right?

                                                    Well, no. You could just accept that you’re writing a dynamic language, Ruby, instead of a static one, and use that to keep the API nicely encapsulated while still keeping things perfectly testable:

                                                    class Foo
                                                        ....
                                                       def some_function_that_depends_on_time
                                                          time_impl.now + some_other_values
                                                       end
                                                    
                                                        ...
                                                        private
                                                    
                                                        def time_impl
                                                            Time
                                                         end
                                                    end
                                                    
                                                    # in your unit test:
                                                    
                                                    class FooTest
                                                      
                                                      def test
                                                        foo = Foo.new
                                                        foo.instance_eval do
                                                            def time_impl
                                                                TimeMock
                                                             end
                                                        end
                                                        #  some test involving foo. some_function_that_depends_on_time
                                                      end
                                                    end
                                                    

                                                    There are mocking libraries out there that give this a simple DSL. But people still avoid this route out of some kind of perception that they gain more moral purity by avoiding dynamically overriding methods, despite working in a language whose key feature is essentially just that. Writing Java in Ruby, and accepting the attending harm to APIs and encapsulation in a language that makes refactoring a lot harder than Java, strikes me as just sloppy and poorly thought out.

                                                  2. 1

                                                    Like @yumaikas I’m curious what you see as an alternative to parameter-based DI. I mildly prefer it because it makes collaborator objects more-obvious, and lets me treat object instances as immutable rather than exposing accessors.

                                                    1. 1

                                                      I already posted a long example in the reply to his comment? Keep your implementation details private and use the dynamicism of the language to inject collaborator overrides in tests via instance_eval and other limited forms of monkeypatching.

                                                      Making collaborator objects “more obvious” is one thing if it doesn’t come with significant downsides, but making them part of your public API contract is a terrible abandonment of encapsulation, in my opinion, and makes all future refactoring and what-should-be-private implementation detail changes into public, breaking changes to the contract.

                                                      It works in Java because you have type restrictions on method arguments. If you have some method public int foobar(timeCollaborator: SomeTimeInterface) then your contract with the outside world is “implements SomeTimeInterface”. The compiler enforces that contract on both the outside world, and on yourself, and changing internal implementation details around method calls on timeCollaborator is information that does not leak across the method boundary.

                                                      Ruby doesn’t work like that. At all. If you have:

                                                        def foobar(time_impl = Time)
                                                          time_impl.now + whatever
                                                        end
                                                      

                                                      the only contract you have with the outside world is “time_impl responds to the method now”, and the only things that enforce that contract are your discipline (on your end), and runtime exceptions (on the outside world’s end). If you change that method call to Time.some_other_method, you have broken the contract and that is a breaking change to the outside world. Ruby is duck typed, and there was never any requirement that client code conformed to the interface of Time (an unrealistically high burden that no caller would bother with if they just wanted to do some manipulation of how your particular gem dealt with that collaborator), just that they implemented the specific methods you happened to call.

                                                      Internal implementation details leak like a sieve in Ruby if you’re not careful; good API design requires ruthlessly minimizing API surface area.

                                                      1. 1

                                                        Ack! Sorry I had a tab open to this and didn’t see your response when I posted. ANYWAY.

                                                        I think you explained well-enough :) I don’t agree that instance evaling to override a private method is superior just because you can - in fact Time is one of those things I have found to be useful to ruthlessly parameterize because it’s useful to use beyond testing - e.g. needing to back-date something. But also I don’t think it really solves the Time interface problem to substitute it as instance eval’ed, though at that point you are deep in the internals for testing anyway I guess? If you’re trying to protect the caller (and not testers) from being able to use alternate objects or types, that does accomplish that, but in any duck typed language you have that for any object you pass around. In practice it doesn’t break as much as static type folks think it would - it’s a bit of an impossible language to code defensively.

                                                        Anyway, point well taken and apologies for prompting you to rehash!

                                                    2. 1

                                                      Implicits were a mistake

                                                      Do you think typeclasses are a good or bad idea? What would you use instead/replace them with?

                                                    1. 6

                                                      I’m intensely skeptical of products like this, and yet I can’t help but be impressed and excited for Dark’s future. It reminds me a little bit of VR - it’s definitely not there yet, but you can see the tantalizing future in the distance.

                                                      In particular I like the declarative/FP inspired way of coding. I’m not sold on the viewing of code on a flat pane you sort of scroll across. I think I’d prefer a more traditional single file, single function/group of things, based approach. Perhaps different ways of presenting this information, but still showing the links between components.

                                                      It looks very raw right now, but I’m looking forward to seeing what’s in store.

                                                      1. 1

                                                        I like the idea of the plane. I’ve toyed with that pattern myself a bit (and like how Apple Numbers is playing around with it too), and there’s exciting potential there, just haven’t seen a killer implementation yet.

                                                      1. 1

                                                        This is really amazing

                                                        1. 3

                                                          Working on Imgui Haskell bindings

                                                          1. 14

                                                            Myself this week. I’ve only gotten 5 hours of sleep per night in the last week. It’s getting bad.

                                                            1. 7

                                                              That sucks, enjoy catching up sleep.

                                                              1. 1

                                                                I absolutely plan to enjoy every moment of it.

                                                              2. 4

                                                                Update: I’m in the hospital :(

                                                                EDIT: I was discharged and told to not do something again. I’m okay otherwise.

                                                                1. 1

                                                                  Oh shit, what?

                                                                  1. 2

                                                                    Apparently my anxiety is that bad

                                                                    1. 3

                                                                      Sending my support. Anxiety is really tough - i’ve been there.

                                                                      1. 2

                                                                        That sucks, I hope you feel better soon.

                                                                        1. 2

                                                                          They gave me lorazepam, I feel peaceful but my body isn’t calming down yet

                                                                          1. 2

                                                                            Glad you got some treatment relatively quickly.

                                                                            I’ve made my rounds around here and I think the Jewish has a very well-oiled machine in emerg compared to the others. Wherever you are, it looks like it’s going better for you.

                                                                  2. 2

                                                                    Here’s some empathy and some advice. Feel free to take or leave either as you see fit.

                                                                    Damn I hope you feel better soon. I’ve been enjoying reading your blog posts and I selfishly want you to get your sleep so I can keep enjoying your work.

                                                                    Intense exercise works for me. When I physically exhaust my body, sleep comes more easily. Also it helps with my motivation and general sense of well-being.

                                                                    1. 2

                                                                      Thanks! I think the lorezapam at the hospital helped the most.

                                                                    2. 2

                                                                      Buff yourself. Like in World of Warcraft. Life is just like that just different magic.

                                                                      While you don’t have potion of rejuvenation IRL, there are some nice buffs for sleep optimization - you could do any/all of Ubiquinol, Piracetam, Spirulina, Vitamin C, K3 MK7, Retynol, ALCAR.

                                                                      Or you can be boring and sleep :)

                                                                      1. 3

                                                                        I generally try to avoid giving specific medical advice unless invited to, as there’s no way to know a person’s situation unless they volunteer it, and people with chronic health issues are generally well aware of the options that people are prone to suggesting. If I were asked to suggest medical treatment to look into for this scenario, it would most likely be treatment aimed at improving sleep duration and quality, as that’s generally probably the highest priority for a sustainable lifestyle.

                                                                        I am not trying to make you feel bad for weighing in - I can see that you’re trying to help - but I do think it’s important that things like this should be opt-in rather than opt-out, so I’m hoping you’ll reflect on it.

                                                                        1. 1

                                                                          Recommending OTC supplements is in the domain of nutrition, it should not be generally considered as ‘medical treatment’. Potential for harm is virtually non-existent here, the worst case I can think of is that no effect happens.

                                                                          1. 3

                                                                            My concern is more about the psychological harm that people often experience as a result of hearing the same advice over and over, to the point that it’s too exhausting and burdensome to even reply to it most of the time. Longer-term, it is often the case that the potential frustration of receiving unsolicited advice becomes an incentive to not talk about health issues at all. When nobody talks about health issues because of the potential reactions, existing societal stigmas are reinforced.

                                                                            1. 0

                                                                              What concerns me is this self-appointed babysitting of grown up people. Maybe that works where you work at, but your deduction about this really concerns me. Furthermore, as far as I can see, our pony dude is more then capable to speak for herself.

                                                                              People should rise their own kids and do that stuff at home. Picking up on random strangers on the internet and trying to re-educate them is not a virtue in my world.

                                                                              1. 1

                                                                                I offered advice that you can think about, or not, as you wish.

                                                                      2. 1

                                                                        Wednesday update: I had 6.5 hours of sleep and a happy dream instead of a horrific nightmare. Things are getting better.

                                                                      1. 4

                                                                        A side project for my Dad.

                                                                        He’s a cardiologist, and does echocardiograms. He just purchased a new machine, a different brand to the ones he already has. He has some software to turn these echo studies into a report using a word doc as a template. But it doesn’t work with this new model (because they are all proprietary and locked down). So I’m building something that can work generically, with the aim to sell it onwards. It’s fun so far.

                                                                        1. 3

                                                                          Prepping for interviews. I really dislike whiteboarding. I think it’s borderline pointless. I guess it’s just how the game is.

                                                                          1. 2

                                                                            Amen and good luck.

                                                                          1. 2

                                                                            Location: New York City, NY, USA

                                                                            Type of Work: Software Engineer

                                                                            Hours: Full Time

                                                                            Contact: Linkedin Github

                                                                            Description: I’m a developer with experience in both the corporate and startup space. I have experience in a wide range of business and technical domains, and am always looking for something interesting.

                                                                            I’m comfortable working in almost all languages or environments, front-end or back-end. I enjoy taking business concepts and strategies from words in a meeting, to live production code.

                                                                            Statically typed functional programming is my passion, and I have experience bringing this into teams and realising the benefits.

                                                                            I’m looking for roles in NYC that use FP, but am open to anything really.

                                                                            Please PM me here, or email if you have anything you think might be a good fit.