Hacker News new | past | comments | ask | show | jobs | submit | MetricExpansion's comments login

If I understood all the semantic properties, including the separate compilation requirements, correctly, here’s how I think it would be done in Swift with the proposed nonescapable types features (needed to safely express the AsRef concept here). (Note that this doesn’t quite compile today and the syntax for nonescaping types is still a proposal.)

  @usableFromInline
  func _read(pathView: PathView) throws(IOError) -> [UInt8] {
      var file = try File(pathView)
      var bytes: [UInt8] = []
      try file.readToEnd(into: &bytes)
      return bytes
  }
  
  @inlinable
  public func read<Path>(path: borrowing Path) throws(IOError) -> [UInt8] where Path: PathViewable, Path: ~Copyable {
      try _read(pathView: path.view())
  }
  
  // Definitions...
  
  public enum IOError: Error {}
  
  public protocol PathViewable: ~Copyable {
      func view() -> PathView
  }
  
  public struct PathView: ~Escapable {}
  
  public struct File: ~Copyable {
      public init(_ pathView: borrowing PathView) throws(IOError) {
          fatalError("unimplemented")
      }
  
      public mutating func readToEnd(into buffer: inout [UInt8]) throws(IOError) {
          fatalError("unimplemented")
      }
  }


The AI safety people should be ashamed that their legitimate views cannot be easily told apart from the sarcasm of the GP.


The embedded copy of Clang is doing some heavy work I think. At no point does any of the C or C++ code get transformed into Swift. Instead, it's used to import the the header directly into Swift (in a manner similar to a pre-compiled header), and then Swift is able to use the platform C calling convention to directly call the C code. Swift is generally really good at code-switching between various calling conventions, including its own, C, Objective-C msg_send, etc.

Many languages have some facility for importing declarations like that and even using C calling convention to invoke them (e.g. Rust + bindgen), but Swift goes much further than just importing declarations; if the header happens to contain C definition code, it actually compiles that code directly and then can then emit a call to it.

In the case of C++, which doesn't have a stable ABI on most platforms, it likely also knows and emits code using Clang's C++ calling convention for the platform (e.g. Clang on Windows uses the MSVC calling convention and so does Swift when calling C++). But Swift's ability to actually compile C++ code is very powerful in dealing with template functions and classes because Swift can instantiate and compile templated code in the C++ headers. AFAIK it's the only major production language I've seen that even attempts to do this.


I think this whole thread has an interesting contrast to a prior HN thread about Alcohol being unsafe at any level of consumptions and which is rated as a Group 1 carcinogen by the WHO, a much stronger designation than has been given to Aspartame: https://news.ycombinator.com/item?id=34752193

Choice quotes from the top three comments in that thread:

1) “To the extent that we expect agencies like the WHO to help us make informed, practical decisions regarding this sort of absolutist statement seems like an abdication of that responsibility.”

2) “The WHO is fear mongering. Maybe it is good health politics, people are scared of alcohol and people will have a better live. Maybe it would be better to communicate the risks more quantitavily. Not everyone is stupid.”

3) “The thinking is backwards on this. They state there is no scientific safe drinking level. They even compare it to radiation. The goal is to establish an unsafe level. it's like saying there is no safe speed to drive a car - sure that's technically true, but worthless to say.”

I think it’s just emotional reasoning and HN having a classic case of being critical when presented with evidence that contradicts your pre-existing beliefs while being uncritical of evidence that confirms them.


This was the social network that was supposed to support ActivityPub, right? So… maybe logged out support will be good? I’m still not holding my breath though.


This (Group 2B) is the same list that includes mobile phone radiation. I think I’ll take my chances.


Honestly, sometimes I question how much this site is really “hackers”.

I downloaded the SDK and gave it a try. It was pretty seamless to get the sim booted up. However I did have trouble getting any of my hobby apps to build for the native SDK. A lot of libraries will need to add target conditionals to build natively. I finally got one of my most simple apps running, and SwiftUI does translate pretty well into it, but there’s still a bit of visual jank that I guess I could probably learn how to fix. The simulator also does seem kind of slow and unresponsive; I wonder if that’s at all representative of the final OS.


Alchemy ultimately did work out. We eventually did figure out how to transmute elements.


Using nuclear physics --- not chemistry.



Basically. I think Elon is a blowhard idiot who succeeds despite himself and have thought so since 2017.

But I purchased my Model 3 in 2021 because, after cross-shopping many car models and trying to optimize for the characteristics and features I wanted, it was the best thing at its price-point. And even now, even after the Twitter debacle, I still enjoy driving it every day. I couldn’t care less about the man who made the car; the product won on its merits.


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

Search: