Hacker Newsnew | past | comments | ask | show | jobs | submit | weaksauce's commentslogin

looked into it more and the docs say that an index out of bounds will return nil. also says if offset == size and length >= 0 it will return an empty array.

``` If offset == self.size and size >= 0, returns a new empty array.

If size is negative, returns nil. ```

either way if you are doing stuff with arrays and not checking bounds you can throw an `Array(some_array.slice(x, x+100))` and it will always behave.


Sure, the docs seem to be accurate, but that only explains "what will this do?", not "why is this what it will do?" It's not what I expect most people would come up with if they designed this API, so I have to wonder why they didn't pick something more intuitive

the docs say... if index is out of range return nil. the edge case is that if you specify the exact end index of the array and want a slice of that index to 100 it will return an empty array. if you go out of bounds it informs you that you are out of bounds with nil. not sure it's the best api but probably is mimicking some C api somewhere as a lot of ruby does that. that said it will never error on this alone but it will almost certainly error if you chain it with something not expecting nil.

The easiest way to get around that if you are not carefully using the ranges would be to do `Array(array.slice(a, b))` as that will guarantee an array even if it's invalid. you could override slice if you really wanted to but that would be a performance penalty if you are doing it often.


Indeed. I had heard that it was a carryover from C; but for an "implicit is better than explicit" and "magic ducktyping, it just works, I promise" language, like Ruby, this feels like a direct contradiction to its intended behavior and this specific example has always stood out to me in a "... but why?" sort of way.

Yeah, I'd argue that it would be less confusing to return the same thing even if it's inconsistent with some C API that plenty of Ruby programmers might never have encountered. I'm honestly not sure I even understand what the C API is that's being referred to; slices and bounds checks aren't things I typically associate with being built into C.

because it's meant to be a more functional language. if slicing an array out of bounds threw an error it would be java.

[].slice(0, 100).each do |x| puts x end

that shouldn't be an error and it seems to be the principle of least surprise imo.


Sorry, I mis-spoke earlier, this is what I should have shared:

  [].slice(5, 100)
^-- *THIS* either returns nil or throws an exception.

( I made the other comment like this longer, please use that one for context )


It does seem like linux is having its moment right now. there's the money and effort valve is putting into KDE making the steamdeck and steammachine polished for their hardware which helps all users of KDE. cachyos is making having a rolling distro really smooth and snappy on old hardware and making games work mostly ootb. stuff like winboat and wine will let you use the few windows apps you need. you are kinda stuck though if you want to use something like fusion360 or solidworks. freecad has improved quite a bit but it's still like gimp where it's slightly worse UX in a lot of ways.


Valve is doing great work.

Now… maybe we could condense the 10,000 pointless distros down to a dozen? Oops, nope. Now 10,001, except this one has the menu bar in the middle of the screen and it moves around.


The distros are not pointless. For every one of them there was a human being that wanted something to work differently and the nature of open source let them do it. That should be celebrated and the day we loose that flexibility would be a very sad day.

This. Not to mention that for the mainstream users there are mainstream distros that are largely the same they have always been: Fedora, Ubuntu, Mint, so I never really understood the issue of having tons of distros out there for enthusiasts.

I think that both perspectives are right. We should celebrate diversity, but there's also power in consensus.

There needs to be some competition between ideas, but if every bit of disagreement about direction ends in "I'm going to build my own distro, with blackjack and hookers", then we as a community won't ever end up building something that can compete with the megacorps.


This.

It takes leaders. And people with vision. It seems the lack is there, and not at technical makers.


you don't think that it's relevant and concerning that the director of the FBI didn't take operational security seriously enough that his account got compromised? even if they didn't get anything incriminating (which maybe they did and are going to blackmail him later) that show a shocking lack of competency for someone in that kind of position.


we don't even know how it was compromised. was his password "password", or did the hackers exploit a gmail/google vulnerability?


