• Unhinged (unregistered)

    I've often wondered who writes these apps for IoT devices because from the quality of these apps they often seem unhinged. Well now I know.

  • Davide (unregistered)

    Many lines of the code blocks are striked through in my Browser and they are not easily readable. It's actually not strike-through decoration of text, but the 1px #ccc border of the .comment class in the CSS. In main.css the border of .comment is commented out, maybe Firefox is picking it the property from somewhere else...

  • Tim Ward (unregistered)

    There are plenty of IoT setup apps which do not say "Hey, you need bluetooth on to talk to bluetooth devices,". And the first time you come across this, how would you know? After all, you're trying to set up a WiFi device, not a bluetooth device.

  • (nodebb)

    I'm confused - how does async in Java work?

    This whole code looks to me like a big pile of junk that has nothing to do with async at all to me coming from the language where the pattern actually originate from.

  • (nodebb) in reply to MaxiTB

    Poorly. Java doesn't have async/await or any other keywords related to async. The options basically boil down to 1) multithreading, 2) callback functions, or 3) using a library that's built on top of one or both of the other options.

    It looks like they went with option 2, and the callback is Consumer<BluetoothGattCharacteristic> consumer (a function that takes 1 BluetoothGattCharacteristic arg and doesn't return anything).

  • Duke of New York (unregistered)

    Android in particular has suffered from Java's inadequate support for asynchronous programming, and the "if you're not me" comment reflects a practical reality that all the existing "solutions" are hilariously prone to misuse.

  • (nodebb)

    Many lines of the code blocks are striked through in my Browser and they are not easily readable. It's actually not strike-through decoration of text, but the 1px #ccc border of the .comment class in the CSS. In main.css the border of .comment is commented out, maybe Firefox is picking it the property from somewhere else...

    I've seen this behavior in other articles, but can't reproduce here. I'm using FF 144.0.2 on Win 11 or FF 128.8.0esr on Debian.

  • (author) in reply to Gearhead

    You can't replicate because I fixed it. It's a conflict between the site CSS and the code formatter we use, which both want to have a comment CSS class. I should really submit a PR to fix it permanently. Mostly I just chuck a style override in the article text itself.

  • (nodebb) in reply to Balor64

    Oh, those are the legacy ways to do async in .net; they are all obsolete with the introduction of 4.0 parallel framework way over a decades ago.

    It's kinda weird, because the Task/Async implementation is actually pretty easy to pull off in every language, so I thought Java has long caught up and implemented it as well. FYI a Task is just a continuation class type which is coupled with an execution context to share data between continuations and a synchronization context to allow synchronizations over non-thread even driven main applications, like the Windows message loop. So there ain't much to it, you could pretty much take the existing code and port it to Java (with a lot of optimizations removed because the Java VM lacks most of those features but it wouldn't in practice result in much of an overhead). The async/await keyword is just a generator making a state machine to chain the continuations, similar to the code you produce when unwinding an iterator. Considering the easy way to pull it off and even PHP managed to do it a while ago, I'm a bit surprised that there is no first-class support for it honestly.

    BTW there are talks in the .net world to make both Span<T> (another modern concept relating to allocation free handling of collections) and async completely integrated runtime features (runtime is a bit of a confusing term for non-.net devs, it refers to both core libraries and core tooling), so basically getting rid of Task<T> workaround all together and directly implement it as a core .net feature. But I don't keep my hopes up for now, maybe that would be a perfect option where Java could take the lead.

  • (nodebb)

    It's actually not that bad. There's a lot of comments explaining what's going on, and anything to do with networking involves a lot of voodoo and functions where odd things can happen or where it's not quite clear what effect they have under certain circumstances. Even something like code for the 30-year-old sockets API is often a morass of special-case handling for odd quirks and differences across platforms.

  • linepro (unregistered)

    Based on the hubris of the comments, cancelDiscovery obviously discovers the resource, initialises communications, sets up handshake and does anything but cancel discovery.

  • Duke of New York (unregistered) in reply to MaxiTB

    Sun/Oracle's solution for async has always been "use threads, dummy," to which developers have replied "but they're slow and heavy," to which Oracle has replied "so's your mother."

Leave a comment on “High Temperature”

Log In or post as a guest

Replying to comment #686831:

« Return to Article