Better HN
topnewbestaskshowjobs
Log inSign up

HumanDrivenDev

603 karma · joined Sep 13, 2017 (9y ago) · 435 submissions

Submissions

comment 9y ago · link · parent

You can pry my Linux desktop out of my cold dead hands. I've been using it for almost 10 years now, and I couldn't imagine having to deal with windows telemetry and terrible performance, or apples outrageous prices. Yes it takes longer to set up but my desktop setup fits me like a glove. I always feel slightly handicapped when I have to use windows at work.

There is one thing that would make me switch, and that's apples IME methods for Chinese characters, which are a lot more sophisticated than the Linux offerings.

comment 9y ago · link · parent

A really, really high percentage. Being born from a poor country doesn't mean you are poor. Even the most impoverished place has an upper class that lives really well - they form the bulk of your immigrants to the first world.

comment 9y ago · link · parent

The amount of padding in modern websites drives up the wall. The idea that I bought a 24" monitor just so I can read text in fullscreen is ridiculous.

One trick I often use is to have the window take half (or less) of the screen and spoof my browser to be Chrome on Android Kit Kat. I just wish there was a change to have a different browser spoofed per tab, or maybe a "whitelist" of websites that are designed well enough that I won't pretend I'm on a phone.

comment 9y ago · link · parent

I guess a lot of people aren't at all familiar with Africas geography. I mean the whole article is called "Diary of an African Cryptocurrency Miner", presumably because Kenya was too specific and obscure for their target audience. If your mental map of a continent is largely "here be dragons", I guess it's easy to associate Nigerian scammers with Kenyan cryptocurrency miners, who live some 3500km and several international borders away.