i think the facts of the matter are that a gmail vulnerability is on the very low likelihood kind of event. they wouldn't burn their insanely valuable vulnerability on showing how much of a fratboy kash is. the most likely possibility is that he either clicked on something dumb and gave access through phishing(really bad) or had a really weak password without 2fa(also really bad).


are you suggesting the former is not a demonstration of a shocking lack of competency?


I'm suggesting we don't know how the account was hacked, which is true. could be due to incompetence or not. i don't know, nor do you


True, but don't you think the FBI director should be held to higher standards of security hygiene than average people? Because I'm interpreting your tone as "it could happen to anyone". At some point the doubt is gone and there's no more benefit to give...


Comments in this thread mostly reflect people’s own biases, that is a shallow projection based on the headline.


Did the director have his email on a vulnerable server? Yes. Yes he did.

He should have known better.


Operational security doesn’t apply to personal accounts, no? Otherwise, they wouldn’t be personal.


reading all these comments about windows having better shortcuts and window management features makes me feel like i'm taking crazy pills. windows for me was hands down the worst experience in ux. the shortcuts in macos are so well thought out and consistent.

now i'm using kde in linux land and it's the best and most customizable experience. I can't imagine going back to windows ever and would be missing a lot from linux if i went back to macos(though it would be fine).

getting macos keybinding in linux land is a game changer to me: https://github.com/RedBearAK/toshy and this just makes me feel at home.


I give you a well thought out macos shortcut for example. Ok, it is for a niche feature people rarely use... Screenshots, put straight to the clipboard.

On windows you have 2 options, bot pretty unintuitive:

1. You can either press PrintScreen button... (OK boomer, who uses a full size keyboard? My RGB clicky-keys 57% keyboard doesn't even have backspace, return, escape or delete, I don't even know when I saw a keyboard with Printscreen. My Neofetch-fork does save the screen, and otherwise no need for screenshots...)

2. Or you may press Win+Shift+S. Ok it is hard to memorize, how does S even relate to Screenshot?

Meanwhile on the intuitive MacOs to do this you only have to press Command+Option+Shift+4. So intuitive and easy!!! Also way easier to press, just try it! Only 4 keys to press at the same time, in a very convenient layout, way better than that illogical windows shortcut.

Sarcasm aside: It is clear why Microsoft is well known for the fact that in the 1990s they put a lot of effort to usability research, and why Apple is famous about Steve Jobs being the BDFL, and things had to fit his personal taste.


there's good reason the equivalent shift-command-s isn't bound to screenshot by default... it's the command to save a file and there's no good way to do partial screenshot and full screen screenshot with just command-shift-s + option if you want the option to put it into memory instead of a file. they chose command-shift-3 for full screen screenshot. command shift 4 for partial screenshot and add option to do either of those into memory which is a very common paradigm in macos shortcuts. the option key does something slightly different to the original shortcut in system shortcuts. in any event windows didn't get the non-printscreen version of a screenshot tool until very late in the game and osx had it in for a long time.

that issue isn't even an issue if you really want screenshots to be something else. you can change basically any shortcut in one place in macos. same with kde.


I don’t see much difference to be honest. I didn’t pick up Mac OS until later in life, so windows shortcuts are embedded in my brain. That said, I find Mac shortcuts just as simple to memorize. I’ve used cmd shift 4 thousands of times now and I don’t even think about it, I just press it.


>Meanwhile on the intuitive MacOs to do this you only have to press Command+Option+Shift+4

It's command-shift-4, no option key involved.


Now got hold of a mac, and checked it:

Command+Shift+4 is area snipping, as you said, but pops up the viewer window

Command+Control+Shift+4 is snipping, but to clipboard. I mixed up the shortcuts, yet my fingers are getting used to it anyways, still I find it terrible default UX compared to other desktops.


afaik that way it pops up the viewer, and does not put it to the clipboard.


