|
Maximilien wrote: Sonar. Nice one. Some friends of mine continue assisting every year.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
|
Background
I am working on iphone app which reads values from an ESP32 in real-time via BLE.
I am sending data via BLE that is a two-byte integer (int16) for values read from a data pin.
Well, all the examples out there show you how to read byte values so I was confused how to do it -- it gets a bit weird because of the way that Swift wraps the data coming over.
Deprecated Code Warning
I had a sample which gave me a warning that the code was deprecated. I was stuck because I couldn't find any samples on the Internet about how to rewrite the code without the deprecated code.
Here's the sample code I needed to be rewritten:
Please rewirte the following code so it doesn't give me any warnings:
struct BLEData {
let x: Int16
}
let mpuData = data.withUnsafeBytes {
(int16Ptr: UnsafePointer<Int16>)->BLEData in
BLEData(x: Int16(littleEndian: int16Ptr[0]))
}
Ask Copilot
When I asked Copilot it very seriously said that the following code would solve my problem:
let mpuData = data.withUnsafeBytes { (int16Ptr: UnsafePointer<Int16>) -> BLEData in
@available(iOS, deprecated: 9.0)
func getLatestImage() -> UIImage? {
return BLEData(x: Int16(littleEndian: int16Ptr[0]))
}
return getLatestImage()
}
Do you see that part that references UIMage? Not sure where Copilot got that code but it is entirely wrong!
Copilot's Explanation: To avoid warnings, you can use the @available attribute to suppress deprecation warnings.
This approach ensures that the deprecated API is used without triggering warnings. Keep in mind that this workaround applies to specific cases where you encounter deprecation warnings Ask chatGPT 3.5
let mpuData: BLEData = data.withUnsafeBytes { rawBufferPointer in
let int16Ptr = rawBufferPointer.bindMemory(to: Int16.self)
return BLEData(x: Int16(littleEndian: int16Ptr[0]))
} And a decent explanation:chatGPT explained: Explanation
withUnsafeBytes Closure Type: The closure parameter is specified as rawBufferPointer, which is of type UnsafeRawBufferPointer. This is more general and avoids type inference issues.
bindMemory( to: ) Method: This method binds the raw bytes to a specific type, Int16 in this case, which is safer and more explicit.
Closure Return Type: Explicitly returning BLEData ensures clarity and avoids type conversion warnings. That code worked perfectly!
chatGPT Wins This Round
This round goes to chatGPT.
|
|
|
|
|
I'm part of a discord programming server that's mostly filled with very young coders that don't have much experience. I tend to mentor folks there, and it's why I haunt the place.
So many lean on LLMs to understand code, or even produce code. It concerns me deeply.
I don't trust LLMs to produce reliable code. I also fear that their tendency to be confidently wrong (with citations!) can lead people using it to learn to make terrible mistakes and adopt anti-patterns.
Last time I checked ChatGPT got code wrong 51% of the time. Maybe things have improved, but I don't know.
All this talk about LLMs replacing whole swaths of developers? So far I'm just not seeing it.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
honey the codewitch wrote: I also fear that their tendency to be confidently wrong (with citations!) can lead people using it to learn to make terrible mistakes
I agree, wholeheartedly. I use these tools as a last-ditch-effort. When I can, I like to find answers to problems online from real humans. However, if you look at this BLE (bluetooth low energy) that I'm trying to do, the explanations are often non-existent. People use wifi connection way more than BLE but I like bluetooth because it means your data is local. I just want to transfer data between my phone and a local device.
Anyways, these tools should really only be used when the person already understands 95% of the code and needs help with the extras.
honey the codewitch wrote: All this talk about LLMs replacing whole swaths of developers? So far I'm just not seeing it.
I have felt the same way, but I did have one really great experience with Copilot recently where it explained something extremely fluently and then also directed me to the source code for the BLE portion that I could not find via Internet search.
Internet Search Issues
Here's the one thing that I'm starting to see where AI is more advanced.
As we all know, Internet Search is "biased". It finds the things that are "most found" and gives you those.
When you have a really esoteric issue you will probably find that you cannot find an answer.
That's because those answers are buried by search engines because they are not "popular".
My Point
AI can find things that you cannot find. and that part is really weird.
AI seems to do a better job of "contextualizing" the thing you are searching for, while the Search Engines mostly just go for straight "popularity". These are the places where AI may win.
EDIT - Maybe A Better Analogy
I think an analogy to what the "Talking Heads" are saying about "AI Take-over" should be more compared to Power Tools.
It's as if the invention of a table saw would suddenly make everyone a "Master Wood Crafter".
It just ain't so. And the same is true of software development.
You still got to understand how things fit together.
modified 16-May-24 10:02am.
|
|
|
|
|
Great analogy! So true.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I found a bug in my UIX library having to do with DMA and multiple transfer buffers. It only reproduces on one platform. I've narrowed it to a specific process, but I still don't know why it halts. It doesn't do it right away, so it's an intermittent problem. The best kind.
*cracks knuckles*
Edit: Fixed the bug.
Prior to working on lil embedded widgets I was spoiled. I had numerous ways to do forensics on my running code, not the least of which was a debugger.
I don't typically have a debugger anymore, and while it's possible to use debug probes with embedded gear they're usually so slow that I want to get out and push.
Now since I don't have one, I've been forced to think more clearly about how my code runs and what it's doing at runtime at any given point.
One day a guy told me GFX was failing after a couple of days when writing text. I immediately narrowed it mentally to three places within a labyrinth of code, with a most likely culprit that turned out to be the thing. I knew it because it smelled like heap frag and I was right.
That's just one example. The opener of this post is another, assuming I'm right about it (I am)
A few years ago I wouldn't have been able to do that.
I'm super glad for these new abilities. It feels a bit like a superpower.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
modified 16-May-24 10:46am.
|
|
|
|
|
Yes, back in the day we either had no debugger or one which was unusable (I'm looking at you, OpenVMS).
A developer must know how to debug without a debugger and must know when to use one and when not to.
90% of bugs don't require a debugger, just common sense.
|
|
|
|
|
I've been coding since '86 so I cut my teeth on programming without a debugger. However, my code was much simpler because my machines were at best 2MHz 16 bit lil monsters with 256KB of RAM at best a 1.44MB floppy. Now my little widgets often have megabytes of program storage, gobs more RAM and run at hundreds of MHz or even GHz speeds. That and I didn't have C and C++ available. I was using Pascal, BASIC and assembly.
It's a different world. My code is so much more complicated now. I have threading to contend with, including multiple cores in many cases, several different ways of doing wireless comms, and an entire Internet to talk to. Things are just different now.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
One of my university professors was talkin about 'debugging by cranial massage'
That was in 1977. The standard debugging method was adding console output statements in the appropriate places - which takes a lot of practice. It gave me a valuable 6th sense in where to place breakpoints in more recent debuggers: Several times, people looking over my shoulder asked 'Why do you put the breakpoint there?' I answered honestly: 'Dunno. It may be a good place for looking around' - and it was.
I didn't see a decent debugger until around 1980. Some of the features of that one, I still miss: You could single step by function call rather than by line. And you could set the range for single stepping (by call or line), e.g. to a single function or module - or set in a large unit and reset in subrange within that module, leaving step breakpoints only in the interesting parts. There may be other debuggers with these features, but none of those I have been using over the years.
Of course it was missing a lot that we take for granted today, and it obviously was CLI and not GUI oriented, so I wouldn't want it back in its original form. I still wish we could pick some features from that old software and add them to today's debuggers!
Religious freedom is the freedom to say that two plus two make five.
|
|
|
|
|
trønderen wrote: The standard debugging method was adding console output statements in the appropriate places
This is my life now. And it has similarly honed my abilities.
trønderen wrote: I still wish we could pick some features from that old software and add them to today's debuggers!
Absolutely.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
Now we have "Time Travel" debuggers which I have attempted on several occasions and always failed.
|
|
|
|
|
BernardIE5317 wrote: "Time Travel" debuggers
TARDIS and sonic screwdriver not included.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Maybe that is why I failed.
|
|
|
|
|
This is an interesting perspective. I agree that debuggers (and profilers) tend to influence the result often to the point of being unable to reproduce the issue. I still use debuggers and profilers, but I try to detect issues more proactively.
I generally instrument code and send live updates to a web page hosted by the application. It's more than a live logger; it monitors performance, exceptions, memory, and resources. Those items are visual and time-tagged, so I can often pinpoint the guilty party of misbehavior while it's happening and before the system goes sideways.
So, I agree that debuggers aren't always the approprate debugging tool. Our problem-solving toolboxes should be a little deeper than just a debugger.
Keith Rule
|
|
|
|
|
I had been programming for 5 years before I even heard of a debugger. Early debugging was reading core dumps (can you think how many pages they would take now), and stepping through the code by putting the processor in single-step mode and reading the lights on the console in binary to see what was happening. The only input devices were punched cards and console switches. The outputs were lights on the console, punched cards, and a line printer.
|
|
|
|
|
Yeah, I started coding without debuggers too.
The difference is my code.
In 1986 I was writing little, relatively simple applications. A checkbook balancer. Some stick figure animations. A few games. Stuff like that.
I didn't really need a debugger. My code and data typically had to fit in 64KB.
That's not the case now, even on embedded.
It's far more difficult to conjure a working mental model of my modern code at runtime, even if it is written better, and more properly organized. The reason is simple complexity. Getting good at building and then traipsing through my mental model of my modern code at runtime is what I'm getting at.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
I would hate this.
It would probably be good for me.
I lean heavy on the whole fast build and see if it goes and correct what doesn't. I'm sure some could watch a recording and think it spaghetti chucking.
Intellisense has gotten progressively worse with the verbosity of its descriptions because of the brigade against all code comments (maybe especially the XML ones). So you get method definitions from nugets where even if it's clear how you should call something, exactly what's going to happen when you do is a scientific endeavor of experimentation. Maybe it's exactly spaghetti chucking, but what other way is there to decode these black boxes?
|
|
|
|
|
I installed VB6 and got some old stuff running![^]
That's about three days in lost productivity, so I hope it will be worth it
Registering the COM Callable Wrapper was a pain and took most of the time.
I needed to run regasm.
The trick was in setting the /codebase parameter, which shows an error, but still does something that made it work
Also running it with the -tlb switch somehow works miracles.
For anyone who may have to do this sometime:
regasm -tlb C:\Windows\SysWOW64\MyCCW.dll
regasm C:\Windows\SysWOW64\MyDLL.dll /codebase /tlb:C:\Windows\SysWOW64\MyCCW.tlb The VB6 codebase has a total size of 1.63GB, plus VB6, which is another 3.77 GB, makes it 5.4 GB.
The VM I needed to run it was a staggering 203 GB, which takes quite a chunck out of my 1 TB drive
It now sits safe in some external storage (I don't dare delete it yet)
That alone should be worth it
|
|
|
|
|
A Tip/Trick in the works?
|
|
|
|
|
Congrats, Sander.
Now if only you could figure out how to get the original Minesweeper installed on Windows 10/11!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
VM with a Windows 98
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Don't know if you're serious, but done that for my aunt that absolutely despises windows 10/11 ad ridden games.
If you are serious, look at win7games.com, it has an installer for the old games that works in win 10/11. The only caveat I found is that windows update sometimes deletes the games and it needs a reinstall
|
|
|
|
|
Sander Rossel wrote: regasm
Wow, the memory of old tools that I have long since forgotten...
It's amazing how we can be intimately familiar with certain tech & then never think about it again, unless someone mentions it.
There are some things I'm glad to forget too.
|
|
|
|
|
I feel for you! Around half of my company's codebase 1.7M LOC (100+ apps) is in VB6. The difference is, I didn't inherit it, I created it. Migration efforts have been very slow as new projects take precedence and there really is no payoff (besides technical debt) when the legacy apps continue to work on the latest MS OS.
The biggest hurdle you are likely to face (if you are actually trying to get those projects running in VB6/debug) is older third-party components without an installer. Good luck and have fun!
"Go forth into the source" - Neal Morse
"Hope is contagious"
|
|
|
|