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

I'd love to hear some specific examples. Ive built several iOS apps and a whole backend (on linux) with Swift and other than lack of OSS library support for some SaaS APIs, it's been quite nice.

Sure Swift itself has some sharp edges, but not any more (or worse) than many other popular languages.


Sure! I love talking about this stuff :) here's a few:

- if you want to manager your Package.swift target, you mostly have to deal with .target enum (can't figure out how to paste the URL)

You can really only do a define or unsafeFlags, which leads to a couple issues...

1) There's only Debug and Release configurations! What if you want more? What if you want a nice flow where you emit and consume pgo data and re-ingest it?

2) What if you want to use a define for another language managed by SPM, such as metal?

3) What if you want to put in a portable path into a linker argument? SPM blocks use of build-time environment variables, so you can't do that either.

All of these things seem contrived, but I ran into all three of them at my current job (shameless NanoFlick plug). All of these can be handled by cmake or xcodebuild (although probably better to use rules_xcodeproj).

- Swift compiler feedback and performance in builders is absolutely atrocious, to the point where binary searching a view to find the actual source of a type error over ~30 second build times isn't very unusual!

- It's very overly conservative with build times, and because there's only module-level import, it's very easy to accidentally have a long dependency chain which makes building one file imply building many files, further tanking your build time. There are some forum posts I can dig up on this if you're curious more on this point.

- POD structs are default-Sendable at module-level visibility, but lose that if they're public, which means if you try modularizing your app into different small packages to restore some notion of compilation units to fight against the above two points, you end up having to go around and mark all of your different classes with default protocols (usually just Sendable) to reimplement!

- Not a huge deal, but no way to have macro_rules! like you can in rust: macros are kinda hard to use and have to be in another package.

This is just my thoughts on tooling, I have many more thoughts about the language itself that I'd be happy to share.

Honestly though it's much better with vscode. I do hope that it makes progress in the right direction, Swift has a lot of things going for it!


+1 to vips! It's amazingly fast and stable. I even wrote (some minimal) Swift bindings for it to be used with a Swift backend: https://github.com/gh123man/SwiftVips


I challenge myself to do it in bash one liners. I came up with a clever and shockingly simple solution to part2 using expansion and substitution.

  cat 1.txt | sed -E 's/(one)/\11\1/g; s/(two)/\12\1/g; s/(three)/\13\1/g; s/(four)/\14\1/g; s/(five)/\15\1/g; s/(six)/\16\1/g; s/(seven)/\17\1/g; s/(eight)/\18\1/g; s/(nine)/\19\1/g;' | sed -e 's/[^0-9]//g' | awk '{print substr($0,1,1) substr($0,length,1)}' | tr '\n' '+' | sed 's/\(.*\)+/\1\n/' | bc


"I challenge myself to do it with bash one liners."

Is bash required.

For example, this also works in dash, NetBSD sh, pdksh, tcsh, etc.


does it deal with cases like "twone", "nineight" and so on? it doesn't appear so to me because of the leading sed statements would commit the interpretation regardless of what happens next, but perhaps there is something subtle im not seeing.


It uses capture groups and puts them back in the replacement (the \1 ), so a match of "one" is replaced with (thematch)1(thematch). So eightwo would replace the two with two2two and end up like eightwo2two, so then the t is preserved and eight is found in a later step and then you end up with eight8eightwo2two, and can solve that using part1 only looking for numbers.


I see. Thank you for the explanation. I didn't know about that feature of sed.


okay that's very clever


For my own I did the same, but without capture groups. So replaced "one" with "one1one" naively without regex and did that for all numbers.

While it maybe is post-hoc clever, I think most of us ended up there because we tried naively to just replace "one" with "1", which broke on things like twone. So when down that path one had to amend it instead of going somewhere else.


I had a T420 in college. One day in a CS class, I bumped my (uncovered) cup of coffee and it spilled into the keyboard. I knew the laptop had ducts to drain water out, but never tested it (for obvious reasons).

I blotted up as much coffee as I could with some napkins and kept taking notes on the soaked keyboard. Worked like a charm. After drying it out, a few keys stopped working so I bought a replacement keyboard for ~$20 and swapping it out was rather fast (from memory).

I use an M1 MBP now, but I still have that thing in the basement. It still works, and I loved it. I don't miss carrying it around though (or the hilariously short battery life due to forcing discrete GPU mode so I could dock it for multiple monitors at home).


> After drying it out, a few keys stopped working so I bought a replacement keyboard for ~$20 and swapping it out was rather fast (from memory).

I had an X220 in university (same keyboard part as the T420).

