News:

Let's find out together what makes a PIC Tick!

Main Menu

How do you even start to write a compiler?

Started by JonW, Jul 23, 2021, 03:04 PM

Previous topic - Next topic

JonW

Question for Les on how do you even start to write a compiler and keep track of the changes in commands and variants in devices etc.  It must be a horrific amount of work and totally do your noodle in! :o

Deadly serious question.  My main line of work is in Microwave/RF but I spend much of my time designing test kit for mass production, hence the MCU involvement.  The complexity of the compiler and its sheer "Perfection" from one man is more than impressive and it would be great to understand how this is achieved with respect the  amount of work that goes into it. Its literally saved me as a designer, thousands of hours of work and I trust the code it produces and its always more efficient than any other compiler and my own efforts in assembler.   Over the  last 15 years I've used this compiler and the code generated within over 20 Million  or more products.  I can literally write code in hours that would take weeks to complete.  I can also break from the code and come back a year later and literally within an hour be back in it due to the structure and the compilers documentation/examples, granted I still study the assembled code, more from morbid curiosity than to identify issues and often smile, or grimace in most cases, at its simplicity/efficiency and then return to my RF world thinking how bad my coding is but at the same time am thankful i have it in my toolbox, I as many others take for granted the true brilliance of the compiler.  Fair play Les...  hats off and thanks x j


top204

#1
Question for Les on how do you even start to write a compiler and keep track of the changes in commands and variants in devices etc.  It must be a horrific amount of work and totally do your noodle in!
With great patience and a curious mind. :-) I started with a series of articles by Jack Crenshaw, back in 2003, that outlined the requirements of a compiler, and the principles behind them. I then wrote my own lexical scanner/parser in C++ so that I could imitate the BASIC Stamp II syntax to a certain extent, but there were aspects of it I did not like, so I adapted them to other syntax. i.e. The declaration of variables and constants.

Most people use, what I call, compiler compilers, in so much as the executable actually creates the full code for a compiler parser based upon a script named BNF, but they do not allow singular commands and, generally, only create 'function only' compilers, which was no good for the early PIC microcontrollers. They also create code generating scripts, so a separate program is required to create the unique assembler code for the device being compiled for, and this is where the skill comes in, because this part of a compiler can make bloated code or streamlined code. It all depends on the time taken to gain knowledge about the device, and the time taken to write the streamlined code in all of its iterations. Unfortunately, this seems to be a rare case these days with some of the assembler generated by most other compilers.

Then, over the years, I added more variable types and features, and had to learn the architecture of the new PIC and PIC24 and dsPIC33 devices coming out and change the parser and assembler code generator to suit them as well. This is a big job that takes a lot of reseach and a lot of code writing, and a lot of time.

If the compilers had had "real" marketing with advertisements and promotions and a good web site, they would have been a lot more popular and I would have made a bit of money from them, but I made a big mistake with the people I trusted, even when they were taking 50% of the sales and doing, essentially, nothing! I do not have a business head, so I assumed it was being done correctly, but I later realised by looking at other, inferior, compilers that the marketing for them was actually zero!

All the work on the compilers was done in my time in my home office. I have about 500 gb of compiler source code backups and they all have times of "out of work" hours. Whenever I make a change of anything in the compiler source, I backup the source first with version, times and dates etc... That way I can go back a day or so if something has gone wrong with the code I create. It also shows a record of the compilers being "my" creation alone from their conception of about 2003!!!

If the compilers had become more popular with good marketing, or "any" marketing, I would have had incentive to create compilers for other microcontroller devices from other semiconductor companies, but that did not happen, unfortunately. Essentially, I blame myself for my stupidity in trust, but never again!!!!!

JonW

Really interesting, Its such as shame this compiler never gained the momentum like some of the others as its way better and I really do think a version for Arm would sell as the devices are much cheaper and more widely used than the PICs, however supporting this and another platform would surely increase your workload even more.

What is happening on the development boards?  If you need any assistance getting them finished and ordered etc then then drop me a PM or an email. 

Jon

keytapper

I think Mr Les should consider some partner to keep his masterpiece going farther.
Ignorance comes with a cost

top204

#4
I have actually thought of putting up the compiler sources and names for sale on some sort of professional bidding site...

I am in a financially difficult period at the moment and we need to move house ASAP to try and ease my state of mind, so the compilers may bring in a few 10s of thousands of pounds to allow the house move to happen. The buyer would receive "all" the source codes from about 2003 onwards to present day, and for a small fee, I would maintain them for 12 months or so, but not add to them for that fee! All the source codes on my systems would be erased permanently, so the compilers would belong to them only.

