On 4/25/2017 3:29 PM, Cecil Bayona wrote:
> On 4/25/2017 1:49 PM, rickman wrote:
>> On 4/25/2017 2:19 PM, Cecil Bayona wrote:
>>>
>>> An example in my life was writing complex software in C, it became a
>>> major problem in C finding bugs that crashed the system. I was going
>>> insane trying to find the bugs, there was a lot of pressure as the
>>> client was using the software and demanded stability. I bit the bullet
>>> and wrote a program to translate the C code into Borland Pascal, after a
>>> weekend of getting the translator to work right I had a working version
>>> of the software in Borland Pascal, I then turned on all the safety
>>> features in the Borland compiler on and re-compiled the code, within
>>> less than an hour the Borland run code started complaining about
>>> problems, mostly uninitialized pointers, after fixing them the customer
>>> mentioned that in over a week the system had not crashed or glitched
>>> once, this was a big life lesson.
>>
>> What was the underlying cause of these problems? It wasn't the C
>> compiler.
>
> Not the compiler but the language is like the Wild West anything goes so
> if one is not careful you can have mistakes that are difficult to find.
> Pascal and Go are languages that are restricted and check for dumb issues.
The problem isn't the tool. I may not be the world's best expert in
anything, but one thing I have learned is that mistakes are made by
people and only people can prevent them.
One of the most rigorous processes for avoiding mistakes is that used to
design and build nuclear reactors and yet nuclear reactors have problems
and even accidents.
I'm not suggesting that we should build nuclear reactors without
processes to minimize mistakes. I'm saying that for software
development you can do a very decent job by using the sorts of methods
we use in programming in Forth which is to simplify the problems in ways
that make the mistakes easier to avoid.
You said it yourself, "if one is not careful you can have mistakes"...
So program with intent and test early and often.
I guess I have very seldom seen a compiler prevent me from making a
mistake that was, "difficult to find". Those mistakes require a human. ;)
>>> After that experience I stopped using C for projects, Borland Pascal's
>>> compile and run-time checks would catch all sorts of dumb mistakes that
>>> I would have missed using C. It didn't take long to get used to Pascals
>>> wordier way of writing code, and the requirement of explicit casting, in
>>> the end I could write code in my sleep in Borland Pascal and did not get
>>> nasty surprises, it was worth the effort.
>>
>> Did you consider the idea of not writing bad code in the first place?
>> That's where you are with Forth. It has very little in the way of
>> compiler checks. You have to avoid mistakes by not writing them.
>>
>> Personally I find it interesting that I use VHDL and Forth. I don't
>> think you can find two more opposite languages in terms of error
>> checking.
>
> Ah now you are getting to the root cause, writing bad code is too easy,
> and if you are in a hurry you can miss things that will burn you later.
Huh? Not sure what I said about that. But don't be in a hurry. It has
been documented many, many times that spending time up front on analysis
and proper design methods will get you to a finished product faster than
rushing. The hurrier I go, the behinder I get.
> But like you I like Forth which has no checks for anything so what is
> the difference?
The difference is a huge amount of work you spend in VHDL coding and the
huge amount of work you spend in Forth with low level testing. I would
prefer that testing were easier in VHDL. The issue is not so much the
effort required to design a test bench. For me it is the tools which
require you to set up a project and designate folders and all manner of
initialization to begin a simulation. The tool providers seem to be
very focused on the "BIG" picture and not the little ones, so the little
efforts are hard.
> C is usually written top down with a lot of code being written before
> one can test anything, this leads to more bugs, one is building on a
> foundation of untested code.
Nonesense. Forth is often written top down with testing by using stubs.
Or C can be *designed* top down and written/tested bottom up.
> Forth also is like the Wild West but one writes code in a totally
> different way. One writes Forth mostly bottom up, writing small
> routines that are easily tested before using them elsewhere, the result
> is relatively error free code. C on the hand with its lengthy edit,
> compile, then test way of doing things encourages one to add a lot of
> untested code to a program which then tends to have more bugs.
Don't confuse writing code with design. Sounds to me like you aren't
used to performing design separate from coding.
> One of the reasons for looking at Go is it's lightning fast compiler
> which makes it more similar to Forth than to C but still Forth is
> wonderful for testing software as you go by it interactive nature and
> it's culture of writing small procedures that are easily tested, that is
> possible because the low overhead in calling small procedures.
>
> So they could be opposite but the both can work out well.
>
>>
>>
>>> The moral learned was pay now pay later, later bring interest payments
>>> with it so it's far better to pay now. This indecision between Verilog
>>> and VHDL seems a lot similar to my issues between C and Borland Pascal
>>> so maybe that experience applies here too.
>>
>> I have made a lot of money by paying later. I bought two houses on
>> mortgages and both are paid off now with values higher than the cost
>> of the loans. By paying cash I would barely be buying the first one
>> now, if that!
>
> Not applicable here.
It was your analogy... ;)
>>> When I first wanted to start this software project I dug out my old
>>> copies of Borland Pascal but the problem is that they would not install
>>> or run with Windows 10 so that reliable and efficient software was out
>>> of the picture since a new copy is out of reach due to it's cost of over
>>> $1400 for the professional version, that is why I started looking at Go,
>>> efficient yet full of checks to keep you out of trouble.
>>
>> Oh, so you don't use Forth much then? Is that just a hobby thing with
>> you?
>>
>
> For a long time large applications were written in Delphi, smaller tools
> were written in Forth, that worked out well as large applications needed
> a lot of libraries not available in Forth. Small tools specially if they
> interfaced to hardware were a lot easier to write and debug in Forth so
> it was a tool to be used when the purpose suited it, when it does then
> it's a wonderful language where one can write error free code like no
> other.
>
> Actually Forth can be good for large applications but one needs
> libraries to accomplish some complicated task, according to people here
> it's to be avoided.
What's to be avoided??? Using libraries or accomplishign complicated
tasks?
> For Delphi I wrote some B Tree Database routines
> that were incredibly fast but it took a while to debug them and the code
> was fairly large some here insist that it be written for each
> application, that is insane so for large applications I had all sorts of
> libraries in Delphi that were tested and made my life much easier.
>
>> I just don't end up adding bugs to my code so much. With Forth the
>> small unit testing works very well. With VHDL I spend a lot of time
>> thinking about how the code will work together, then simulation finds
>> the bugs much more easily than running in the chip.
>>
>> I seriously think it was an epiphany for me when Jeff Fox wrote that
>> stack errors just mean the programmer can't count. Avoiding stack
>> errors is literally that simple, count the parameters added and
>> removed from the stack. A compiler isn't needed to find those errors,
>> just as, in my opinion, a compiler isn't needed to find uninitialized
>> pointers. Heck, we had to perform requirements traceability analysis
>> which was all done by hand. Why can't uninitialized pointers be found
>> as you code?
>>
>
> In C one can write a lot of code before anything is tested and somewhere
> along the line a pointer might not have been initialized, it's easy to
> miss sometimes.
That is not at all related to the language. You can do stupid things in
any language.
> With Forth that is not much of an issue all routines are small so you
> can see what you are doing.
They are only small if you write them small. In VHDL I try to keep my
modules small although that has a different meaning than in Forth. I
want to try coding the bulk of my work in procedures sometime. I know
people who do that, but I don't see how what they are doing is very
useful. One in particular would separate the three sections of a
sequential process. One was initialization but I can't think what the
other two were. Anyway, he would code the three sections as procedures
which sounds nice from a Forth perspective, but there is no way to test
a procedure in VHDL without the supporting code. He thought it provided
more organized code, but I didn't see the difference since the three
sections are all very apparent when coded inline. They are all dealing
with the same signals and variables, so I just didn't see the advantage
in splitting them up.
So while I think most aspects of design, coding and testing we have
talked about are language agnostic, Forth does lend itself to smaller
module sizes.
--
Rick C