oceaneng
Posts: 2
Joined: Thu Dec 15, 2011 2:52 pm

Re: BASIC - more harmful than useful?

Thu Dec 15, 2011 8:33 pm

One more case study (for what it's worth)...

I started my programming career with BASIC, on an Apple IIgs in the mid-to-late '80s, copying short programs line by line from magazines.

Over the years, I moved to QBasic, VB, then finally to C/C++ and Java (picking up a few others on the side like Fortran, Python, PHP, ASP, etc.). Looking back, I appreciate the simplicity of BASIC and I think it's still a good start for understanding, at a superficial topical level, how "Programming" works.

That said, C/C++ really gave me better insight (when I was older/wiser?) into the details...optimization, embedded assembly, memory management, etc. that helped me (hopefully) to become a better programmer. I still find myself coding in text editors occasionally and "get back to the roots" with command line compiling/linking. With the IDEs, I set and forget hundreds of flags/options/etc., never to be remembered again without lots of digging.

I hope there is some simple language, BASIC or otherwise, available for the Pi (in some form) that will allow children/beginners to write simple code and see results of their work without too much "optimizing, compiling, linking, waiting, etc."

Great job Pi team. Keep up the good work and can't wait to play with one!

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

Re: BASIC - more harmful than useful?

Thu Dec 15, 2011 8:41 pm

Quote from hippy on December 15, 2011, 17:13
The stock answer is 'more capable hardware allows things to be done easier, quicker or with less effort' so it depends what end result one is looking for; a shorter and easier development cycle or a faster performing system.

I'm not sure seeking to reduce development time can truly be called laziness; that's more a trade-off between spending longer on one thing and doing fewer other things, or spending less time on each and getting more things done.

I don't believe anyone sets out to waste instruction cycles or memory it's just a consequence which is absorbed by better hardware.
No, it's not called laziness, it's called a combination of "person at the keyboard is a coder, not a programmer" (="getting paid to work, not to think" and boy does it show...) and/or "economic viability" (aka "a deadline", scientifically engineered to no more than 75% of the absolute minimum required time for the project, or 25% of the time required to do it properly). Also, it's not a tradeoff: all I've ever seen was the slider being jammed squarely onto the "do it faster" end of the scale, 0% being allotted to "make it faster".

The snag is, however, that the waste in coding (it's not even CPU cycles, noooooooooo sir - it's bloody blocking waits, where there should be no blocking calls allowed, ever, period.) is not absorbed by more powerful hardware at all - what you get is merely a futile attempt to make up for some of the waste, while things keep getting slower and slower: nothing today runs half decently on anything but the current generation of hardware. Honestly, I find the idea that a period software on a period hardware generally runs faster than the modern equivalent (which however does now have 500% more functionality, of which I only ever use 0%) very, very repulsive and hard to swallow. It's just plain wrong.

If anything, breaking out of this vicious circle would be a worthwhile goal for the Pi. Unfortunately, I'm really not sure how that could be achieved. Proper programming would of course help a lot (and here the Pi could really help), but on the other hand writing everything in assembly isn't really an option either. I'd really love to see a language that manages to simplify the increasing complexity back to levels the human brain can efficiently handle, without introducing serious loss of performance, but I'm not holding my breath...

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

Re: BASIC - more harmful than useful?

Thu Dec 15, 2011 9:22 pm

Quote from Wooloomooloo on December 15, 2011, 20:41

No, it's not called laziness, it's called a combination of "person at the keyboard is a coder, not a programmer" (="getting paid to work, not to think" and boy does it show...) and/or "economic viability" (aka "a deadline", scientifically engineered to no more than 75% of the absolute minimum required time for the project, or 25% of the time required to do it properly). Also, it's not a tradeoff: all I've ever seen was the slider being jammed squarely onto the "do it faster" end of the scale, 0% being allotted to "make it faster".


I agree about the cause of the problem, and that is laziness on the part of the employers. "Productivity in software engineering can not truly be measured in Lines Of Code, or hours worked".

The most productive coders are those that do it correctly. They may not produce as much product, though they do produce the most usable product.
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

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

Re: BASIC - more harmful than useful?

Fri Dec 16, 2011 12:27 am

We forget that the B in Basic stands for "Beginners".

I think that somebody who can program in Basic can at least program, and has the foundation of learning to program in many of the other languages that we all preach about.

Conversely, somebody who can't program can't even begin to move to C/C++/Python/Java/Malboge.

If we suggested putting 3 year old children behind the wheel of a Formula 1 car we would be accused of murder. (or get some sort of Darwin Award by proxy). Sit the same child on a small bike with stabiliser wheels and they get a chance to learn the basics (pun intentional !) and may move on later.

Programming is a depressingly rare aptitude - why scare people off by shoving too much complexity in their faces ? Is it a coincidence that so many people were programming on 8 bit micros back in the 80s, and we are struggling to find people to do pretty much the same tasks on our shiny 64 bit monsters ?

Some of these IDEs scare me !

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

Re: BASIC - more harmful than useful?

Fri Dec 16, 2011 12:49 am

Quote from pvgb on December 16, 2011, 00:27
We forget that the B in Basic stands for "Beginners".

I think that somebody who can program in Basic can at least program, and has the foundation of learning to program in many of the other languages that we all preach about.

Conversely, somebody who can't program can't even begin to move to C/C++/Python/Java/Malboge.


Excellent points. IMO Basic is a completely reasonable way to introduce the basic elements of programming like variables, expressions, control statements, subroutines, arrays, and strings. You can do useful exercises with these.

When it comes time for serious data structures programming and recursion, you'll probably want a language designed for it like Pascal. C as a first language is problematic IMO. Better to learn an assembly language first, and then learn C as a dandy way to write portable assembly language using high-level notations. JMO/YMMV

User avatar
lobster
Posts: 57
Joined: Sun Sep 11, 2011 6:57 pm
Contact: Website

Re: BASIC - more harmful than useful?

Fri Dec 16, 2011 1:23 am

And what BASIC or other future programming language will be used on Pi-Quantum processors of the future?
http://tmxxine.com/web/asq3
The reminiscing children of tomorrow will describing how they moved code around on their ancient touch screen tablets handed down from an older brother (yep we never had thought controlled interfaces in ye olde days - we even had to type in 'code'. Yes Siri, tablets did not even understand spoken English in them days . . .)
Perhaps we need to ASQ the kids to write down the specs for the new language
and then provide it . . .?
http://peace.wikia.com/wiki/ASQ
Sorry above link is at least 5 years old and yet we are still discussing the merits of Ruby v Squeak v Complanned Basic?

Try Gambas
http://gambas.sourceforge.net/...../main.html
. . . something new . . . at least

Where is AMOS Basic and Dark Basic for Open Source?
Maybe we need to play a different game?

User avatar
NormanDunbar
Posts: 111
Joined: Wed Nov 23, 2011 12:13 pm
Location: Leeds, West Yorkshire, England.
Contact: Website

Re: BASIC - more harmful than useful?

Fri Dec 16, 2011 8:09 am

Quote from DavidS on December 15, 2011, 21:22
The most productive coders are those that do it correctly. They may not produce as much product, though they do produce the most usable product.
A sorry tale from my fairly recent past. A company I worked in was looking to make redundancies - no, nothing to do with the fact that I worked there - so the manager went a wandering.

In one room of programmers, he found a dozen people all coding away, lots of activity, very busy.

In another room, another group were doing a lot less work. Pretty laid back atmosphere etc. They were working, just didn't seem as busy as room number one.

So, come the day for cuts, the programmers in the second room were made redundant.

Wrong decision! Those were the best programmers and the system they worked on was running pretty damned well. The programmers in the first room were the code monkeys who were busy fixing their own bugs. Major fail.

And another major fail came not long after I was made redundant - the firm got into serious trouble and was asset stripped by a much larger company. Me, I started my own business - and, so far, I'm still working. And I started on ZX-81 Basic, self taught from PCW Magazine.

Maybe what we need is a Raspberry Pi Foundation for Proper Programming and Analysis - need a snappier title though! ;-)

Cheers,
Norm.
Why do they put lightning conductors on churches?
Why did Tarzan never have a beard?

User avatar
lobster
Posts: 57
Joined: Sun Sep 11, 2011 6:57 pm
Contact: Website

Re: BASIC - more harmful than useful?

Fri Dec 16, 2011 8:43 am

need a snappier title though!

Codeberry
Geek Skool
ULTRA - Unorthodox Lateral Thinking and Raspberry ARMed

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

Re: BASIC - more harmful than useful?

Fri Dec 16, 2011 2:21 pm

Ah yes Beginners All-purpose Symbolic Instruction Code.

Though most of the BASIC dialects mentioned here have been for Linux, Linux is complex from the programmers view. I would like to restate: this is an ARM based system, Risc OS is a fairly simple OS and it is designed for the ARM, and the ARM for Risc OS.

Some people also forget the All-purpose part of BASIC.
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
johnbeetem
Posts: 945
Joined: Mon Oct 17, 2011 11:18 pm
Location: The Mountains
Contact: Website

Re: BASIC - more harmful than useful?

Fri Dec 16, 2011 2:49 pm

Quote from DavidS on December 16, 2011, 14:21
Ah yes Beginners All-purpose Symbolic Instruction Code.
...
Some people also forget the All-purpose part of BASIC.
I assume "All-purpose" in this context means "All purposes suitable for Beginners". Otherwise IMO it's just Marketing.

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

Re: BASIC - more harmful than useful?

Fri Dec 16, 2011 3:57 pm

Yes; it is a 'Beginners' language, this does not limit its use. Especially if you are using BASIC V on Risc OS, as you have pointers, and SWIs directly available. Not to mention that it has a built in assembler, and at least 2 compilers available (ABC from Risc OS Ltd. [Commercial], and Whizz [Free]).

While BASIC may be a 'Beginners' language, it is still powerful enough to create applications of any type, and any UI. For some things it is of course necessary to compile the program, as ANY interpreted language is a bit slow.
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?

Fri Dec 16, 2011 4:09 pm

I wish to note that Linux is not a good platform to learn to program on. To illustrate this, Take a minimal Linux system (Kernel + minimum set of modules + init + login + sh + a C shared library + minimal set of needed support libs) and you already have a system with an extraordinarily complex API (and even in BASIC the API will have to be learned at some point). Though yet a complete Risc OS system with a bunch of extras, including the USB, Ethernet, and TCP/IP modules has a fairly simple and strait forward API. I love Linux, though it is not for Beginning programmers, The Pi has an ARM CPU at its core, take advantage of this and use Risc OS as the teaching OS. If necessary add a third version that is $50USD and based on the Model B with a commercial Risc OS license from Castle.
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

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

Re: BASIC - more harmful than useful?

Fri Dec 16, 2011 4:12 pm

I see some complicate a lot with these "rights" and "wrongs". What made old home computers and their BASIC so attractive to me back then was how well the language was "integrated" into the computer. Plug it into the wall, turn it on... and... here you are... type, program, interact with the system, execute some BASIC sentence, program, do something, see something happen... and being able to do something useful, something you could store and use later... Perhaps the best language to start kids with technically using computers would be bash shell operating/programming. I'm not kidding. I think bash would be excellent... if it wasn't so damn hieroglyphic... So, I don't think it actually is anything close to it.

The idea I like, is something like scriptbasic, yabasic, smallbasic (not the one from Microsoft) in interactive mode etc. being integrated with the system like a command shell, in some smart and smooth way. Would it be usable as a teaching tool? It could be. It would, if done right. Harmful? Hell, no! Unless someone would get an idea containing a weird necessity to use a single tool (language) to teach every and each aspect of computer programming and control. And I've already exposed my firm belief that the "one tool for everything" idea is wrong. Education should be, I believe, about solving problems and choosing the right tool, not about getting into a too comfortable sit with any language or paradigm.

So, regarding BASIC, well, sure, I am a bit (and a bit more) nostalgic. I try to not be biased too much, due to it. But, anyway I turn it, I don't see a good reason why BASIC should be regarder just unsuitable. Who says what "BASIC" is, should be, should not be, can or should not do, after all? As it is, it's just an idea of a language syntax to give grounds, not limits, to any actual implementation. But, all that talk... the language is not so important here, in my oppinion, It's about how it's integrated into the "machine". When we were kids, it was hard to imagine that programming isn't part of using computers. Nowadays, it seems like programming has very little - if anything at all - to do with computers. I don't think kids should be "programmed" with this "vision", not if we want to raise future programmers.

MattD
Posts: 3
Joined: Mon Nov 28, 2011 5:59 pm

Re: BASIC - more harmful than useful?

