pvgb
Posts: 51
Joined: Sat Oct 15, 2011 9:53 pm

Re: BASIC - more harmful than useful?

Sat Dec 17, 2011 2:05 pm

Ladies, Gentlemen, we are all making assumptions here. The first assumption is that everybody writes the type of programs we write, the second is that everybody sees the problem the same way we do.

I have done some assembler. Easy enough once you get the hang of it. I once wrote an assembler ( for a Z8000 if you must know )
I have written compilers ( It would be in a class called Computer Science 201 these days. ) Easy enough once you get the hang of it.

I have done a couple of Windows apps. ( Took one look at the old Windows SDK - 17 pages of C to get a window saying "Hello world !" - or at least it seemed like 17 pages ... had a go with Visual Basic - good for small/prototype systems, wouldn't like to build anything big with it. Ended up using Turbo Pascal for Windows, then Delphi. Tinkered with Gambas and Lazarus/FPC) Easy enough once you get the hang of it.

Did some concurrency - used Ada for that. Easy enough once you get the hang of it.

Did some parallel processing - used Occam for that. Easy enough once you get the hang of it. ( Did you know there is a version of Occam for the Arduino ? )

More recently I tend to crunch numbers. Mostly in C, probably because I mostly use Linux. Easy enough once you get the hang of it.

Notice the phrase "Easy enough once you get the hang of it." Programming is easy enough (it can't be that difficult because I can do it ... ), learning to program presents an almost insurmountable barrier for whole chunks of the population.

We all have different insights on how to get learners over that barrier. The barrier is only partly technological - there are cultural issues as well.

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: BASIC - more harmful than useful?

Sat Dec 17, 2011 3:23 pm

Quote from jamesh on December 17, 2011, 10:19

1. Writing a big app in assembler takes about 20 times longer if not more than writing the same code in a high level language.
2. More difficult to debug for someone who didn't write the original code.
3. Unlikely to be smaller or faster than a compiled version if the person isn't a real *expert* on the CPU being used, and their are not many of those.
4. It is MUCH MUCH MUCH more cost effective to write in a high level language than assembler.
5. Code size and speed *are* relevant, especially on embedded systems, on desktops not so much. However, decently written C can get to a few percent of expertly written assembler. That's usually good enough.

Ok I see where you are coming from.
As to your points.
1. Yes it would take longer if not all the developers are intimately familiar with the CPU instruction set, or they do not spend much time working in assembly. If you (and your development team) are quite good with the CPU and code in assembly most of the time then the development cycle is a lot shorter than you would expect (the problem is that generally these conditions are not met).

2. Only true if the person debugging does not have the offset tables and original source, or if the person debugging is not quite familiar with the CPU+OS.

3. Anyone that codes primarily in assembler and continuously tries to improve there coding skills will become intimately familiar with the CPU, thus I said a competent assembly language programmer (expert is just an alias for competent and practiced).

4. Go ahead and create bugs.

5. Yes there are some very good optimizing C compilers out there. The problem is that these compilers still leave that 'few percent' and if you optimize for speed you end up with much larger object code. In assembly this sacrifice is rarely needed, it is possible to optimize for both size and speed (giving only a very small increase in size to fully optimize for speed).
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

spock
Posts: 225
Joined: Sun Oct 02, 2011 10:33 am

Re: BASIC - more harmful than useful?

Sat Dec 17, 2011 3:41 pm

what about platform independence? another reason you shouldn't use assembler for most things.

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: BASIC - more harmful than useful?

Sat Dec 17, 2011 4:00 pm

Quote from spock on December 17, 2011, 15:41
what about platform independence? another reason you shouldn't use assembler for most things.

That is just a reason that the initial version should be written in C.

For full platform independence you have to use some form of Toolkit, this adds one or more extra/unwanted layers of abstraction, before release of a good product you want to use the native APIs of the target platforms (we need speed and small size).
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

bradburts
Posts: 341
Joined: Sun Oct 02, 2011 7:07 am

Re: BASIC - more harmful than useful?

Sat Dec 17, 2011 4:46 pm

Optimising assembler is a little easier on a RISC than a CISC, most stuff is one cycle.
But by the time you have multiple cores, various levels of cache, asynchronous memory and code pre-fetch units then I would bet a lot of money that you will be old and grey before you you beat the compiler for all but the most trivial programs.

Its not high level software which slows and bogs down modern computers. Its all the levels of software needed to get the hardware running reliably and present a level of uniformity to the application level. That and the thousands of protocols and file formats.

There are so few good reasons to use assembler; initial boot, where you need to know timings.
A lot of hardware engineers I have known don't trust higher level language as they cannot see what it is doing (I don't understand it either) and use assembler.
They would be a lot better off in C but you can only suggest it.

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: BASIC - more harmful than useful?

Sat Dec 17, 2011 5:08 pm

Quote from bradburts on December 17, 2011, 16:46
But by the time you have multiple cores, various levels of cache, asynchronous memory and code pre-fetch units then I would bet a lot of money that you will be old and grey before you you beat the compiler for all but the most trivial programs.
The few hotspots where you might actually need assembler for its speed (as opposed to early boot and other specific tasks) do, of course, tend to be trivial. However, if you're thinking about dropping down to assembler, a best first step is restating that part of your program in a different way, and wondering *why* exactly what you're doing is slow (in most cases, it's due to crappy design).
Quote from bradburts on December 17, 2011, 16:46
A lot of hardware engineers I have known don't trust higher level language as they cannot see what it is doing (I don't understand it either) and use assembler.
They would be a lot better off in C but you can only suggest it.
You might try pointing out that even "assembler" is actually a high level language running on top of microcode on most processors these days. In other words, they might *think* they know exactly what their code is doing, but in most cases, they actually don't.

Simon

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: BASIC - more harmful than useful?

Sat Dec 17, 2011 5:14 pm

Personally I have no problem with C, Pascal, Ada, Compiled BASIC, or other procedural languages. I do however compile to an assembly listing (with comments) and then hand optimize many things that the compiler got slow.
These languages are great for small projects, not large ones (I like to be able to trace my code and debug the object code). I have seen times where people spend weeks trying to debug something just to find out the bug is in the languages standard library or the compiler itself.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: BASIC - more harmful than useful?

Sat Dec 17, 2011 5:15 pm

Oh ya, and I will always write the most frequent routines in hand optimized assembly, I do not want to take any extra time that could be better used by another task/module/thread.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: BASIC - more harmful than useful?

Sat Dec 17, 2011 7:13 pm

I think there's a competition or two in this, to be honest.

http://www.raspberrypi.org/for.....8;t=1555.0

User avatar
johnbeetem
Posts: 945
Joined: Mon Oct 17, 2011 11:18 pm
Location: The Mountains
Contact: Website

Re: BASIC - more harmful than useful?

Sat Dec 17, 2011 10:06 pm

Gee, I missed out on the beginning of the "ASM >> Basic" debate here, which is probably just as well. But here are my opinions:

1. ASM is wonderful. I'm very glad I know ASM and have mastered several of them. I'm very proud of this. I'm also very smug about it. [Monty Python]

2. I would avoid using ASM for something big. ASM is unportable, very time consuming to write, and very hard to find errors in.

3. I believe it's almost always best to use a language that is closer to the application's problem domain, so as the minimize the amount of "encryption" needed to map the problem into the language. This helps creation, debugging, and maintenance. ASM is pretty far from almost all problem domains.

4. Modern C compilers do an excellent job of optimizing most code, so there is really no point in using assembly language. Yes, it's very important to be able to get a listing of the ASM produced by a compiler since they are not perfect. I've rarely found a compiler error, but I was sure glad to be able to do so. I remember a particular case where the order of assignments was critical to correct operation, and the compiler re-ordered them. Someone forgot to label some variables "volatile", so it wasn't a compiler bug but ASM was the easiest way to find the problem.

5. C compilers for ARM may not do a good job of producing conditionally-executed code, i.e., they may use conditional branch instructions instead of ARM "cond" fields or Thumb-2 IT instructions. That's a good reason to use a better compiler rather than recode in ASM.

6. A standard C compiler may not be able to take advantage of DSP or graphics instructions. This is a good reason to use ASM in small functions with critical performance.

7. A standard C compiler may not know about pipelining and generates code that runs poorly. This is a good reason to use ASM in small functions with critical performance.

8. Most performance problems IMO are not because you have a poor compiler. That may cost you a factor of 1.5 to 6. IMO most performance problems come from using a poor algorithm, e.g., one that is quadratic when a better solution could be linear or logarithmic. For example, I once got a factor of 2 improvement in a matrix application by taking advantage of symmetry.

Hamming once said "The purpose of computation is Insight, not Numbers". Gio Wiederhold came up with the corollary: "The number of computations without purpose is out of sight".

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 28358
Joined: Sat Jul 30, 2011 7:41 pm

Re: BASIC - more harmful than useful?

Sun Dec 18, 2011 10:12 am

Quote from DavidS on December 17, 2011, 15:23
Quote from jamesh on December 17, 2011, 10:19

1. Writing a big app in assembler takes about 20 times longer if not more than writing the same code in a high level language.
2. More difficult to debug for someone who didn't write the original code.
3. Unlikely to be smaller or faster than a compiled version if the person isn't a real *expert* on the CPU being used, and their are not many of those.
4. It is MUCH MUCH MUCH more cost effective to write in a high level language than assembler.
5. Code size and speed *are* relevant, especially on embedded systems, on desktops not so much. However, decently written C can get to a few percent of expertly written assembler. That's usually good enough.

Ok I see where you are coming from.
As to your points.
1. Yes it would take longer if not all the developers are intimately familiar with the CPU instruction set, or they do not spend much time working in assembly. If you (and your development team) are quite good with the CPU and code in assembly most of the time then the development cycle is a lot shorter than you would expect (the problem is that generally these conditions are not met).

2. Only true if the person debugging does not have the offset tables and original source, or if the person debugging is not quite familiar with the CPU+OS.

3. Anyone that codes primarily in assembler and continuously tries to improve there coding skills will become intimately familiar with the CPU, thus I said a competent assembly language programmer (expert is just an alias for competent and practiced).

4. Go ahead and create bugs.

5. Yes there are some very good optimizing C compilers out there. The problem is that these compilers still leave that 'few percent' and if you optimize for speed you end up with much larger object code. In assembly this sacrifice is rarely needed, it is possible to optimize for both size and speed (giving only a very small increase in size to fully optimize for speed).

I'd be very interested to know who you work for and on what projects. Because I cannot see how you would ever release anything in an acceptable timescale working like that. For example, if you were writing Videocore code, let's say the 3D engine, we would still be working on it, and would still be working on it in 10 years time. And that has assembler in it already!

Even the amount of typing required is a factor of 10 to 100 greater than using a HLL. Many millions of lines of C or C++ would translate to many 10's of millions of lines of assembler - and that is platform dependant assembler, so little code reuse moving to a different platform or Arm version.

Sorry, I just cannot see how using assembler to the extent you want to can ever produce a product at the end of the day. You would be wasting yours and your employers time.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

tomo
Posts: 19
Joined: Mon Dec 12, 2011 12:50 pm

Re: BASIC - more harmful than useful?

Sun Dec 18, 2011 10:56 am

Some points very well made above. I can't even imagine doing any enterprise application we do at work in some kind of assembler. If there is any volunteer eager to prove assembler is better (or even sane) here, too, I'd be very much amused to check his/her progress once in a while... There is a reason for higher level languages. It's not just something that happened by mistake or some coincidence.

hippy
Posts: 9164
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: BASIC - more harmful than useful?

Sun Dec 18, 2011 3:19 pm

Quote from tomo on December 18, 2011, 10:56
There is a reason for higher level languages. It's not just something that happened by mistake or some coincidence.

Absolutely.

I spent two decades writing hand-crafted assembler and I've also used C as a 'macro assembler' where I need tight control but did not desire verbosity. It's the abstraction of being able to write 'a = b + c' to save writing many lines of assembler which does the same which is the first advantage, and then it is just a matter of further abstraction and ease of use which follows.

Ultimately one can end up writing 'what one wants to do' and not worrying so much about 'how that is at a lower level than coding at' but that is not always a disadvantage and the gains usually outweigh any disadvantages in my experience. Where the disadvantages are important, then it's fair enough to consider alternatives, but given the choice I know which I would choose.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 28358
Joined: Sat Jul 30, 2011 7:41 pm

Re: BASIC - more harmful than useful?

Sun Dec 18, 2011 3:45 pm

Quote from tomo on December 18, 2011, 10:56
There is a reason for higher level languages. It's not just something that happened by mistake or some coincidence.

I suppose some would argue (wrongly) that high level languages are only there so mediocre programmers can make a living.

Pascal programmers eat quiche etc.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

pvgb
Posts: 51
Joined: Sat Oct 15, 2011 9:53 pm

Re: BASIC - more harmful than useful?

Sun Dec 18, 2011 4:35 pm

When I want to start a flame war, I usually make the assertion that C is warmed over PDP macro assembler anyway ( lights blue touch paper and retires ). I use C most days, and quite enjoy its quirks. (not to the extent of participating in http://www.ioccc.org/ !)

I have taught C (or C++ subset ) as a first language six or seven times over the past twenty years, and the people who were going to be good programmers "got it" . Pretty quickly. The people who weren't going to be programmers were completely flummoxed (There are few things more frustrating than seeing intelligent people struggle with something that you don't find difficult ) Sometimes people convince themselves that they can't do programming before they try. Self-fulfilling prophecy ?

The difference is for the people in between - how many of then would have had a better grasp of programming if we had used a different first language ? This will be on my conscience for some time.

We have tried using Dehnadi's approach to screening as a predictive model, and I would be intrigued to see how it could tie into mental models. This all needs more work, in particular are we seeing a variation on the Hawthorne Effect ? The Forer effect ?

For the record, I have also done about six cohorts of Visual Basic as a first language, and do not have any real sense that the ratio of "got it" to flummoxed is any different.
Three cohorts of Ada ? Pretty much the same. ( They were postgrads, so you would expect variation - not a bit of it !)
A group we did Pascal with ? (OK, some time ago ) Same story.
Did Java once. (Shudders)
Trying JavaScript this year.
Probably Python next year !
Might even go for LOLcode ... ( or is that just warmed over Basic )

User avatar
johnbeetem
Posts: 945
Joined: Mon Oct 17, 2011 11:18 pm
Location: The Mountains
Contact: Website

Re: BASIC - more harmful than useful?

Sun Dec 18, 2011 7:48 pm

Quote from jamesh on December 18, 2011, 15:45
Quote from tomo on December 18, 2011, 10:56
There is a reason for higher level languages. It's not just something that happened by mistake or some coincidence.

I suppose some would argue (wrongly) that high level languages are only there so mediocre programmers can make a living.

My understanding is that the first high-level language -- Fortran -- was invented so that scientists could do their own programming instead of needing a "computer scientist" to code it in ASM. Some even wrote at the time that Fortran would make programmers obsolete.

Sorry, no links. They're probably all on punched cards anyway.

User avatar
johnbeetem
Posts: 945
Joined: Mon Oct 17, 2011 11:18 pm
Location: The Mountains
Contact: Website

Re: BASIC - more harmful than useful?

Sun Dec 18, 2011 7:54 pm

Quote from pvgb on December 18, 2011, 16:35
When I want to start a flame war, I usually make the assertion that C is warmed over PDP macro assembler anyway ( lights blue touch paper and retires ).
Yes, this is completely true, assuming you mean PDP-11. Some people find this inflammatory? Well, I guess it takes all kinds...

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: BASIC - more harmful than useful?

Sun Dec 18, 2011 10:08 pm

I am not sure how we have stayed off topic so long in response to a statement I made.

My point originally was that structured BASIC is a good way into all levels of programming both toward ASM and toward other HLLs.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 28358
Joined: Sat Jul 30, 2011 7:41 pm

Re: BASIC - more harmful than useful?

Sun Dec 18, 2011 10:09 pm

It could be argued, probably successfully, that had computers stayed with assembler, then then PC wouldn't exist, smartphones wouldn't exist, almost anything computer controlled wouldn't exist.

HLL's are the reason why we have all this stuff. Development time would otherwise be much much too long. They are in effect a self fulfilling prophesy. They HAD to be developed.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

Wooloomooloo
Posts: 92
Joined: Fri Nov 25, 2011 10:52 am

Re: BASIC - more harmful than useful?

Sun Dec 18, 2011 10:36 pm

Quote from jamesh on December 18, 2011, 22:09
It could be argued, probably successfully, that had computers stayed with assembler, then then PC wouldn't exist, smartphones wouldn't exist, almost anything computer controlled wouldn't exist.

HLL's are the reason why we have all this stuff. Development time would otherwise be much much too long. They are in effect a self fulfilling prophesy. They HAD to be developed.[Citation needed]

User avatar
johnbeetem
Posts: 945
Joined: Mon Oct 17, 2011 11:18 pm
Location: The Mountains
Contact: Website

Re: BASIC - more harmful than useful?

Sun Dec 18, 2011 10:46 pm

Quote from jamesh on December 18, 2011, 22:09
It could be argued, probably successfully, that had computers stayed with assembler, then then PC wouldn't exist, smartphones wouldn't exist, almost anything computer controlled wouldn't exist.

HLL's are the reason why we have all this stuff. Development time would otherwise be much much too long. They are in effect a self fulfilling prophesy. They HAD to be developed.

One could also argue that HLLs are the reason for software bloat. If it's hard to write code, it becomes worthwhile to spend more time designing and less time coding.

My understanding is that the original, pre-bloat MS-DOS (from Seattle Computer Products) and Macintosh OS were written in ASM, as was MS-DOS Basic. Indeed, IBM chose the 8088 so they could use machine-translated versions of existing 8080 ASM programs. The original Macintosh OS fit in 64KB of ROM, with only a few bytes to spare. Couldn't get that level of efficiency without hair-shirt ASM programming.

obarthelemy
Posts: 1410
Joined: Tue Aug 09, 2011 10:53 pm

Re: BASIC - more harmful than useful?

Sun Dec 18, 2011 11:15 pm

@DavidS: we're bored waiting for our Pis, so going off on any tangent we can grab ^^

@Johnbeetem: the reason for software bloat is that people like it. I don't do more in Word or Excel nowadays than I was doing in (Word + 123) or Framework back around 1990 on MSDOS+DesqView when 640K were enough for everyone. I even had email and news, though no Web and no multimedia. Windows is more shiny though.
If ASM were a viable option for a modern OS and apps, there'd be an ASM OS and ASM apps. Even ubernerdy Linux is mostly C. But please do prove me wrong, and do something in ASM ?

Plus, in the x86 as well as in the ARM world, there are plenty of sub-variants. Throw a couple of switches in a compiler, or do a couple of macros, and the compiler can spit out somewhat optimized code. In ASM, you have to redo for each variant, or you're not optimized either, which kinda defeats the purpose.

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: BASIC - more harmful than useful?

Sun Dec 18, 2011 11:22 pm

I said:

Quote from DavidS on December 18, 2011, 22:08
I am not sure how we have stayed off topic so long in response to a statement I made.

My point originally was that structured BASIC is a good way into all levels of programming both toward ASM and toward other HLLs.

Also this afternoon I began an assembler app for this point, should not take to long to finish.

I have not said not to work in HLLs, They make good wen prototyping an app or for when cross CPU support is essential (very rare). Not to mention they are fun.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: BASIC - more harmful than useful?

Sun Dec 18, 2011 11:25 pm

Or when your boss requires it, this is another time that one must work in an HLL. Though that always takes me longer to do the same thing :) .
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

harrythespider
Posts: 1
Joined: Sun Dec 18, 2011 10:55 pm

Re: BASIC - more harmful than useful?

Sun Dec 18, 2011 11:25 pm

An interesting debate from several angles.

My understanding about the genesis of Fortran is that it's compiler needed to be incredibly good at generating tight code in order to gain credibility with those coding in assembler on the one hand, and be able to fit this code in to quite limited machines of the day... And several references cite this first compiler as one of the tightest ever written.

Today, many good optimising compilers can be had for little or no money... But the very best are incredibly expensive to buy... Many $1000s per seat or copy. And for some languages it is simply not possible to optimise the way some believe they should...

When I first started writing code for a living, it was to build tools that ran on well resourced machines, and frankly the aim was to build working product as quickly as possible, with little thought given to ensuring the final generated code was as small and/or as fast as possible. High level languages were key to this, along with good practice in terms of documentation, data structures, algorithm libraries, testing, and code re-use. Portability was less of an issue but we coded in C as it was readily available on our systems, and known to and by many developers.

More recently all my development work has been in embedded or micro controller environments, and while 32 bit or even 64 bit micro controllers are readily available, along with great tool sets, available memory is typically measured in bytes, if not kilobytes! It's not at all unusual to code some speed-critical elements in assembler and the compilers make this quite easy. Interestingly perhaps, is the fact that when optimising, a compiler can do unwanted things to the final generated code that can be a pig to fix, especially when debugging on hardware with limited debug facilities (or sometimes, none!)

The issue of portability is often about moving for one architecture to another, and this is where a higher level language really helps in the initial porting... Tuning for the new target architecture and embedded system is where a deeper understanding of what the CPU and other system elements are doing, is vital. One of the easiest and quickest ways to build this knowledge is to code in that architecture's assembler...

I am involved in writing an optimising compiler for a variety of micro controller targets, the source language being something closer to Pascal than C, with a ton of features specific to creating embedded systems. The big insight from having been coding a lot in assembler recently for several different micros, and now building this compiler, is in understanding why certain instructions in the micro exist - to help with high level compiler construction - and where hardware and compilers struggle. As a result I now code many of my loops, array and other structures, and condition testing, very differently. Colleagues have called me crazy because the optimising compiler being used to develop this target compiler (stay with me!) will optimise it all for me... I now know that this is not always going to be true... In addition, somebody may not have access to a truly great optimising compiler... With the way my source code is structured, many of these optimisations are built into the source - making it more likely that tighter code is generated no matter which compilers are used...

Does it make my code less readable? Apparently not, according to colleagues. If anything, it makes the detailed intent of a block of code even more clear, aiding some elements of tweaking final code for a given target.

For children to get some early exposure to some aspects of the basics of CPUs and software can really help their broader understanding, help them appreciate the beauty of code and machine in harmony(!) and also help decide - a career in software, hardware or a mix...

In the embedded world it seems more and more companies are developing their software in C for example, and buying faster micros and bigger memory to cope with the inefficiencies of the code these compilers produce, offset by faster development times... But it is the end consumer who buys the products these micros end up in, that ends up paying. Sometimes the trade off favours coding in assembler - for the smaller projects - other times it's the high level language that wins. Knowing more about the pros and cons of both makes it easier to decide when to code in assembler or not, and when to specify a more capable (expensive) micro...

Either way, it can be fun, challenging, and rewarding - what ever your age!

Return to “Staffroom, classroom and projects”