|
I think my favourite one was a Cobol compiler message from a Prime minicomputer back in the '80s - which said, "Error 23, line 72, column 21, severity 3: fatal. Either an IF is missing or an ELSE is missing or a THEN is missing or the compiler is broken."
By "broken" I think it meant someone pressed Break, but still...
|
|
|
|
|
That reminds me. Some years ago I saw a list of unusual messages from searching multiple source code files. There were errors something like: "WTF: This should never happen". Well I give them props for covering every possible scenario, even those that should never happen.
At least that Cobol error was comprehensible. C++ template error messages often require a text editor to break it down into its component parts, so you can find the relevant information. Other error messages are not even close to the actual cause of the error; like reporting missing <something> at the end of some standard libraries header file - when the error is, of course, in one of your source files.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence." - Edsger Dijkstra
"I have never been lost, but I will admit to being confused for several weeks. " - Daniel Boone
|
|
|
|
|
I'm guilty of writing such a "can never happen" error message myself in the 90s. It was meant for my codevelopers, but I forgot to remove it before delivering to our client. Thankfully the man doing first level tests on our client's side caught that message before delivering to the actual users, and we all had a laugh.
Of course, that he did see that message meant that indeed something had happened that I hadn't anticipated, and that needed a fix - so it's actually a good thing that this message was still in there.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
That is why they are needed. Although management would prefer a more professional (boring) message.
If it is possible, then code for it. If you think it is impossible, then you are wrong, by definition, if you thought about it in the first place, then it is possible.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence." - Edsger Dijkstra
"I have never been lost, but I will admit to being confused for several weeks. " - Daniel Boone
|
|
|
|
|
The SPL compiler on Prime used to do something similar
|
|
|
|
|
LOL! That's great!
When I was teaching myself C, the Datalight C compiler gave me this: "Lvalue required". I had no idea at the time what an lvalue was and the "internet" at the time consisted of dial-up bulletin boards. That made for a fun afternoon.
|
|
|
|
|
I agree. Regarding vtables, I've seen many errors that require of the user to understand what vtables are, how they are built, and how they are used by the compiler. Without that knowledge, it's near impossible to figure out what's going wrong. Since the compiler is trying to resolve some symbol, at the very least it should point out which symbol it is working on, and where it encountered that in the source code.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
I have seen that automated line (assumption) posted before. How in the world is he supposed to know why a particular compiler prints the messages is does.
This is not a language issue, it is a compiler issue. Most compilers will just print out what they know and leave it up to you to figure out what the problem is. Some compilers will try to break it down for you, but that is, technically, not their job.
Compile after every function/method that you create, so you know where the error must lie. That is the beauty of modern coding, you do not have to get it right before actually scheduling time to compile and test it.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence." - Edsger Dijkstra
"I have never been lost, but I will admit to being confused for several weeks. " - Daniel Boone
|
|
|
|
|
question in the subject
|
|
|
|
|
I do not think anywhere. You can create an article about the subject you want to share with people. Probably add some references. And if it gets through, people will see it. But that's about it.
Also wrong forum.Be prepared to get schooled.
|
|
|
|
|
This guy has already been banned once for spamming - trying to promote his online courses.
|
|
|
|
|
I didn't know that. Thanks.
The article if he creates one won't get through then
No harm done I guess.
|
|
|
|
|
You can't, unless you are prepared to pay for proper advertising.
|
|
|
|
|
I'm reading the book, A Common-Sense Guide to Data Structures and Algorithms: Level Up Your Core Programming Skills[^]
The book has some code samples in Ruby!! Argh!
I converted the first one to C# for you. Although I'm sure most of you have written a bubble sort before and could do it blindfolded and typing only with your mouse.
Of course, Bubble sort is slow and not a great algorithm. But now I understand why far better because of the book's explanation that it's O(N^2) -- runs in quadratic time. Large sets sorted this way will become extremely slow.
And this nice graph from the book shows that too : https://i.stack.imgur.com/LPdjF.png[^]
I'm quite excited to pull this stuff together into some understanding after many years of not quite being able to explain it. I know that is lame.
FYI if you get the Free LINQPad (LINQPad - The .NET Programmer's Playground[^]) you can copy the code below and run it easily.
void bubble_sort(int [] allValues, bool showIntermediateValues = false){
bool sorted = false;
int stepCounter = 0;
while (!sorted){
sorted = true;
for (int i = 0; i < allValues.Length-1;i++){
if (allValues[i] > allValues[i+1]){
sorted = false;
int currentVal = allValues[i];
allValues[i] = allValues[i+1];
allValues[i+1] = currentVal;
}
if (showIntermediateValues){
Console.Write($"{allValues[i]} ");
}
}
if (showIntermediateValues){
Console.WriteLine($" ## Step {++stepCounter} ##");
}
}
}
void Main()
{
int [] allValues = {33,12,10,4,16,44};
bubble_sort(allValues,true);
TestArray(allValues);
int [] moreValues = {100,88,38,53,14,55,40,7,2};
bubble_sort(moreValues, true);
TestArray(moreValues);
int [] presortedValues = {5,17,33,59,72,73,74,75,76,88,99,100};
bubble_sort(presortedValues, true);
TestArray(presortedValues);
}
void TestArray(int [] allValues){
Console.WriteLine("############## OUTPUT #################");
Console.Write("SORTED ===> ");
foreach (int i in allValues){
Console.Write($"{i} ");
}
Console.WriteLine();
Console.WriteLine("#######################################");
Console.WriteLine();
} Output Shown With Steps
// Each Test array is shown with its steps so you can see how inefficient the bubble sort algo is.
12 10 4 16 33 ## Step 1 ##
10 4 12 16 33 ## Step 2 ##
4 10 12 16 33 ## Step 3 ##
4 10 12 16 33 ## Step 4 ##
############## OUTPUT #################
SORTED ===> 4 10 12 16 33 44
#######################################
88 38 53 14 55 40 7 2 ## Step 1 ##
38 53 14 55 40 7 2 88 ## Step 2 ##
38 14 53 40 7 2 55 88 ## Step 3 ##
14 38 40 7 2 53 55 88 ## Step 4 ##
14 38 7 2 40 53 55 88 ## Step 5 ##
14 7 2 38 40 53 55 88 ## Step 6 ##
7 2 14 38 40 53 55 88 ## Step 7 ##
2 7 14 38 40 53 55 88 ## Step 8 ##
2 7 14 38 40 53 55 88 ## Step 9 ##
############## OUTPUT #################
SORTED ===> 2 7 14 38 40 53 55 88 100
#######################################
5 17 33 59 72 73 74 75 76 88 99 ## Step 1 ##
############## OUTPUT #################
SORTED ===> 5 17 33 59 72 73 74 75 76 88 99 100
#######################################
|
|
|
|
|
|
Ok, so far, I watched the first one.
It takes a long while for the sort to even start.
Everything has been done on the Internet.
|
|
|
|
|
look the last two
they are faster
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.
|
|
|
|
|
Yeah, they start right up. That's how I like my algos.
You know, those little videos are actually quite interesting and it's good to think of my data as dancing
|
|
|
|
|
raddevus wrote: Everything has been done on the Internet.
That's right, and don't forget it. Also don't forget a lot of things are done poorly on the internet.
It's great that you're interested enough to implement these things yourself in sample code, to ensure you understand the concepts, but don't reinvent the wheel in real code.
|
|
|
|
|
agolddog wrote: It's great that you're interested enough to implement these things yourself in sample code, to ensure you understand the concepts, but don't reinvent the wheel in real code.
Definitely agree. I'm on chapter 10 now where the book teaches quicksort and the value of recursion in this scope. The author also states :
Quote: In previous chapters, we’ve encountered a number of sorting algorithms, including Bubble Sort, Selection Sort, and Insertion Sort. In real life, however, none of these methods are actually used to sort arrays. Most computer languages have built-in sorting functions for arrays that save us the time and effort from implementing our own. And in many of these languages, the sorting algorithm that is employed under the hood is Quicksort.
THis is why this is a really great book, because the author explicitly makes statements like that.
|
|
|
|
|
Going thru chapter 5 of the book and I just rewrote the provided Selection Sort (from book's JavaScript example) as a C# example and examined it. After that I watched the selection sort dance :
Nelek wrote: Select-sort with Gypsy folk dance - YouTube[^]
The dance really is interesting to see as you see the low value come out and dance with each one, but when the low value gets replaced, the new low value doesn't need to iterate over the other previous ones because it is lower than the previous low and thus lower than the ones that came before anyways.
These dances really are quite instructive.
|
|
|
|
|
raddevus wrote: These dances really are quite instructive. Glad you like them
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.
|
|
|
|
|
That is... Brilliant!
|
|
|
|
|
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.
|
|
|
|
|
I think algorithm analysis is a pretty useful skill to pick up even if you just write "normal" code all day. Big O is the most commonly used but there's also Big Theta and Big Omega[^]. Also there's a cheat sheet [^] for all common data structures and sorting algorithms
|
|
|
|
|