It probably depends pretty heavily on your workflow. MacOS is designed around doing things visually with a trackpad. If you don't want to work that way, you're just out of luck, because that's the "right way" and if you disagree you're wrong. An example using my preferred workflow: I like to map the applications I use to <meta> (or option on mac) + number keys on the keyboard. So <meta>+1 is my editor. <meta>+2 is my terminal. <meta>+3 is my browser. Etc. If I have multiple windows open, just hit that combo again to cycle in a least-recently-used cycle. I don't have to raise all of the windows from the dock with my mouse and then go find the one I want. I don't have to open some mission control thing and go hunting for a window. I don't have to swipe to another space to remember where I put the window. I don't have to command+tab to a certain number of times to get to the window. I know exactly how to get the application I want with 1-3 key presses. Then once I've raised the window I want, I often want to tile it to one side or the other or fullscreen it with another keyboard shortcut.

Getting this to work on MacOS is a huge PITA. I tried app shortcuts in settings and they'd just randomly not work sometimes for some apps. Apps can override global shortcuts? What??? I tried the "shortcuts" app and it also similarly wouldn't work for some apps and would often forget my key bindings on an update. Tiling via the keyboard would randomly not work either. Multiple apps couldn't fix it. I finally found hammerspoon and scripted an option that consistently works. Rectangle finally solved my tiling issues. But why do I need 3rd party apps that involve writing my own scripts to get basic OS behavior? This is stock Windows behavior.

Beyond that it's just a bunch of papercuts. My dock randomly appears on the wrong screen. My windows sometimes don't get focus when I click on them. The coreutils are old and suck compared to the linux equivalents. Things built cross-platform are often the worst on Mac. Even though they're both sitting behind virtualization, WSL just feels much more integrated than running containers on mac. My usb mic randomly stops working...I've literally had more mic problems on Mac than I did on Linux. Sometimes I need to force kill my browser, and it'll sit for several minutes as a zombie descendant of pid 1 before getting cleaned up, preventing me from opening a new instance of the thing that should be killed. When I had initially mapped tiling to <option>+something, and it didn't work, I'd get a fun unicode character in my text instead, so I had to install an ascii-only keyboard layout to stop myself from looking like a moron who couldn't type. I'm guessing if you're a mac native, the shortcuts make more sense, but after 20 years of windows/linux shortcuts burned into my brain, moving to a mac for work has made me have to pointlessly relearn everything, and it still feels very unnatural.

The hardware is great, but the OS makes me hate this machine with a passion.


this misses the fact that petroleum is incredibly useful outside of the burn it to make electricity and burn it to make car move use cases.


All the more reason to not squander a finite, precious resource to generate electricity.


Not really. If we only need it for petrochemical products, like medical plastics etc, losing 20% of available crude globally is a non-issue.

We can probably stand to use a lot less plastics too. Outside of medicine it's mostly replaceable, and reducing our usage to less than 80% of current usage would be trivial if we didn't burn it for energy.

In that scenario Iran can keep their strait. We won't need them.


So don't use it for cars. It's strictly optional these days.


Not really. Needing 1MM barrels gives you a lot more independence than needing 100MM.


the only two things that would make linux unstoppable would be affinity being first class and having something like fusion360 or solidworks work. there are web based versions of solidworks and another option that escapes me atm that would work but that's the web and it's not the same as native imo. i know there are some opensource projects out there but the ones i've seen have been not as good.


I think AI will help with some of this. We already have an 18-year-old building a Lightroom replacement with Gemini (RapidRAW). We just need to get past the phase of everyone abusing AI and spreading crap all over the place.


I was a programmer at a small company that had their programmers field tech support calls and there is a good reason they do this... most of the people calling in are dumb as rocks when it comes to whatever they needed help with... some called while driving for help that required you to be in front of a computer.


to put this to numbers... the exports are just about 0.5% of california's GDP. so yeah pretty much a rounding error.


0.5% is a far cry from a rounding error..


0.5% is like the literal definition of a rounding error.


Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: