HN user

greggman3

4,044 karma
Posts2
Comments1,106
View on HN

I agree that having a "can't modify this object" via this reference is useful and that JavaScript doesn't have it. TypeScript has it with `ReadOnly<T>`

It could be worse. You could be in python that has no const whatsoever :P

I also agree pass by reference is useful. JavaScript only has pass by value, similar to python.

I suspect they spent several millions of dollars a year and at least 20-30 people if not more and I think you don't have any idea of how hard the problem is and how it's getting harder all the time.

It's going to get even harder as spammers use ChatGPT like tech to write individual spam messages for each person

That brings me to something I really want in JS, actual unmutable values. If you use `const x = new SomeClass()`, you cannot reassign it, but you can change fields. The first time I encountered `const`, I thought it did the opposite. It would be cool if you could declare something (object, array) to be an immutable value.

That sounds like a fundamental mis-understanding. Variables do not hold objects, they hold references to objects.

    const foo = {};
    let bar = foo;
foo and bar hold references to the same object. They do not hold the object themselves. foo's reference can not be changed. It's const. bar's reference can. But the object is independent of both variables.

If you want the object itself to be unmodifiable there's Object.freeze.

    const foo ...
makes foo const. If you wanted a shortcut for making the object constant (vs Object.freeze) it would be something like
    let foo = new const SomeObject()
This doesn't exist but it makes more sense than believing that `const foo` some how makes the object constant. It only makes foo constant (the reference).