I truly love my compilers, but sometimes reality has to kick in and I am spending far too much time on them for very little "real" benefit, but I will never let the compilers die or go stale while I am around.

CPR

Quote from: top204 on Jul 27, 2021, 10:03 AMI have actually thought of putting up the compiler sources and names for sale on some sort of professional bidding site...

I am in a financially difficult period at the moment and we need to move house ASAP to try and ease my state of mind, so the compilers may bring in a few 10s of thousands of pounds to allow the house move to happen.

I guess any value of the (Positron) compilers to a prospective purchaser of it, would be down to some demonstrable growth rate of the user base. But I think the main stumbling block is unfortunately the language, Basic. Not something unfortunately -imho- that's considered "professional" these days. So perhaps think on how better to aim Positron at hobbyists and tinkerers. Then offer it for sale once you have figures demonstrating its uptake and potential growth through some form of chargeable upgrade path perhaps. That'll put a base value on what you might then reasonably expect to get for it? Do you advertise it anywhere? Have you made contact with any of the electronics mags to promote it? Have you considered a website with an easy way to make purchases? Through PayPal directly for instance? (I don't mean your existing one where an email has to be sent to storypainter first. Positron@compilers_R_us might have been a better name to pick ;- jesting) Anyways, best of luck!

top204

#6
I simply cannot afford to advertise, or even afford a web site!

The compiler upgrade sells, maybe, 3 per month!

I know this is probably because of no advertising, and no dedicated web site, but it is a catch 22 because I cannot afford to pay for them so they bring in no money to make money. :-)

CPR

Quote from: top204 on Aug 03, 2021, 02:18 PMI simply cannot afford to advertise, or even afford a web site!

The compiler upgrade sells, maybe, 3 per month!

I know this is probably because of no advertising, and no dedicated web site, but it is a catch 22 because I cannot afford to pay for them so they bring in no money to make money. :-)


It's a catch 22 then which needs to be broken, yes?

Have you considered giving out free "watermarked" copies to any of the popular magazines, with say demonstrable comparisons
of your codes efficiency (size & speed) versus all the competitors? I'm thinking in particular of one very popular basic
compiler by a large firm beginning with a "M" ?

That could be a juicy tidbit to generate interest?

Have you considered perhaps taking on a partner that you feel you could work with, who may be willing to invest time and
funds in marketing? A bank loan? (the lenders would need hard figures placed in front of them, projected growth, targets etc.,
and a convincing argument of why your compiler is so much better then the competitors) Venture/Tech capital maybe?

Do you (or your circle) have any contacts in largish firms which use PICs in their products that perhaps could be approached?

Is there any route to licensing - any unique tech you have in your compiler?

Is it an "easy" task to give the compiler or another version of it - a more C++ feel? (Given that's more of an expected/accepted norm these days)

Just thoughts out loud. Perhaps food for thought? Either way I hope helpful.  :)

trastikata

Quote from: top204 on Aug 03, 2021, 02:18 PMI simply cannot afford to advertise, or even afford a web site!
...
I know this is probably because of no advertising, and no dedicated web site, but it is a catch 22 because I cannot afford to pay for them so they bring in no money to make money. :-)

I am pretty sure the lack of dedicated web site is the first and foremost reason for the compiler not being renown as it should. Even if one wants to refer to Positron on his/her site there is no link to give, so in my opinion this is the first issue that needs to be addressed.

Just and idea - I think there are enough well situated (professionally) people here that wouldn't miss say 100 or 200 dollars each. And if you give them some incentive, say you make them minor shareholders or something similar (hell I would do it anyway if it only meant you can keep the compiler alive for couple more years) to get them involved, I think it won't be hard to get 20-30 people to spring 100-200 USD which would be enough financing for well designed web site. Once the dedicated site is up and running the things will get easier for advertising and referrals.

If you decide this is an option I would gladly participate. We can make a list with people wishing to contribute and once there is enough to finance the website we can transfer it to you so you can give it a go. Just an idea... 

basiclover


Stephen Moss

Quote from: trastikata on Aug 10, 2021, 04:07 PMI think it won't be hard to get 20-30 people to spring 100-200 USD which would be enough financing for well designed web site. Once the dedicated site is up and running the things will get easier for advertising and referrals.