Fri Dec 16, 2011 4:50 pm

Fully agree with tomo - I should admit up front that I'm no teacher and my programming days are long over. I especially identify with the plug in and go thing - I've never really worked out how to code anything on a PC - it always seemed like too many steps and stuff to be installed and configured before I can even get started.

But knowledge never got in the way of opinions, so here's my recipe for what kids need to know -

1.Some understanding of what a 'computer' actually does (I won't attempt to define that - too risky!)
2. An appreciation of how to write simple instructions to get it to do anything at all - syntax etc (I wonder if kids of today are taught to appreciate any kind of rules........most computers tend to be pretty unforgiving)
3. Some idea of how to break a bigger problem into a series of smaller steps so that you can use the instructions to carry it out. (kind of handy in other parts of life too - even if you aren't a techie)
4. Experience of what steps you actually go through to make that happen.
5. A bit of encouragement to experiment with stuff (in my day it was modifying games I'd typed in from magazines), and some inspirational 'can do' attitude.

I honestly can't see how it matters what programming language you use - so my recipe says preferably one which a wide range of teachers can pick up and teach after a few evenings of self study.

If you get that far, then some kids will want to go further. At which point you can throw in elegant design and coding, a choice of languages etc etc a some teachers who can guide them. But at least everybody has some appreciation for how a mere 2 million lines of code of some sort can make their TV display things from tinternet.

And hopefully out of all that comes a small cadre of people who go on to do clever enough things to keep the UK economy viable.

And now, in anticipation of the imminent arrival, I will finally work out how to install a python environment on my PC.......

User avatar
Burngate
Posts: 6046
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: BASIC - more harmful than useful?

Fri Dec 16, 2011 4:54 pm

There seem to be several opinions on this thread.
1) BASIC's old therefore out-of-date.
2) It teaches bad habits. Teach a more rigorous language eg C
3) It was easy to get into in the old days, and still should be.

1 is a red herring.
2 depends on what and how you are teaching.
3 should be true but isn't.

The "Hello World" fallacy - "Look how easy it is to create a program in language xxx"
Yes, but you've hardly learned anything! Look at all the things going on under the bonnet to get it to work!

If you're teaching 6-year-olds, you need to show them how to get started with the minimum of "load this then start that then open a window here" - you need "switch it on and start typing"

If you're teaching 12-year-olds, you need a more under-the-hood detail.

For GCSE you're going to expect a more adult, disciplined approach, including structure so something like C. But you would hope they've already had some exposure to programming, which would have come, possibly, from a Basic or Python interpreter.

As to RiscOs, with its built-in Basic interpreter (which is very fast) it has been promised (and I'll be getting it as-soon-as). If nothing else, it would show a GCSE pupil that there's more to life than Windows/Linux

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

Re: BASIC - more harmful than useful?

Fri Dec 16, 2011 9:41 pm

If there was one ideal programming language we would all be using it.

( Actually, some aged contrarians like me would be holding out for SNOBOL/APL/PDP 8 Assembler/Occam/Brainf**k/<your-niche-language-here> - (Hey, is this the first pseudo BNF on this forum ?) )

Once you can program you can pick the right tool for the job.

Key ingredients ( already alluded to in this thread ! ):
Immediacy ( see the prompt straight away )
Instant gratification ( type something in and see stuff happen )
Straightforward mapping between cause and effect ( is it clear what keywords actually do )

I really don't care what language is used as long as I don't find myself saying "I really don't know why they designed it that way ..."

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 12:37 am

Agreed; As long as it does not impede the understanding of assembly, all is good.

Though Assembly is always the ultimate language. It has been proven time and again, no compiler can produce as well optimized of code as a competent human programmer period.
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

kme
Posts: 448
Joined: Sun Sep 04, 2011 9:37 am

Re: BASIC - more harmful than useful?

Sat Dec 17, 2011 1:02 am

Quote from DavidS on December 17, 2011, 00:37
It has been proven time and again, no compiler can produce as well optimized of code as a competent human programmer period.That certainly depends on the boundary conditions: Given unlimited time (=money) you are right. Otherwise you are underestimating optimizing compilers. They do a surprisingly good job compiling a mediocre source into something either fast or small (but rarely both). And optimizing compilers never have a bad hair day or are unfocused after a fight with the wife.

In an ideal world hand made assembler wins hands down, but who last saw an ideal world? Humans can't even beat computers in chess anymore.

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

Re: BASIC - more harmful than useful?

Sat Dec 17, 2011 1:14 am

@DavidS: the issue is, optimizing code is irrelevant in the overwhelming majority of cases. Speed of development, maintainability, reliability, readability, even the oft-exaggerated evolutivity/recyclability of code are way more important in the great majority of cases. Unluckily, assembly sucks on pretty much all those criteria.
Nobody is arguing that competently done assembly code isn't smaller and quicker than other languages. It's just not that relevant anymore. CPU cycles and RAM are a lot less expensive than developer time, and the difference keeps widening.

liam collins
Posts: 17
Joined: Sat Oct 29, 2011 5:06 pm

Re: BASIC - more harmful than useful?

Sat Dec 17, 2011 2:37 am

Quote from obarthelemy on December 17, 2011, 01:14
Nobody is arguing that competently done assembly code isn't smaller and quicker than other languages. It's just not that relevant anymore. CPU cycles and RAM are a lot less expensive than developer time, and the difference keeps widening.

In commercial terms, all of the above are true, however if you're talking about a teaching system then using Assembler is, in my opinion, the best way to teach the hardware/software interface that the 8-bit micros taught my generation (yep, I'm that old :) ). Countering my love of Assembler, I do think people need to be taught a proper structured language (though not OOPs).

I am not a "BASIC basher" and would say that teaching flowcharts will cause more 'harm' than any individual language; better and more structured diagrammatic methods for showing how code works exist and should be used.

With the comments about the complexity of LINUX (or any current main stream OS) I would have to agree. Maybe what would be best is a library set that 'hides' the monument number of calls from the user, initially, but allows them to explore each one when they're ready (wrapper library with sensible defaults). I understand that modern desktop GUI are, by their nature, complex but that needs to be hidden from the user until they are ready for the challenge. Think back to how many kids gave up on programming when they first met the basic POKE command and then had to read the technical (badly written) documentation.

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:43 am

Quote from obarthelemy on December 17, 2011, 01:14
@DavidS: the issue is, optimizing code is irrelevant in the overwhelming majority of cases. Speed of development, maintainability, reliability, readability, even the oft-exaggerated evolutivity/recyclability of code are way more important in the great majority of cases. Unluckily, assembly sucks on pretty much all those criteria.
Nobody is arguing that competently done assembly code isn't smaller and quicker than other languages. It's just not that relevant anymore. CPU cycles and RAM are a lot less expensive than developer time, and the difference keeps widening.

Speed and code size will always be relevant. Why should I upgrade my RAM just to have newer software waste it to do less in a more 'pretty' manner? Why should I upgrade my CPU just to have apps run as slow as the hand assembler written equivalent would on a system 1000 times slower (this is also to blame the OS architectures and driver modules that sleep [thus wasting otherwise useful time] or code that blocks when there is no need [all of which could be avoided by good programming practices]).

As to reliability, maintainability, and recycle-ability of code, these areas rule in Assembly, as long as the Author correctly comments there code.

Yes it is true that it takes longer to develop a product using assembly than if using a high level language, though the end product is usually going to be better debugged, and if the programmer is familiar with the CPU faster and smaller when written in assembly.

Now is it more cost effective to have a developer spend twice as long to produce a high quality product, or to produce a functional product in half the time and have to pay him 16 times as much time to do bug fixes as they are discovered? As a project written in assembly and well commented lends itself to easy debugging do to the fact that you trace the binary to find the bug with out having to see how the debugging tables of a HLL line up to the binary, and you can directly debug the production version (as you are not using debug symbols so there is no 'Debug build')
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:53 am

I made an omission:
If you keep an offset table of some form, and a good assembly/machine lang toolkit it is not to difficult to directly patch binaries if the need arises, and do so in a way that directly and accurately reflects the changes made to the source. This also makes getting bug fixes to the customer much easier.
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: 23869
Joined: Sat Jul 30, 2011 7:41 pm

Re: BASIC - more harmful than useful?

Sat Dec 17, 2011 10:08 am

Quote from obarthelemy on December 17, 2011, 01:14

Nobody is arguing that competently done assembly code isn't smaller and quicker than other languages. It's just not that relevant anymore. CPU cycles and RAM are a lot less expensive than developer time, and the difference keeps widening.