I did wash my keyboard multiple times using dish soap and normal tap water and I only killed a single keyboard (when I didn't wait enough for water to dry out).

You could have most likely just washed the keyboard in warm soapy water, as long as you had enough patience to wait for it to be properly drier (2-3 days at least imho, depending on temperature in your home/area).


Had a similar experience but with water and the laptop stopped working


The spill has to remain in the keyboard area.

Friend of mine in college spilled.. I think beer?.. on this Thinkpad. He instinctively grabbed it (me, across the room, yelling to keep it stable) and turned it to the side. The fluid got into the fan intake and boom, dead it was.


I spilled an entire mug of tea on my X1E when it was just new. That would have killed any Macbook, but the Thinkpad was fine. Turned it off, unplugged the power, let it drain through the bottom. Next morning, open it up, clean it out, turn it on, and it's fine.

Even had time to make a photo: https://www.reddit.com/r/thinkpad/comments/h0663l/good_thing...

Don't count on this too strongly though; not every Thinkpad is spill-resistant, unfortunately.


I have a 2014 MBP that was working fine (except for some screen defects that I did not get fixed before it was too late for the warranty)...

Until I left it in my basement for a few weeks, i.e. in a slightly cold and humid environment.

Now, the keyboard is broken: I need to press multiple times on each key (it's better now that it has dried a bit, but not perfect).

The trackpad is also broken: only hard-clicking works.

Next step is to open and clean it up but I don't have much hope.


I recently replaced an old, power hungry 2U server with a laptop.

I wanted a NUC, but as it turns out a used laptop on Ebay could fetch the same specs (i7-1185G7, 16gb) for less than half the price of the equivalent NUC (without an SSD or memory).

An added bonus is you get a UPS and KVM included!


Maybe a slightly off topic question, but with the recent-ish news of Corellium winning against Apple in court to sell an iOS virtualization service. How is it that virtualizing macOS (on non-apple hardware) is still NOT ok (illegal?)?

Cloud providers are forced to host mac instances on real mac hardware for example (with a lot of strange restrictions).


Virtualizing macOS on non-Apple hardware is against Apple's TOS. It is not illegal. Big difference.


What exactly are the repercussions for breaking them? Sure, Apple wouldn't sell me anything officially anymore, but how could they actually stop me? They evidently can't stop Corellium.


They could sue you in court, and the court could find for them and enjoin you from doing a particular thing (an "injunction"), and then if you did that thing any more you'd be in contempt of court, which can result in fines and jail time.



Agree on all points. It's extra frustrating because GA exposes some metrics that are hard to get elsewhere like traffic sources, organic search, accurate user metrics, live geo location, etc. The only reason I keep it activated (alongside a more flexible alternative) is because it's free.

The whole UX drives me mad.


I am also frustrated with Google Analytics but one thing it does very well (that I can't seem to find elsewhere) is counting unique unregistered visitors. If I had to guess this is done with some advanced fingerprinting - but I'd be curious if anyone has found an alternative for these metrics.


its a simple 2 year cookie for every browser. it's not that complicated.


Nice writeup! Building raycasting engines is fun and rewarding. You can get a lot of visual impact with very small and easy to understand code. I took a stab at it and ended up adding portals which I thought was really fun (https://github.com/gh123man/Portal-Raycaster).

I've been thinking about re-writing my raycasting engine in Rust but never really found the time - glad to see someone has done it and documented it so well!

If anyone else is interested in raycasting this page is also worth a read: https://lodev.org/cgtutor/raycasting.html


I followed your link, and Gate Escape looks pretty fun, but not available in the Australian app store?


It appears my Appstore agreements have fallen out of date and needed renewal. That's a somewhat embarrassing - but it should be fixed now. Gate Escape should be available in all regions, and thanks for checking it out!


Just curious, why do you describe ray casting as a “_pseudo_-3D rendering technique”?


At least as implemented in these retro-style engines, it's a technique with a lot of limitations. Crawling pervasively 2D data, in 2d grids, and grid-aligned 2d wall data, interleaved with 2d screen-aligned sprites with a scaling factor applied. Lots of vertical alignment.

You wouldn't use the same technique to implement a "realistic" 6DOF flight simulator, for example. Wolfenstein 3D released in 1992 - and a mere year later, Microsoft Flight Simulator 5 would be released, with actual 3D meshes and arbitrary 3D rotations coming much earlier.

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


Many frameworks solve this with logger context. Add the properties you want to the logging context and all future logs in that context will have that property.

One simple example - Serilog enrichment https://github.com/serilog/serilog/wiki/Enrichment

This does however assume your entire application uses the same logger. But this is generally a requirement in services that require tracing like this.


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

Search: