Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Best programming Language??

Status
Not open for further replies.

raedbenz

New Member
HI,..
i am intending to start learnig C or Basic for programming PIC's..
which language do you recommend(except assembly).??
 
The language that gets the job done is the best language.

Learn assembly. It will force you to understand how the PIC works which will make you a better programmer when it comes to using high level languages.

Once you master that, C is high level language of choice for the PICs.

Why on Earth would you dismiss assembly?
 
I see assembly recommended all the time, but I think it makes more sense to learn a high level language first and be comfortable with it before delving into the detail of assembly.

Mike
 
raedbenz said:
HI,..
i am intending to start learnig C or Basic for programming PIC's..
which language do you recommend(except assembly).??

Hi

i will also join you and i feel you can learn C --however, assy language is manytimes required as support. Particularly when you have to fit the code into small space-- optimization by other languages may not be that efficent as what you could do -- not at amature level but after gaining experience.

So, all the best
 
upand_at_them said:
I see assembly recommended all the time, but I think it makes more sense to learn a high level language first and be comfortable with it before delving into the detail of assembly.

In my opinion, while that might be true in some cases, I don't think it is true for microcontrollers. PICs aren't at all the same as PC's, where many things are abstracted away from you... There's no command line terminal where you can print a nice "hello world" message on a PIC! Instead you're always programming with a direct interface to the hardware, so you really have to understand the hardware. As phalanx states, assembly will force you to understand the hardware better. One of the biggest reasons in my mind is that the PIC is pretty limited in its capabilities, so you should always be conscious of what kind of assembly code your program written in C or BASIC is going to compile into. On a computer, you don't even think about things like multiplying and dividing 32-bit integers or performing floating-point math... but on a PIC, some of these operations can take thousands or tens of thousands of instruction cycles to execute because of the lack of direct hardware support of such math. If you start out doing assembly you'll quickly gain firsthand knowledge about what can and what cannot be done efficiently, and then later on when you are writing code in C you will always have a feeling for what is really going to happen when your code is compiled.

This is not to badmouth higher level languages at all... I use C pretty much exclusively on PICs, however I still don't recommend it as a first step. Even if you only spend a short while with assembly, do a handful of basic to intermediate projects (maybe work through a bunch of nigel's tutorials), it should benefit you.

