|
Nope. No threading, and the thing runs, even after the fact. Everything goes except my SVGs which is what this code is about. It can still parse SVGs from a file, but if built manually the above happens.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
interesting. (frustrating but interesting).
I must confess to being an old, crusty, developer. So here goes.
Add conditional code (via macros or assembly directives that are dependent on a keyword) to define a log file.
Pick spots in you code that you absolutely know have to be executed (start with file SVGs first)
Only use a few prints to the log, you only need to prove that the code is executing the way your brain is telling you it is executing. Then switch to manual SVG test. The log file should be the same. If it is not, then this is the paradox you are looking for. You are absolutely certain that the code must be executing but it is not. You can then concentrate on figuring out why it is not. If the log is identical but the manual SVG is still misbehaving, then you must refine the granularity of the prints by inserting more until you can prove all of the code is executing and still not producing output. (obviously this is not possible, but we are looking for a paradox. A point in the code that is deviating from the norm.)
I know this is not the sexy way of using real time debuggers, but I can not tell you the number of times that I was absolutely certain a piece of code was being executed, only to find it exiting out of a loop early for a reason I forgot about.
Hope this helps a tiny bit.
Good luck.
|
|
|
|
|
I haven't been using a debugger. At this point I'm so used to coding embedded that I've found it's almost quicker not to use one. So what you're suggesting is kind of what I've been doing except more.
It's a console app - see my 2ascii project I recently updated here - but I've hijacked it to test my SVG builder code.
Since it's just console I use fprintf(stderr, "foo"); to "log"
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
Ok
Also, slightly off topic, I looked at the 2ascii project code you posted in the article.
It appears that on the SVG processing logic "If (bmp.begin())" returns false (because the create failed) then the code just drops through to a return 0 out of main without issuing any error message. (JPG and PNG have error messages)
|
|
|
|
|
I'll take a look thanks. To be honest, I threw it together to test some things. It wasn't originally meant for an article so it's a bit sloppy.
However, I've updated the actual code with more error handling, just not the in-article code. I'll take a look and see if the bug is in my final codebase.
Thanks again.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
Gary, your link regarding the AI stuff got flagged by the automod as spam, so it's pending review from one of the moderators.
That said, I saw it in email and was able to peruse the link.
First thing, I need to clarify something. I'm not looking for true intelligence like "here's what I want to generate" and then it just creates code.
I'm looking to essentially expand existing code generators to produce more natural code.
So like, I have a parser generator, Parsley: A Recursive Descent Parser Generator in C#[^] that works great, but would be better if it produced more natural parsing code.
So I'm thinking I could augment a tool like this to do code synthesis. You'd still have to feed it a Context-Free-Grammar (CFG) just like normal**
The difference is simply the generated code would be more natural. I imagine you'd have to train up a model for each generation scenario, but hopefully not for each CFG.
The stuff at the link isn't quite what I'm after.
** an example of a CFG for JSON in my XBNF (extensible BNF) format
// based on spec @ json.org
Json<start>= Object | Array;
Object= "{" [ Field { "," Field } ] "}";
Field= string ":" Value;
Array= "[" [ Value { "," Value } ] "]";
Value<collapsed>= string |
number |
Object |
Array |
Boolean |
null ;
Boolean= true|false;
number= '\-?(0|[1-9][0-9]*)(\.[0-9]+)?([Ee][\+\-]?[0-9]+)?';
string= '"([^\n"\\]|\\([btrnf"\\/]|(u[A-Fa-f]{4})))*"';
true= "true";
false= "false";
null= "null";
lbracket<collapsed>= "[";
rbracket<collapsed>= "]";
lbrace<collapsed>= "{";
rbrace<collapsed>= "}";
colon<collapsed>= ":";
comma<collapsed>= ",";
whitespace<hidden>= '[\n\r\t ]+';
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
You (still) have to confirm the code you're expecting to run is running, and that code that should only run once, runs only once. And what shouldn't run, didn't.
Some events will run multiple times even thought they "sound" like they should only run once; "re-initializing" things you don't want.
Or sometimes one isn't running the "latest" release.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
In this case I'm not doing callbacks except in the rasterizer which is battle hardened and working great for parsed-from-file SVGs as well as working with the builder in my test code, so I'm ruling that out for now to narrow my possibility matrix.
What I am doing is traversing a bunch of linked lists. Something about my data in the data structures is almost certainly wrong which means my builder code isn't doing something.
Complicating matters, much of this code comes from nanosvg which I didn't write, and while I've refactored it such that it's almost unrecognizable there are bits I don't understand.
I'll get through it, as it's more of a motivational issue than a technical one. In a battle with machines I always win - eventually.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
Quote: there are bits I don't understand 😱
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Is it drawing black figures on a black background?
(ducks)
|
|
|
|
|
It's actually a good question, but I really don't think so in this case.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
While I can't offer any technical insight in this case, I can share with you an experience I had just last week. I was in a similar situation to what you're describing. I documented the experience in my progress log. It's verbose and very, very boring, so don't say I haven't warned you. Just know that you're not alone in your struggles. You can be sure of that.
10/20/2023:
Several days ago, I encountered an issue at around 9:00 AM in the morning. It could be the most elusive anomaly I have ever encountered. It's the most time I have ever spent trying to pin down a bug without success. I tried everything I could for 8 hours straight. Over that time, I made zero progress. I put down my laptop, sat back in my chair, and stared at the wall. I couldn't believe how baffled I was. How does this happen? What on earth am I missing? The only option left was to walk away and revisit the issue at some point in the future. As to when that would be, I hadn't a clue. I returned 4 hours later. The only option I could think of was to scrap it, revert to a backup, and start all over again. After 3 hours, I scrapped it and reverted to a backup once again. A couple of hours later, I did it again. After another hour, I did it again, and later, again. I must have done this 5 or 6 times. By 2:00 AM I got to the point where I was just staring at the screen. I was completely exhausted. I pushed on until about 5:30 AM. By that point, I was nodding off. I struggled to keep my eyes open. The code was blurry and I couldn't read it. I don't remember anything beyond that. All I know is that I fell asleep. Aside from that one break, I went over 20 hours straight. It was a surreal experience. When I woke up, I went back to it. This time I made progress. I had to get creative though. I did narrow it down to the point where I could engineer a solid workaround. It works great, but I won't stop until I get to the source of the problem. It's a temporary fix. Since all that happened, I haven't touched a thing. It threw me for a loop, and it's going to be some time before I go near it again. If necessary, I'll revert to a backup I saved a month ago and restart from there.
|
|
|
|
|
Sounds like a wicked bug. Good luck!
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
I know! I've never seen anything like it. When I first discovered it, I thought to myself - Oh, this should be a quick fix... Little did I know...
|
|
|
|
|
Have you tried summoning a demon, speaking its true name, and have it burn the Winduino in the fiery pits of hell fix the bug for you?
|
|
|
|
|
LOL! At this point, I'm willing to give it a try. I don't know how to summon a demon, though. Hello? Attention all demons, can you hear me? Isn't there some sort of demon hotline you can call? There really should be. It's not like I can just pick up my phone and dial 1-800-HI-DEMON. Maybe I'll try using Twitter. I'm pretty sure that Catholic priests provide demon removal pest control. If they start throwing around all that holy water and it lands on my keyboard, I'm screwed. I wonder if I ran a virus scan. Do virus scans detect and remove demons? I will have to look into this. Thank you very much, Sander Rossel.
|
|
|
|
|
I just have been connected for a possible COBOL related job...
"If builders built buildings the way programmers wrote programs, then the first woodpecker that came along would destroy civilization." ― Gerald Weinberg
|
|
|
|
|
|
wow. Do you know COBOL? I've actually written some back in the late 80s. shudder
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
I haven't written any since the early 70s, when we had to write it out on those great big coding sheets. They were then sent to the data prep section who returned us a card deck ready to submit to the mainframe. Happy days!
|
|
|
|
|
Ah the punching routine
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
Oh man, I remember that. My little project was interfacing COBOL output to some C code. Talk about mind blowing, COBOL was just different.
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
charlieg wrote: Talk about mind blowing, COBOL was just different.
Charlie Gilley When people ask me how many programming languages I know, I use to answer something like "Well, the first one is the algorithmic, with conditional execution and explicit loops and stuff - there are dialects called Pascal and Algol and C and Basic and a lot of others names.
The second one is predicates, known under names such as Prolog, regex, XSLT and Snobol.
The third one is matrix programming; I know only the APL dialect, but there are a handful of others. Isn't R a matrix programming dialect?
Number four is list programming. I have programmed a little in the Lisp dialect, for emacs only.
I will count state/event programming as number five, although it usually use an algorithmic or matrix language as "machine code". State/event coding requires an completely different approach than both algorithmic and predicate programming. (Look at the Game of Life example in the APL language article in Wikipedia!)
So, I know about five languages, to varying degrees. Fortran, C#, Cobol and assembly (and scores of others) all represent algorithmic programming. I see them as dialects of algorithmic coding.
We may of course split algorithmic dialects into subgroups, e.g. bases on the data structuring facilities, but they are still programmed by the algorithmic paradigm. And there are some crossovers: Snobol has one foot in the algorithmic world (whereas Prolog doesn't), yet you have to think in predicated terms when programming Snobol.
There was recently a question of 'Pet Peeves". One of mine is when programming language people do not respect the nature of the language. Say, when the APL is expanded with all sorts of flow control from the algorithmic world. That is not how APL is to be used! Or Lisp with classes and object and inheritance. That isn't list oriented programming!
My second Peeve relates to the quote at the top: Lots of people think that they have learned two (or maybe three or four) very different programming languages because one uses square brackets for indexing, the other uses parentheses. Or one uses = for assignment, the other uses := . These are just tiny little details that you have to remember, but your approach solving the problem is 99.99% identical. Schools of today teach one single language.
If you show young IT people completely different approaches, such as Prolog and APL (note: without trying to mold it into some sort of algorithmic-like thing!), they shake their heads and generally refuse to active relate to it. It is just some strange thing, like an African tribal language: They would never consider spending any resources on learning anything as useless as that!
I think that learning different languages - algorithmic, predicate, array, list, ... - stimulates you creativity and ability to develop good workable problem solutions. If you know a few different ways to skin a rabbit, you can apply it to other animals as well. Colleges and universities should teach all IT students at least the principles behind different programming languages.
It would be a lie to claim that all IT people of my generation is fluent in everything from C# to APL to Prolog to Lisp to whatever. We did have a required course called 'Programming Languages' (not about compilers, but about the languages to be compiled!), and I guess that for the majority, that course was their only contact with some of the languages - until they 10 years later had to do some XSLT work, or some statistics in R. Maybe they had to configure their emacs. But quite a few of the students were fascinated by the different ways, and a lot of us played around with the other languages, mostly focused on Lisp and Prolog and some APL. (As seniors, we did a major group project where APL was the only language provided.)
Learning other human languages is considered valuable to understand other human cultures. Learning other (major classes of) programming languages is valuable to understand other ways of problem solving.
|
|
|
|
|
What about SQL? That's not really Matrix, but it seems to me its a Set programming language. I.E. Find me the set of records that match the following conditions. For me, at least, approaching SQL from that perspective has helped make sense of it all.
Keep Calm and Carry On
|
|
|
|
|
I guess that is not the only language not covered by the languages (groups) I drew up!
For the classification of SQL: Geek & Poke: SQL[^]
SQL certainly is not an algorithmic language. It may be embedded in an algorithmic language, maybe LINQ style. The essential characteristic of SLQ is the 'where' clause, which is very much a predicate mechanism. I find it natural to consider it a close relative to Prolog, XSLT and Snobol. The differences are not significant enough to say that it requires a 'programming mindset' different from those languages, to consider it a language (group) of its own.
I am quite sure that others will come up with other groupings. I mentioned state/event as a problem solving paradigm implemented in some other language. One somewhat related that I considered was process languages: E.g. CHILL, used for phone switch programming, essentially fires off thousands of processes (or if you like: Threads - CHILL has no unix-like gluing-together of address space and activity; you manage them separately). When you make a phone call, the switch may have used a dozen processes to handle it. All activity is broken down into tiny processes, much like event-systems break logic down into event handlers.
There may be SQL lecturers presenting SQL as a predicate language, teaching students to think in a predicate way. My general impression is that most developers will mentally translate an SQL predicate to a sequential, algorithmic style, set of operations on tables, as if they were to filter data from C# arrays in C# code.
(That goes for other predicate languages as well: My Prolog lecturer, when explaining the logic of some piece of code, frequently reverted explaining the algorithmic actions taken by the interpreter. We used an interpreter developed by the lecturer.)
|
|
|
|
|