HN user

feca

-92 karma
Posts0
Comments12
View on HN
No posts found.

Nobody asked for an argument, and by downvoting any argument on my part was prevented. I can explain why I find it immoral: I think the world has many real and deep problems, and investing in a web application that is not hard to build and solves a superfluous first world problem, is a waste of resources. Conversely, I think profiting from it is dishonest and immoral. You may disagree with my reasoning and you may have a different world view to compare, but the downvotes just terminate the conversation.

Can you show an example of what you are describing? It doesn't sound interesting for the tasks I have in mind, so it must be the case that you are dealing with very complex tasks.

You have probably seen code written by the best programmers you know, and I guess you are comparing their work with the code in open source projects. As the rest of us can't see their code, it's impossible to agree with you, so we can only trust you blindly. But "trust" with something so technical is a bad criteria, and that's why open source software is good for showing your approach to problem solving and your programming style.

I think the idea of "doing open source work" sounds a bit disproportionate. At least to me. Instead, think about people sharing some small tools they have built for themselves. Even if they work for IBM, they should be able to customize their environment by tweaking some tool or writing a script to make their lives easier. They only have to share that code, not to show off but to help others with similar problems.

I disagree. Learn the language and discover the new way of doing things it proposes. The approach Lua takes is very elegant, worth learning.

Another problem with the approach from the blog post is locality. If you need to draw 10 numbers in all places, then configuring that value in the module will work. But localy, when you look at the code, it won't tell you how many numbers you are drawing.

If you have this in many different places:

    MegaLotto::Drawing.new.draw
You don't have the information of how many numbers you are getting back. That's not a big deal, but adds to the cognitive load (or requires some comments). Also, if you need to draw different numbers in several different places, you will have to change the configuration many times:
    # First use, we need 10 numbers
    MegaLotto.configure do |config|
      config.drawing_count = 10
    end

    MegaLotto::Drawing.new.draw

    # Second use, we need 6 numbers
    MegaLotto.configure do |config|
      config.drawing_count = 6
    end

    MegaLotto::Drawing.new.draw
And as soon as you do that, you may need to take multi-threading into account, because you are mutating the class.

Extrapolating, it is like defining the size of an array:

    Array.new(4)
If instead you configure Array.new to have a given size for all instantiations, you also lose locality and you may run into thread safety issues.

In the case of MegaLotto::Drawing.new needing multiple configuration options, you can use keyword arguments. If you need too many arguments, maybe the abstraction is wrong. Even if you want to move forward with too many arguments, you can add getters/setters to the newly created instance:

   # Another approach which modifies the instance
   drawing = MegaLotto::Drawing.new
   drawing.size = 10
   drawing.draw #=> returns ten numbers
But this is not optimal design given the elements we have.

This is actually a very complicated way of achieving the goal. It works, but it's not good from an economic point of view as it is more expensive in computational terms than a simpler OO alternative, which is to pass the size when you instantiate the MegaLotto::Drawing object.

For example, compare the proposed solution:

    MegaLotto.configure do |config|
      config.drawing_count = 10
    end

    MegaLotto::Drawing.new.draw
With the alternative:
    MegaLotto::Drawing.new(10).draw
If you want to make it extensible, you can use keyword arguments:
    MegaLotto::Drawing.new(size: 10).draw
The interface and the implementation are simpler, but also the performance is better because there are less method calls. If you look at the code of both implementations, you will find the simpler one easier to understand. As a side effect, you will also get simpler stack traces if anything goes wrong.
Redis 2.8.7 is out 12 years ago

I think it's bad manners to act like if the author owed you something. Redis is a monumental personal effort, and a lot of people try to help in many different ways because they are grateful such a tool exists. If you want to improve Redis, you are welcome to discuss any issue and even provide a patch, but you have to be respectful. A comment like yours is very demoralizing for open source contributors.