Plus, if you ever have to get down to some short-duration precision delay routines (like if you're bit banging some sort of serial protocol) that can usually be done with more certainty in assembly, and many C compilers will allow you to use inline assembly code for this reason, among others, so that's yet another good reason to get a feel for it.
 
Hi,
Evandude's opinion is totally correct to my imagination. Higher level languages can be learnt later in due course.
 
I only use assembly.

I can't see any advantage in using a high level language for PICs.
 
ljcox said:
I only use assembly.

I can't see any advantage in using a high level language for PICs.

Depends on what you're doing. There's no way I'd attempt the USB interfacing stuff I've been doing lately with assembly, it would take me the rest of my life. And even for simple stuff, I can still throw together a program a lot faster in C than in assembly, and the written code is generally shorter and easier to read and follow than assembly. And, more and more C compilers are becoming compatible with MPLAB, so that you can do full simulation and C-source-level debugging directly in MPLAB, which makes them even more convenient for getting a project up and running more quickly. Not that I see anything wrong at all about spending plenty of time on projects, but the faster I can finish one, the faster I can start another, because my to-do list never ends!

But when I had to build a device that could transmit serial data at a rather high rate relative to the clock speed of the PIC (couple of dozen instruction cycles between output transitions) I didn't even think of using C, I went straight to assembly where I could control exactly how many clock cycles everything would take without worrying about the compiler making different optimizations and changing things. There's a time and a place for everything.
 
Last edited:
ljcox said:
I only use assembly.

I can't see any advantage in using a high level language for PICs.

Perhaps your programs are not that complex.

Assembly produces efficient code using lots of man hours.

High level languages produce varying degrees of efficient code using far less man hours.

95% of industry could care less about code efficiency so long as the program works. 100% of industry wants to spend as few man hours as possible to complete a project because time is money.
 
thanks

thanks guys for your efforts,,,,,
i am using Assembly since two years and it is Great language,,,i really like it,,,but some people advised me to learn C for PIC programming..
thanks again
 
phalanx said:
Assembly produces efficient code using lots of man hours.
Providing you're good at it, sloppy asm code is often slower than C.
 
Hero999 said:
Providing you're good at it, sloppy asm code is often slower than C.

Very true. I was only posting best case scenarios.

Some C compilers are pretty efficient too. C30 for the dsPIC being one of them.
 
Yes I agree with alot of the comments made here on this subject. Assembly language does force you to learn the hardware aspect of microcontrollers. Such as registers, timers, stacks I/O ports and so forth. I have used assembly for many different types of projects and found it to be very easy to learn. Then, I moved on to c/c++, which I also enjoy to use. But assembly gave me the foundation on how to program logically and understand what exactly is going on behind the scenes in a micro-controller.
 
Try and learn assembly language, i.e. the language native to the device. Use assembly in small steps so you can understand the nuts and bolts of using the device then move on to higher level languages. This will stand you in good stead when debugging when using a higher level language, and will give you a deeper understanding of what's going on. My preference is for C, basic can be clunky and lead to bad programming practice. Having said that, basic is more like assembly language in terms of code structure so better chance of generating better assembly from basic. In the end there's no substitute for assembly in terms performance and space requirements, and I like to know exactly whats going on down there..!
 
There is no right answer here. A lot depends on the individual. Personally, knowing and using both asm and C is the best end result.

You can understand the structures of a microcontroller with out learning ASM. Except for precise short delays, you can pretty much do everything in C. I've programmed all the features of the midrange in C.

The advantage of C is that much of program house-keeping is done for you. banks, pages, pclath, bit-test-skip-double-inversion jumps, flash rom tables, ... can be error prone for even experienced programmer in asm. Still, the ability to read and understand asm is important as many examples are written in asm.
 
philba said:
You can understand the structures of a microcontroller with out learning ASM.

You can, but a good method of learning it is to learn assembler - it's probably counter productive to try and learn the underlying hardware without also learning assembler.
 
Nigel Goodwin said:
You can, but a good method of learning it is to learn assembler - it's probably counter productive to try and learn the underlying hardware without also learning assembler.

I respectfully diagree with you. there is no one correct answer. You can access all the underlying architecture in C just as easily as in asm. it's a perfectly valid way to go. In some ways, it's more productive for a beginner because they don't have to deal with things like banks, pages, skip flow of control, etc.

Note that I am not saying asm is an incorrect approach. It's perfectly fine, too.
 
philba said:
I respectfully diagree with you. there is no one correct answer. You can access all the underlying architecture in C just as easily as in asm. it's a perfectly valid way to go. In some ways, it's more productive for a beginner because they don't have to deal with things like banks, pages, skip flow of control, etc.

Note that I am not saying asm is an incorrect approach. It's perfectly fine, too.

You appear to be missing the point?, it's not about the language, it's about the underlying hardware - assembler forces you to understand the hardware, C doesn't, and it makes it difficult to program effectively without that knowledge.

Fine, you could study the hardware and understand it from a C point of view, but I would suggest that is more difficult than learning a small amount of assembler in the first place?.

You see some absolutely horrible code written in C and BASIC, simply because the writers don't have a clue about the hardware.
 
Hi all
Are we making a case out of nothing- these are inter complimentary.any one writing a prog has his own comfort or discomfort and many times feels homely with what one knows. Volumes can be written with 'C' by them comfortably as it saves mental fatigue. Let us imagine software written for Various Telecom digital switches with parallel processing depended on 'C' language.

while writing for a microcontroller, if one feels comfortable with what one Knows, let him . Hope we should put stop to this and start delivering effective software.

towards this end the site managers can organise a sort of heathy compitition across a critical pproject. we need not bother aBOUT TIME TAKEN AT THIS STAGE, BUT ONLY TRY JUDGING THE SIMPLICITY AND TIME TO PERFORM THE WANTED FUNCTIONS. EACH PARTICIPENT SHALL HANDOVER THE SOURCE CODE TO THE PANEL AND THE SITE COUL GET THEM EVALUATED BY DISPASSIONATE PANEL.

Let us take it spotive. Incidentally it can also involve hardware and PCB design interested groupswho will first do it and others to write software top work for the end goal.

i have suggested these with no bias as i am neither a software (C<BASIC< PASCAL<ASSEMBLY< FLOWCODE< JAL and what not)or hardware professional and regard all teams as eminent in their fields-
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top