Unfortunately, I think you will find it harder to raise the amount of money your are indicating than you think, and even if you could I don't think it would last very long. I do not know how much things cost these days but I would think a professional web designer would probably be at least 800 dollars for the initial design and then 80 dollars for maintenance every time you want to update anything, and based on what I remember from running a site about 10 years ago about 70 dollars a year for hosting and the domain name.

Consequently, if someone who is already paying for hosting with spare capacity to store another small site would be willing to do so and someone else with time (and preferably some experience) were willing to create and maintain the website then all that would be left to cover is the relatively small cost of the domain name instead of the much larger amounts otherwise required.

trastikata

Quote from: Stephen Moss on Aug 11, 2021, 06:51 AMConsequently, if someone who is already paying for hosting with spare capacity to store another small site would be willing to do so and someone else with time (and preferably some experience) were willing to create and maintain the website then all that would be left to cover is the relatively small cost of the domain name instead of the much larger amounts otherwise required.

Stephen, hosting and domain name is not that much as cost, 40 USD per year total. However to create a professionally looking web site one needs creative artist skills, which costs considerably more than the domain and the hosting.

top204

#12
Quotehosting and domain name is not that much as cost, 40 USD per year total.

Many thanks Trastikata, yor words were a pleasure to read.

Where could I find a web host and name for $40 per year? I've looked around quite a lot and they are all "rip off" merchants. They adsvertise low prices, but then when you read the small print thoroughly, that low price is for the first year, then the price goes up a lot! Also, for sites that can have some form of selling system, they want stupid amounts of money per month!

And they know once you are on their hosting system, they have "got you" and it is difficult to move, so they can charge what they want every year, and they do increase the price every year.

trastikata

Hello Les,

I've been using this hosting https://www.namecheap.com/hosting/shared/ (Shared-Stellar option) for the past 12 years and never had any issues. They also include excellent tools to build your own site and DB backup, web-shops etc..

Also my previous offer stands, I've registered the domain www.positroncompilers.com and will prepay it for 5 years and as soon as you have hosting, I will transfer the ownership - without a hosting I can't transfer it even if I want to!

JohnB

#14
For what its worth, I have hosted my PositronStudio.co.uk site with Netcom.co.uk.  Their prices for hosting my site are £110 + VAT per annum. This includes 2 email accounts and Wordpress with Divi extensions. I designed the website myself but I paid for a 15 min of one to one help to get me started. There are a number of things I still want to do with it which require getting into the lower levels and are beyond my competence level.  As I have offered before I can extend the site for the Positron compilers if you would like.

I have to say that the link trastikata referred to does look good value.
JohnB

John Drew

Again as an example only my website is hosted by panthur.com.au an Australian company and I use their Mini option for AUS$6 a month. That's about £3.20.
I have 2 GB of storage. Plenty for my needs. In addition I pay $17 per annum for the URL.
So it's not that expensive and it is very reliable and I speak to people who are in a call centre here.
The company doesn't play the "bait" game.
I'm not trying to talk you into this company, only to say there are reputable companies out there with reasonable deals.
John

top204

#16
I cannot thank you all enough. :-)

Trastikata, that hosting company is a one I never saw before, so I read up on them and have purchased a hosting site for 2 years and it only cost £56, with a domain name. Many thanks. I asked my lovely wife if it was OK to spend the money and she was over the moon because I now have my own web-site, even though she is not techically minded, bless her. The domain is called "RosettaMicro.com", but the domain name "PositronCompilers.com" would be very welcome and I could attach it to rosettamicro.com, I think?

I can now write my articles and tutorials and try to promote the compilers and my projects I have in mind, such as my Story Painter bedside lamp and 3D music box etc...

JohnB. I very much appreciate your offer of using your host, but with things that have happened to me in the past, I had to do it myself because we do not know what is around the corner. It still worries me about this forum, because I have no idea who is now controlling it, since that lovely gentleman OG passed away too soon, or where it is located in the net etc...

John D. The fact that you looked around and have replied to help me, means a lot more than you may realise my friend.

I am so glad to call the people on this forum "friends". It helps lift me out of my depression. :-)

Now.... I have to work out how to use CPanel to create my website, and create some images for it. :-)

Yasin

Quote from: top204 on Aug 11, 2021, 01:07 PMIt still worries me about this forum, because I have no idea who is now controlling it, since that lovely gentleman OG passed away too soon, or where it is located in the net etc..

Presumably dear @gevv is admin. He also manages this website.

CPR


John Drew

Yes, gevv is the main admin and is probably paying the bills but he has effectively gifted it to Les. It is very generous of him now that his friend has passed.
John