and yet looking through code from the place you work I see something like this

    let field = ve.instanceContext.replace(/(#\/)|(#)/ig, "").replace(/\//g, ".")
Which you apparently claim should be
    const fieldWithHashMarksUnesacped = ve.instanceContext.replace(/(#\/)|(#)/ig, "");
    const field = fieldWithHashMarksUnesacped.replace(/\//g, ".")

https://github.com/mirusresearch/firehoser/blob/46e4b0cab9a2...

and this

    return moment(input).utc().format('YYYY-MM-DD HH:mm:ss')
Which apparently you believe should be
    const inputAsMoment = moment(input);
    const inputConvertedToUTC = inputAsMoment.utc()
    return inputConvertedToUTC.format('YYYY-MM-DD HH:mm:ss')

I agree that

(1) named intermediate values are sometimes more readable ... though I have examples where it's very hard to come up with names and not sure it helped

(2) debugging is easier.

For (2) though, this IMO is a problem with the debugger. The debugger should allow stepping by statement/expression instead of only by line (or whatever it's currently doing). If the debugger stopped at each pipe and showed in values (2) would mostly be solved. I used a debugger that worked by statements instead of lines once 34 years ago. Sadly I haven't seen once since. It should be optional though as it's a tradeoff. Stepping through some code can get really tedious if there are lots of steps.

Hello, PNG 4 years ago

I don't consider ASCII simple because it needs to be parsed (more than a binary format).

As sample example, a binary format could be as simple as

    struct Header {
      uint32 width;
      uint32 height;
    }

    struct Image {
      Header header;
      uint8* data;
    }

    Image* readIMG(const char* filename) {
      int fd = open(filename, ...)
      Image* image = new Image();
      read(fd, &image->header, sizeof(image->header));
      size_t size = image->header.width * image->header.height * 4;
      image->data = malloc(size);
      read(fd, image->data, size);
      close(fd);
      return image;
    }
Yea I know, that's not a complete example, endian issues, error checking.

Reading a PPM file is only simple if you already have something to read buffered strings and parse numbers etc... And it's slow and large, especially for todays files.

For me Spotlight fails constantly. I don't know what's tripping it up but programs I use often it randomly decides "today I'm not going to find those for you". I have it set to only show programs and nothing else so no idea why it can't do that simple task but whatever, several times a week it decides "not this time"

As for tiling, Mac does do somethings that Windows (IIRC) doesn't. One is, if you move a window or the edge of a window slowly it will snap at the border of another window. So you move fast to get it close then slow down and it will align nicely.

Also, tiling: https://support.apple.com/en-us/HT204948

But I agree that Windows tiling is more discoverable.

Hello, PNG 4 years ago

Honestly, I don't consider PNG a simple format. The CRC and the compression are non-trivial. If you're using a new language that doesn't have those features built in and/or you don't have a reasonable amount of programming experience then you're going to likely fail (or learn a ton). zlib is 23k lines. "simple" is not word I'd use to describe PNG

Simple formats are like certain forms of .TGA and .BMP. A simple header and then the pixel data. No CRCs, no compression. Done. You can write an entire reader in 20-30 lines of code and a writer in other 20-30 lines of code as well. Both of those formats have options that can probably make them more work but if you're storing 24bit "True color" or 32 bit "true color + alpha" then they are way easier formats.

Of course they're not common formats so you're stuck with complex formats like PNG

1000 square feet is only small in the USA. 1000 sqft is the average size of a home in Japan. 50% are smaller. There's plenty of creative ways to use 1000 sqft

Conditional CSS 4 years ago

I believe the reason there's no if/else is because CSS is supposed to be easy enough to interpret relatively quickly (in a finite amount of time). The moment you add if/else you'd up with a full programming language and the halting problem and an arbitrary amount of calculations before the system can finally know what to render.

Yes, I did consider that. That's exactly my point. He stated he hates (A) and likes (B). I suggested that hating (A) is a poor POV. It would be better to like both (A) and (B) even if you prefer (B).

Let's put it another way. If someone says the France sucks, Germany rules. And someone replies "The France doesn't suck, here's a few reasons why". Why do you feel the need to jump in and defend the POV that "France sucks"?

I also listed spending time with people as a plus to the city. It's interesting that you left that out. I'd guess if the author had a job they loved with people they loved their attitude about everything else would change. The fact they're in a job they hate arguably taints everything else about their life. Commuting of course sucks if it's to a place you don't want to go in the first place. To me, commuting by public transport rocks because I got, on average, 50+ minutes of walking (25 each way) for free (added to the 20 minutes of standing on the train)

https://www.youtube.com/watch?v=KPUlgSRn6e0

He did call it crap or did you miss it?

In so many words he said cities suck, nature rocks.

Vs me, who said both nature and cities rock, and that the attitude that one sucks is a poor attitude

They have opinions. One is nature rules. The other is the city sucks.

I think their opinion of that the city sucks is wrong, full stop, and that a change in attitude would see all the great things a city provides that nature does not so that then you can appreciate both.

To me, enjoying the good parts of both the city and nature is a better POV than shitting one one of them.

Hey, if being in nature makes you happy good for you but your outlook on the rest is kind of crap.

Me, best time in my life, commuting in Tokyo to my jobs working on a project I loved with people I loved. All the ads on the trains were eye candy to me. I didn't buy anything that I remember but I did find out about museums, concerts, and other events around town as well as various obscure services which I never used but was amused to read about.

Drinking with my buddies, including work buddies about once a week was great. Clubbing, going to restaurants, and going to events of the kind that generally only happen in giant cities was lovely.

I like the occasional trip to nature but as for me I'll pick the city and the public transportation. I love it!

Is it true there are plenty of places in the world that don't have an epidemic of obesity?

My belief is Japan doesn't have as much of an obesity problem.

Sure, I'd love a drug that lets me eat more calories and not get fat but I'd also love it if we some how managed to stop eating so many cookies, donuts, potato-chips, sugary sodas, giant portion meals, etc.... I'd also love it if we designed more areas to be walkable and bikeable.

I lived ~15 years in Japan. I never missed owning car because the country is designed not to need a car. I also spent a year in Europe and Singapore and again, never missed owning car for the same reasons.

Let me also add that in Japan, at least in big cities like Tokyo, Osaka, Kyoto, you are almost always 1-2 minutes away from junk food. You can walk to a convenience store and find whole aisles of pastries, chips, ice cream, candies, etc and yet somehow the Japanese manage not to pig out.

Similarly there are bakeries all over full of donuts, etc...

Somethings that help are the portions are often smaller. Certainly for potato chips most bags in Japan are 1/3th the size of the average bag in the USA. Similarly cookies are small and come in small portions vs the USA where pretty much any supermarket sells cookies in packages of 20 to 40 cookies and each cookie is giant 300-500 calories each.

I guess this is one of those, we're not going to get people to stop eating too much so we have to find another solution? I can just imagine once I get this drug I'll start eating more because I can and companies will ramp up the portion sizes even more.... TACO TIME!!!!!

It's not the "like" button. It's the "likes" number. Hide the number and the like button is signal to the system. So "likes" and it's a signal to the poster. That IMO is the problem, not the button itself, the "score" you see visually.

I've hidden the score here on HN for myself and on StackOverflow. Two places where score has a negative effect on myself.

I agree with you. I ran into that issue once. Of course I knew map takes a function that it passes value, index, array, I just forgot for a moment. It would arguably be better to have different functions for those.

Very tangentially related, Apple's Metal API has a function that copies a texture. You pass it a width, height, etc... But, if the texture is compressed, then 255 of 256 possible value combos you pass it will be invalid since compressed textures can only be copied in block multiples. I think it would have been a better designed function if it only took width and height in blocks instead of pixels (with uncompressed textures defined has having 1x1 pixel blocks). Then this nonsense of 255 of 256 values being bad would disappear. There's a ton of other inconsistencies in that function. For example, you pass it destinationBytesPerRow when copying to a buffer but if the texture is compressed you pass it say 40 rows and it will only only actually copy 10 rows of blocks and only advance the destination every 4 rows instead of every row. It's arguably a poorly designed function. Thought, I suspect it was inspired by similarly poorly designed functions in other graphics APIs

I got all that. They're still going to look at statistics to decide how who to risk billions of dollars on a space mission.

This is no different than say insurance companies charging more for people under 25. You might be 19 and the safest driver in the world. Doesn't matter, the statistics say, people under 25 get in accidents. Same with all kinds of things.

It's not like a space program has infinity money and sends up a rocket to Saturn every day. So, they have to lower the risks and one of the ways they do that is by trying to select extremely healthy people to be astronauts. Sure, one person how's genes say they are unhealthy might happen to outlive everyone how's genes say they are healthy but that's not how it works. They're still going to use some form of selection by genes (health, body size, eye sight, hearing, etc...) so select people they feel give the mission the highest chance of success.

If you're blind, deaf, have missing or deformed limbs, a "bad" heart, etc... you aren't going to be selected.

I'm going to take the inevitable downvotes, especially by people who don't want to engage and discuss, and say I wasn't a fan of Gattaca. In particular the story gets muddled for me because they made the poor choice of choosing a space mission as the background for the story.

NASA and the Air Force already have (had) a "you must have perfect genes or you don't get to be an astronaut / fighter pilot" so that part of Gattaca was not sci-fi, it was just repeating what was already true. One of my best friends in high-school, his dream was to be a fighter pilot, but he had bad vision (bad genes) and knew that was an instant "no".

In terms of the movie, the main character wants the government to risk billions of dollars on a space mission on him and he selfishly doesn't care that they're trying to lower the risk of failure by selecting only people less likely to have issues on the mission. Real space missions do the same. You aren't going to send someone who genes suggest the mission may fail. They may not give you a DNA test, but they will test tons of other things that all basically test your things you got because of your genes.

I get the movie is about trying harder than anyone else, taking risks, not letting others tell you your limits. All of that is great. But, because of the poor choice of context (billion dollar space missions) it didn't work for me because that is how billion dollar space missions are run and it made the main character kind of a jerk for risking the mission and every one else's lives.

The typical response is being in these jobs changes you so that when you have the money you no longer have any meaning. You have a passion, you put it on hold for 10-20yrs for $$$, you come out the other end having lost your passion

Further, that assumes you make it out the other end. Almost no one saves the money and retires early. Instead they get some money, they get a nicer apartment, nicer car, start eating out at fancier restaurants, shopping at higher end places, buying fashion brands etc...