It's not limited to Africa though. I'm from New Zealand, and I've had Europeans ask if I visit Japan a lot, because I'm so close (I'm about as close to Japan as Germany is). I've had Americans ask if I was ok when they heard news that tropical cyclones were hitting Queensland (I'm as far from Queensland as a Jamaican is from Ohio). And the hemisphere thing stumps so many people. Usually they just constantly forget that the seasons are reversed, but I've had one educated, multilingual gentleman from east Asia ask me if North and South mean the same thing in the southern hemisphere, or if they have opposite meanings.

comment 9y ago · link · parent

I think I've come to a different conclusion reading your run down of this. The key paragraph is this:

The problem was that over time, there modules started drifting. Their domains became different ever so slightly and the owners of those modules became different teams. Now if you wanted to modify the domain object, you had to check it wouldn't break code the other teams were developing.

Isn't the real issue here that the architecture didn't keep pace with reality? It sounds like the dev who made the package had the right ideal. The real issue was subsequent devs introducing their domain specific stuff into a common package, instead of extending it or composing it with their own domain specific code.

comment 9y ago · link · parent

I think you're not understanding what I'm saying. Luckily this person explained it better than I could.

https://news.ycombinator.com/item?id=15607598

comment 9y ago · link · parent

IIRC this is called "subroutine threaded code". A few techniques for dispatching instructions for virtual machines are discussed here:

http://www.complang.tuwien.ac.at/forth/threaded-code.html

comment 9y ago · link · parent

i think from the outside, it's better to articulate what you want in domain semantics, rather than implementation semantics.

You've articulated here what I've actually been trying to communicate. I have no problem if a method does nothing but get/set a variable. I just think they should be named with domain semantics.

comment 9y ago · link · parent

What do you mean by "real objects"? Are you refering to prototype OO?

comment 9y ago · link · parent

It looks like I have a really different definition of "getter" than some people here. I would only call something a getter if it explicitly makes reference and effectively exposes an internal field. Just giving a method a noun name is not enough to make it a getter, in my mind. It's the "get" prefix that says 'hey there is definitely a field in here called Foo that we think we're encapsulating but we're really not'.

comment 9y ago · link · parent

I guess I'd call it "changeLastName". That's closer to the domain, we don't go to the Department of Births, Deaths and Marriage and tell the clerk we want to "set" our last name. But that is being too pedantic, even for me.

I'll concede defeat. That is a pretty good example. At the end of the day, "customer details" class is actually a big bag of fields that needs some access control and validation.

comment 9y ago · link · parent

> I can't speak to Java, but in C#, the original goal was to reduce coupling.

If you want to reduce coupling, why not write a real method? Get/Set couples you to your class fields. If you change your class fields, your getters and setters all suddenly become useless.

Maybe I just hate the middle ground (:

comment 9y ago · link · parent

But the example is just a demonstration of the concept - you should be able to change the implementation without changing the exposed interface.

My argument is that having getters and setters exposes your implementation. If you have "getFoo" and "setFoo" it exposes that your class contains a value called Foo. My argument is that you should either give your methods better names, or get rid of the pretense of encapsulation altogether and just make them public. Get/Set is just an awkward middle ground.

Even if we keep this immutable, your implementation is different in that it uses twice as much memory.

How can my implementation be different? No one else has written one (:

But maybe not. If you had getters and setters, you could seamlessly try the other implementation without changing all of the client code.

And if you had actual methods with names that didn't break encapsulation, you could do the same and divorce all your calling code from the burden of knowing about the internal structure. Again, the middling approach is the worst of both worlds to me.

comment 9y ago · link · parent

What you propose wouldn't be using "getters" to me. They just sound like normal methods.

comment 9y ago · link · parent

Then I would implement it as a "real" class, not a data one.

    class Satellite {
        Coordinates coordinates;
        double celcius;

        /*** constructors, etc ***/

        public double Celcius() { ... }
        public double Kelvins() { ... }    
        public void Move(...) { /* modifies state */ }
    }
Note how none of the methods make any mention of low level operations like setting/getting internal fields.

You could make the argument that I do have a getter there, Celcius. But at the risk of pedantry I'd argue it isn't so. The name doesn't imply that it's retrieving the value of a field - ie the internal representation could easily change to Kelvin or Fahrenheit - where as "getCelcius" definitely tells me there's a field there called Celcius.

Hmm, after writing that I wonder what the definition of a setter actually is. I have no problem with a method that just returns a field, as long as it doesn't go out of its way to tell me that's exactly what it's doing. Maybe the distinction I am making is too subtle.

comment 9y ago · link · parent

If you have a mutable class, and you're modifying its fields, you're doing it for a reason, right? Often it's part of a larger operation. So why not name the method that mutates the field after that reason. I got away from thinking about "I am altering the internal representation of this struct + vtable" to "I am sending a message to this opaque thing and I don't really care how it's done when I'm outside the black box".

> but "setters are always bad and i don't understand why anyone would ever use them" seems like a needlessly hard-line sentiment, IMO.

I have a strong opinion because I read some compelling arguments, thought about a lot, stopped using setters, and the quality of my code improved. I don't see a need to moderate my opinions on programming, especially when that's what I really think. Again, happy to be shown a great counter example and admit I was wrong.

comment 9y ago · link · parent

Why have a mutable class to represent temperature - a simple value class with two fields? Why not just construct a new Temperature? I mean if performance was an issue, you'd just use plain doubles instead, right?

I'm open to the idea that setters do have a use case, but I'm not seeing one here.

comment 9y ago · link · parent

> I'd love to see if in 50 years we're closer to Smalltalk, Haskell, or something completely different.

I guess in my mind FP and OO are orthogonal. If I write an immutable object and I send it messages that are referentially transparent, am I not doing both? Would it help FP people if they thought of such objects as "a record of partially applied functions"? So I hope both. I'd love if there was a statically typed, high level pure OO language without all the cruft of Scala or C#. Maybe I have to wait for the next programming fashion cycle for that to happen.

> Thanks for posting your feeling on OO. In some ways I've always felt very restricted writing OO (even in Python), but learning Smalltalk is making me see it from an entirely different perspective.

I often wonder if I need to coin a better term for "OO" for what I am talking about. Alan Kays whole schtick was that objects contained both data and procedures, but by combining them they became something new, and more than just the sum of their parts. That's the powerful idea to me. But language changes, and OO in 2017 just means "Java".

comment 9y ago · link · parent

This is a bit abstract to me. I don't tend to write mutable classes. And if I do mutate fields, it's for a "reason" (and I'll name the method after that reason).

If you feel like it, write out how you'd implement the class and why. I posted a fairly strong opinion, but I'm happy to have my mind changed.

comment 9y ago · link · parent

I get what you're saying, but at the same time I don't understand how you'd implement the class and why.

    class Temperature {   
        public final double celcius, kelvins;

        Temperature(int celcius, int kelvins) {
            this.celcius = celcius;
            this.kelvins = kelvins;
        }
        
        public static Temperature fromCelcius(int c) {
            return new Celcius(c, c - 273.15);            
        }
    }
What's wrong with that approach, and how would you do it?

comment 9y ago · link · parent

Why not give your "setters" a real name that describes what they're doing?

https://news.ycombinator.com/item?id=15606777

In the structs & records world (C, F#, Rust, etc) they never seem to have this issue. Either the struct is completely transparent and you can read and write fields at will, or it's completely opaque and the functions that operate on it have better names/semantics than "setField".

comment 9y ago · link · parent

I appreciate you thinking of an example, but I guess I find it a bit convoluted.

Couldn't you also refactor that by changing the constructor of your temperature class so it converts things to Kelvins, rather than converting it every time you call the getter?

comment 9y ago · link · parent

But by definition getters and setters lack lexibility. They expose the internal representation of an object. They stop really being "objects" - high level opaque things you send messages to - and they turn into big porous bags of fields.

To clarify, I would not consider something like this a setter:

    class Monster {
        int health;
        
        void Damage(int d) { 
            this.health -= d;
        }
    }
True, it is a method that just sets a variable. But it makes no mention of that variable. It's defined in terms of its actual purpose (inflicting damage on a monster), not its implementation (modifying an internal field called 'health').

There is definitely a time and place for plain data objects. But if you find yourself actually needing validation and preprocessing in your get/set, then you probably have a 'real' object hiding their. Stop being lazy and give it proper methods.

comment 9y ago · link · parent

Yes, I am. It was a separate tangent, and a bit off-topic.

comment 9y ago · link · parent

... To write such a class responsibly, one has to write a lot of low-value, repetitive code: constructors, accessors ...

If you're writing a plain data class, why on earth would you write getters and setters? Just make your fields public and be done with it.

I will be forever perplexed by the idea of getters and setters (and this extends to C#s syntax sugar). I have no idea what problem they solve. If you're at the level of plain data, then just make a class with public fields and no methods. If you're trying to write a 'higher level' object - then don't refer to the names of fields in your method names. The getter/setter/property approach is just the worst of both worlds. They make explicit reference to an objects internal fields, while at the same time obfuscating what happens when you actually access them.

comment 9y ago · link · parent

I would, but I'm still waiting for the pin wheel to stop spinning...

I miss the old C2.

comment 9y ago · link · parent

I've often thought about an editor for a stack/concatenative language that makes the arity of words clearer. like when you select a word it highlights which of the previous words in the definition it's consuming.

I don't know if it would work for forth - too low level - but for something like Factor I could see it being really useful.

comment 9y ago · link · parent

I think a degree of skepticism is required with NIH. I'm probably not going to roll my own crypto, or high performance statistical routines. But if something invented elsewhere "solves" a problem that really isn't rocket science, or if it's a framework - I will almost always avoid it.

comment 9y ago · link · parent

> It reminds me of this quote: "The problem with object-oriented languages is they've got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle." - Joe Armstrong

What Joe Armstrong (who I admire) complains about is actually what I love about OO languages. And for me that's the true essence of what OO is, and how it differs from non-OO. People keep trying to frame OO in terms of mutability (completely orthogonal) or C++/Java coding practices (C++ doesn't define OO because it has objects, anymore than it defines FP because it has lambdas).

The real difference, the real paradigm shift is in data + functions vs objects. And I maintain that objects are more powerful and better idea than data + functions. The banana can't be peeled without the gorillas opposable thumbs.

comment 9y ago · link · parent

You're bang on the money: Tamsui is a romanisation of the hokkien name, not the mandarin one. There's a few other non-mando names floating around, like Taroko (an aboriginal language).

I have a Taiwanese book for school children that includes the governments romanisation, hanzi, and some kind of extended bopomofo. While the native speaker I was learning with could read hokkien-with-characters, he couldn't do it quickly, and often had to puzzle over a certain character. In cases where they had both characters and romanisation I was able to help him on the characters he was stuck on by (badly) pronouncing the romanisation. Still, I haven't met any Taiwanese hokkien speakers at all interested in romanisation. Which is a shame - it covers all the sounds, and the language does seem to be slowly dying (the fact people don't write it probably has a lot to do with it).

1
1112131415