Actually, I would argue that! I think assembly needs to be better than 'competent' to be better than a good optimising compiler - it needs to be done by a real expert.

Case in point, we sometimes use assembler in the Videocore code, but the vast majority is C. And yet we require maximum speed and efficiency. Assembler is used when we need to use vector instructions (no compiler for it), or we need to do sometime like SD RAM calibration where you are doing very accurate timing and need to count instructions. I've read that SD ram code - it's pretty incomprehensible, and written by someone better than competent!

With regard to teaching assembler, I think you need to teach what it is, and how it applies to what the CPU actually does, maybe a few instructions as examples, then you need to teach people about compilers and how they translate higher level languages to assembler, thereby getting them on to somewhere they can do real work! Writing in assembler takes too long and produces too little to keep people who are starting out interested.

You really don't need to teach someone a particular assembly language in any depth early on. Once they have the hang of higher level languages, if they want to specialise on assembly, go for it at that stage.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

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

Re: BASIC - more harmful than useful?

Sat Dec 17, 2011 10:19 am

Quote from DavidS on December 17, 2011, 05:43
Quote from obarthelemy on December 17, 2011, 01:14
@DavidS: the issue is, optimizing code is irrelevant in the overwhelming majority of cases. Speed of development, maintainability, reliability, readability, even the oft-exaggerated evolutivity/recyclability of code are way more important in the great majority of cases. Unluckily, assembly sucks on pretty much all those criteria.
Nobody is arguing that competently done assembly code isn't smaller and quicker than other languages. It's just not that relevant anymore. CPU cycles and RAM are a lot less expensive than developer time, and the difference keeps widening.

Speed and code size will always be relevant. Why should I upgrade my RAM just to have newer software waste it to do less in a more 'pretty' manner? Why should I upgrade my CPU just to have apps run as slow as the hand assembler written equivalent would on a system 1000 times slower (this is also to blame the OS architectures and driver modules that sleep [thus wasting otherwise useful time] or code that blocks when there is no need [all of which could be avoided by good programming practices]).

As to reliability, maintainability, and recycle-ability of code, these areas rule in Assembly, as long as the Author correctly comments there code.

Yes it is true that it takes longer to develop a product using assembly than if using a high level language, though the end product is usually going to be better debugged, and if the programmer is familiar with the CPU faster and smaller when written in assembly.

Now is it more cost effective to have a developer spend twice as long to produce a high quality product, or to produce a functional product in half the time and have to pay him 16 times as much time to do bug fixes as they are discovered? As a project written in assembly and well commented lends itself to easy debugging do to the fact that you trace the binary to find the bug with out having to see how the debugging tables of a HLL line up to the binary, and you can directly debug the production version (as you are not using debug symbols so there is no 'Debug build')

Whilst you make a couple of relevant points, I pretty much disagree with everything else you have written!

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.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

Bakul Shah
Posts: 321
Joined: Sun Sep 25, 2011 1:25 am

Re: BASIC - more harmful than useful?

Sat Dec 17, 2011 11:07 am

Quote from jamesh on December 17, 2011, 10:08
Assembler is used when we need to use vector instructions (no compiler for it), or we need to do sometime like SD RAM calibration where you are doing very accurate timing and need to count instructions. I've read that SD ram code - it's pretty incomprehensible, and written by someone better than competent!


For something like this I would be tempted to write a program that spits out the correct assembly code (and can try various alternatives to get the best code -- sort of a super-optimizer. Doing this by hand can be time consuming and error prone, particularly if some parameters change). Of course, the eventual output can be totally incomprehensible! But one can test each baby step of an equivalent transformation that gets you there.

Pretty much agree with the rest of the points James made but wanted to stress that even in such areas where you *have* to write assembly code, it is often easier, quicker, more correct and more flexible to write a specialized code generator than write assembly code by hand. Usually you can just profile your HLL code and then optimize its hot-spots. Even then, 9 out of 10 times you can do so in the HLL itself.

True, a competent programmer needs to have an idea of how the compiler maps a high level language construct to low level code, but not much more. More detailed knowledge is gained on an as needed basis (e.g. chasing a compiler (or chip) bug or hot spot optimization or special purpose code).

Return to “Staffroom, classroom and projects”