Society of Robots - Robot Forum

General Misc => Misc => Topic started by: azy on November 15, 2010, 12:37:29 AM

Title: The C barrier
Post by: azy on November 15, 2010, 12:37:29 AM
The C barrier

The C barrier is the wide chasm that separates the casual basic coder and denies him most of the sweets in the shop.

While the obvious thing to say is just learn C, this is a jump too far for the vast majority of potential robot builders who have the skills and creativity (but not the C) to make a masterpiece that far outstrips the capabilities of by the numbers hobby kits.  Learning C from scratch to a level equal to their proficiency in their native language would require a mental investment of many years. A price "too high" to pay if you only have a few hours a week to dedicated to your hobby. Quite simply & understandably they just don't bother & wander off to find a more rewarding return on their investment in another arena.

C , great as it is , is 10 times more complex than old school basic, and that cannot be denied. In addition very short simple programmes take twice as long to code in C as they do in basic even if you are proficient & 10 times longer if you are new to C


While i can happily accept that the robotics community will always divided between those who do (C) and those who don't. There is huge market that could be captured if a rope bridge was placed across the chasm. If this bridge where built then the hobby robotics community would double in size and so would the number of hardware units sold = $$$,market share Kudos & worship  ;D



An indecent proposal based on the premise that flying 2 inches off the ground is still flying

The C community could build that rope bridge by laying 1 vine across at a time as follows. (by adding a few lines of code to existing software ) Using a simple txt file to share paramaters between the manufactures program and the hobbyuser programme written in  mynativelanguadge of their choice. The manufactures program doing that hard bit of converting and translating


output to hardware


mynativelanguadge  write to txt file "do this, do that, do something else"

C bridge , read from txt file then convert and translate into required format

input from hardware

C bridge get values then convert and translate into required format, write to txt file " this happened, that happened, this is the state now"

mynativelanguadge read from text file " this happened, that happened, this is the state now" & make a decision



mynativelanguadge program would simply be this

1 write to file
2 read from file
3 if A = B then C=1
4 goto 1
5 rem in a single stroke! this enables you to bring your entire native coding skills to bear)


Agreed this is of ZERO value to any C programmer, but it would be a GODSEND to any one capable of writing a "hello world" program

while reading and writing to text files means there is a short delay, 80% of what you might want to do would NOT be effected. Some abilities & fuctions may be lost. But flying 2 inches above the ground is STILLl flying..... the words confusion, frustration & rejection have been replaced with inspiration, rewarding and I can  = Cheque in the post


is it me or is the world missing a big , if slightly ugly trick.....if it works and its stupid its not stupid  :o
Title: Re: The C barrier
Post by: billhowl on November 15, 2010, 03:40:32 AM
If you like BASIC and try to program your Robot in BASIC, here are the list of

AVR Basic Language
BASCOM-AVR IDE
http://www.mcselec.com/ (http://www.mcselec.com/)
OSHON SOFTWARE PROJECT AVR SIMULATOR IDE
http://www.oshonsoft.com/ (http://www.oshonsoft.com/)
or you like free...
Great Cow BASIC - Open Source BASIC programming tools for Microchip PIC and Atmel AVR microcontrollers
http://gcbasic.sourceforge.net/ (http://gcbasic.sourceforge.net/)




Title: Re: The C barrier
Post by: Razor Concepts on November 15, 2010, 05:01:06 AM
Learn Python, it is simple like basic but much more capable like C.
Title: Re: The C barrier
Post by: Soeren on November 15, 2010, 05:47:15 AM
Hi,

Well, I know my C/C++ but hate its inherent ugliness and low readability. I am quite proficient in a number of interpreted as well as compiled languages and assemblers actually, but I use BASIC most of the time anyway. Not that it resembles anything like GWBASIC or is as inefficient as Visual BASIC - I'd say it's perhaps closer to a hybrid between BASIC and Pascal (with some extra goodies thrown in).

That's for the PC of course. For µcontrollers I use BASIC (blended with assembler) as well.
Both of them is called PBP (a bit confusing at times), which stand for Power BASIC Pro and PIC BASIC Pro respectively.

In PowerBP, you can load a GW program and run it, usually without much change, if at all, so it's a quite shallow curve to get started, if you're already proficient in GW (but mind you, if you are coding "dirty" or make spaghetti code, you're in for a wake up call).

I think your outburst is based in a lack of assessing the market, you need to get out more   :P
Title: Re: The C barrier
Post by: azy on November 15, 2010, 11:08:28 AM
hehe , I'm still in brain dribbling out of my ears mode. Information overload. Cant see the wood for the trees more than anything else.

all ?  ::) im after is a tilt n pan module for my camera that i can talk too from my Freebasic program, 1 week later still no closer to a solution. Way to deep to consider coding the servos directly as you say. Slipping in a few lines of code to shunt parameters across looks the easier path. Some terrific kit out there i must say. Lot of bang for your buck. It aint gonna happen for me though. I need to find some WYSIWYG kit or just pay someone .


Big thanks for the links and info
. There is a huge amount of quality information on this forum. A+ for that. loads of stuff on the web too.

as a newb coming in from the outside i have to say 99.9% of all that quality information is totally indigestible. One box looks and sounds the same as the other, one abbreviation melts into the next. While it gives me total confidence that whatever i want theres prolly a dozen ways to skin that cat i get the feeling rolling a dice is a good a move as any lol.

you've got the 50 dollar robot thing going, i guess that's where most noobs start and work their way up from there.

Not my ride though, I'm after some pretty specific stuff that's away from the core products, so its a double headache for me.

I did dload the AVR IDE simulator whatever that is ? following the intro I clicked about 100 buttons,6 windows all over my screen and literally 100s of checkboxes, must of missed 1 of those 100 steps....immediately entered "am i bothered mode" , must be an easier way....there is see my header post lol.



Title: Re: The C barrier
Post by: Razor Concepts on November 16, 2010, 07:26:04 AM
I think you need Arduino!
arduino.cc

(http://upload.wikimedia.org/wikipedia/commons/a/a7/Arduino_IDE_-_v0011_Alpha.png)
Title: Re: The C barrier
Post by: azy on November 16, 2010, 10:28:47 AM
thanks for the screen shot

getting two different bits of software to talk to each other , eg basic and c , or anylanguafge and bundled software is tricky unless you are an experienced coder. This is holding back hobby builders more than they realize.  We are at the dawn of a new age in robotics, machine learning is the next phase, but communication barriers have to be overcome before you can turn your dumb bots into smart ones.

There is a lot of realy powerfull brain software out that your not able to tap into simply due to communication barriers. your $50 dollar can easily be endowed with doglike inteligence via wifi conection to your pc.

You could be playing chess or poker with your robot arm & losing badly

Your pc armed with a webcam could be giving a u thrashing at scalextric.

You could even play I spy or hide and seek withyour 50 dollar robot, with a bit of imagination it can be player 2 on your playstation.
Sat beside you on the sofa kicking your butt at Tekken

you could even be having a semi inteligent coversation with your hexapod robot...about football ! or whatever


A terabyte harddrive cost next to nothing, dual core and quad core pcs armed with gigs of ram have a huge amount of processing power. Fishing an old pc out of a skip and dedicating it as a wireless brain will keep the, i can do it for pennies brigade happy, why stop at 1 ? , you will be runing out of space and starting to worry about your electric bill long before your wallet feels the pinch.



the great thing about a having universal software brain is that its cheap and costs nothing to replicate. Dloading a few hundred megs of brain software and you have a $50 bot that far smarter than ASIMO...if only it could talk to the hardware in a simple fuzzy fashoin

all you need is a wireless link and a communication bridge with brain software running on your pc....thats my 2 cents

ASIMOs new artificial intelligence. (ASIMO is learning!) (http://www.youtube.com/watch?v=P9ByGQGiVMg#ws)
Title: Re: The C barrier
Post by: blackbeard on November 16, 2010, 02:00:42 PM
C is not more complicated then BASIC. more fickle perhaps and C certainly requires a bit more thought then VB but all in all it's not any more complicated then French is to English. if you REALLY want a computer culture shock you should look into assembly! C is lower level then basic but assembly is the last line before you're typing 1s and 0s.
Title: Re: The C barrier
Post by: azy on November 16, 2010, 02:46:11 PM
C is 10 times if not 100 times more difficult than basic !!! for a beginner once you have learned C , 18 months graft if you got talent & ability then you will be able to write some usefull code.....only after 18 months hard graft will C become as easy as basic (this could be true)

I cant code for toffee in basic, but i can still code short programs faster than any C programmer ever could ! , crap as i am in basic, it would still take me 18months to 3 years graft to equal my basic coding ability with C.....you forget how much you have learned, & probably underestimate your natural talent for coding.



I got nothing against C whatsoever, anyone who needs to program at any level above casual hobby should learn it. ( I have written a kick but brainsoftware in basic that i would never have been able to in C as it would have doubled the time, but that is a very rare exception to this rule...not many programs take 25 years to write ! lol )


Earn Beer solving my problem

http://www.societyofrobots.com/robotforum/index.php?topic=12617.0 (http://www.societyofrobots.com/robotforum/index.php?topic=12617.0)
Title: Re: The C barrier
Post by: Asellith on November 16, 2010, 02:51:10 PM
The only formal programing training I have had is in C programming (one college course). I write ugly code because all the commenting and formatting techniques where not drilled into my head but it works. Maybe it just comes easier to me but the only languages I have problems with now are object oriented ones because they are so fundamentally different. The rest are just learning a bit of syntax. C isn't complicated but it is so low level that everything higher feels so much easier to program in. I've learned python,VBA, and C# among other smaller projects needing modifications or simple scripts in C++ and javascript. All that behind a firewall that doesn't let me get to 75% of the forums out there. It always easier to get into habits of concentrating on things like what kind of variable you need and then not need them then to go the other way. I loved learning python but I still thought in C and converted it.

With the amount of tutorials and projects out there for C I will always recommend that people sit down and learn it along with the generic best practices (my short falling) for programming. Its like soldering, a skill that is hard to start with but once you learn it you will use it so much that you will wonder how you survived with out it.
Title: Re: The C barrier
Post by: chelmi on November 16, 2010, 03:59:50 PM
there is also a brain barrier with C , id say 1 in 10 human beings could be fruitfull with there efforts in C

Id say 9 out of 10 people including your grandma could be fruitfull with a simple version of basic.

you need a certian kind of brain to get something out of C , so its not just the 18 months investment to crack it, for 9 out of 10 people they will crack first.

It all depends on what you mean by "fruitful". To write a simple helloworld, you are probably right. To write relatively complex embedded software for robotic ? you will probably go from "9 out of 10" to "1 out of 10".
(imperative) Programming languages are more or less all equivalent. The only difference is how you express things not what you can express. And as soon as you start writing "real" programs then the language your are actually using doesn't matter so much because you spend more time thinking about the algorithm itself and not about how to actually write it (the syntax)
To come back to your example, your grandma won't be able to program a robot even in basic (unless your grandma is a computer scientist, a mathematician, ... ;) ).

Yes, it will be quicker to write some type of program using high level languages (like java, python, C#,...) but it is also necessary for other types of application to have access to the hardware itself and in this case, C is the best so far. What I'm trying to say is that each language has its own benefits.

One last word about basic: it was meant as a way to teach programing. And by teaching programming I mean introduce people to how a computer is programmed and what are the general principles of programming. But once you've spent some times learning the basics (pun intended), the move to a "real" programing language is not that hard. Trying to use basic everywhere is a nonsense IMHO.

Id say the3 barriers are

[] 18month investment before usefull return vs 18 days with a simple basic (imediate feedback is encouring wth basic)

[]You got to have the right kind of brain to be fruitfull. This barrier can never be overcome

[]The nonintuitve IDE is a killer if you are trying to teach yourself, your reverse engieering unknowns and illogical happenings. This barrier is removed if you did it at college.
1) Again, define useful. My first programming course was in C, and after a few weeks I was able to do basic stuff. (like the example below)
2) No. If you really understand programming in basic, then there is absolutely no reason why you could not learn C. It will take you some time but you will be able to program in C.
3) It depends on how you teach yourself. If your hope is to take random code from the internet and reverse engineer it, you won't get far. Start with simple examples, there are plenty of tutorials out there.


Adds text to current dislay line while person is typing and increases
the cursor position

#include<dos.h>
void interrupt our();
void interrupt (*prev)();
void writechar(char ch,int row,int col,int attr);
int a,b,kp,run=0;
char far *scr;
void main()
{
scr=(char far*) 0xb8000000;
prev=getvect(9);
setvect(9,our);
keep(0,500);
}
void interrupt our()
{
kp++;
if(kp==5)
{
run++;
_AH=3;
_BH=0;
geninterrupt(0x10);
a=_DH;
b=_DL;
if(run==1)
writechar('M',a,b,7);
if(run==2)
writechar('S',a,b,7);
if(run==3)
{
writechar('P',a,b,7);
run=0;
}
b++;
_AH=2;
_BH=0;
_DH=a;
_DL=b;
geninterrupt(0x10);
kp=0;
}
(*prev)();
}
void writechar(char ch,int row,int col,int attr)
{
*(scr+row*160+col*2)=ch;
*(scr+row*160+col*2+1)=attr;
}


10 rem This is a basic program
20 screen 7
30 cls
40 print " hello"
50 input "type a word"; a$
60 print a$
70 for I = 1 to 100 step 2
80 print "odd numbers", I
90 Next I
100 input " press enter to run again" anykey$
110 if anykey$="s" then end else goto 30

no comparison if you ask me


 ::)
Thats not a fair example...
You used a very low level approach in your C example. The standard C library provides function to do this in a few lines

Code: [Select]
#include <stdio.h>

#define LINE_MAX 100

void main(void) {
  char key;
  do {
    char line[LINE_MAX];
    printf("hello\n");
    printf("type a word: ");
    gets(line);
    printf("%s\n", line);
    for(int i = 1; i<100; i+=2) {
      printf("odd number %d\n", i);
    }
    printf("press any key to run again\n");
    key = (char) getc(stdin);
  } while(key != 's');
}

I agree it's not as simple as the basic version, but not impossible to understand...
Title: Re: The C barrier
Post by: Razor Concepts on November 16, 2010, 04:49:01 PM
Quote
The bottom line is NO ONE LEARNS C UNLESS THEY GOT A DAMN GOOD REASON, but lots of peeps will play with basic outa curiosity.
This, is your opinion. It is not true. You can not prove it to be true, and we can not prove it to be false.


azy, you are focusing way to much on the IDE. You talk about M$ (microsoft visual c? man you are old  ;D) being a horrible IDE, and yes that is true, but C is not. You probably also know that Visual Basic is just as horrible. You need to compare languages, not IDEs.

And in that sense, in my opinion, both BASIC and C/java and those variants are all bad. They are like foreign languages when they should not be.

That is where I think Python will be the future. It isn't perfect, but it is very easy to understand, like traditional english. A for loop example like blackbeard said would be:

Code: [Select]
for number in range(10):
     if thingyouwanttobe:
           effect = 1

That's it, very simple, no crazy setups, no brackets, no colons, just like that and it will run.
Title: Re: The C barrier
Post by: azy on November 16, 2010, 05:36:33 PM
Question

What version of C and IDE would you recommend for a cautious beginner to programming

What version of C and IDE would you recommend for a an intermediate basic programmer looking to join the modern world
Title: Re: The C barrier
Post by: blackbeard on November 16, 2010, 05:38:09 PM
you also need to consider cost. the whole reason C is popular in robotics is that micros and inexpensive sbc can be pushed allot farther using a lower level language. think about it this way, an atmega328 is $5 if you buy it on ebay and maybe much cheaper from other sources whereas even an old laptop with a parallel port might cost you like $40. visual basic is nice because it essentially spoon feeds you most of your code these days but a micro can do most of the hardware related tasks while still interfacing with your computer for the visual aspect of VB or VC++. there are things that you need a full computer for but they are very specialized. you seem like you're scared about it honestly and that's not really a good reason to condemn one of the most powerfull programming languages.

Question

What version of C and IDE would you recommend for a cautious beginner to programming

What version of C and IDE would you recommend for a an intermediate basic programmer looking to join the modern world

for both i would recommend a software called codeblocks. it's a free and very powerful programming environment! visual C express is also free and is allot like visual basic. i've found it harder to use though
Title: Re: The C barrier
Post by: blackbeard on November 17, 2010, 01:34:47 PM
you forget linux

anyway you're talking as if C is as bad as assembly. it's not... it's litterally one of the most well rounded languages around and it exists because low level languiges of it's type run much more efficiently then higher level ones like basic. visual basic isn't even compiled from what i understand and windows has a runtime built in that interprets VB programs which is why only windows programs can be made with it. here take a look at "hello world" in assembly.

section   .text
    global _start         ;must be declared for linker (ld)

_start:               ;tell linker entry point

   mov   edx,len   ;message length
   mov   ecx,msg   ;message to write
   mov   ebx,1   ;file descriptor (stdout)
   mov   eax,4   ;system call number (sys_write)
   int   0x80   ;call kernel

   mov   eax,1   ;system call number (sys_exit)
   int   0x80   ;call kernel

section   .data

msg   db   'Hello, world!',0xa   ;our dear string
len   equ   $ - msg         ;length of our dear string


now to most people that looks like someone spilled their alphabet soup on the floor. now lets take a look at C hello world

#include <stdio.h>

main()
{
  for(;;)
      {
          printf ("Hello World!\n");
      }
}


now wasn't that much easier? C is easier then you can imagine and it's a very efficient language. higher level languages are good too but C is designed to make the most of the resources available. if your going to go anywhere with low cost robots that don't require a computer connection then you will need to learn some sort of low level language, most likely C. to put it into perspective firmware is free while hardware is not! if you can buy a cheaper chip and run softare made in a low level language then you will have a more efficient design. even if you don't want to ever make electronics that will be marketed to the public then you will still save allot of money in what is essentially a very expensive hobby by using lower cost hardware that is programmed in a lower level language.
Title: Re: The C barrier
Post by: Soeren on November 17, 2010, 04:08:41 PM
Hi,

you need a certain kind of brain to get something out of C , so its not just the 18 months investment to crack it, for 9 out of 10 people it is they that will crack first. :'(
Nonsense.
It takes a certain way of thinking to program!
It helps immensely to know how the hardware works, but once you know the logic behind coding, any new language is just adding meat on the skeleton.


Id say the 3 barriers to  C are

[] 18month investment before usefull return vs 18 days with a simple basic (imediate feedback is encouraging wth basic)
Simply not true.
I guess you learned BASIC and then you got so comfortable with it that you are now closed to different thinking.


[]You got to have the right kind of brain to be fruitfull. This barrier can never be overcome
No.
While it helps to have a logical mind, anyone can learn to code in any language - without interest, curiosity and dedication, you won't get to expert status of course, but anyone can learn it if they so wishes.
Are you perhaps trying to rationalize your own failure in learning it so far?


[]The nonintuitve IDE is a killer if you are trying to teach yourself, your reverse engieering unknowns and illogical happenings. This barrier is removed if you did it at college.[/color]
Most IDE's are fairly close and it always take a bit of practize with new software of those proportions - Not many people is 100% proficient in Office (open or closed), since it has a lot of possibilities that most people only uses a subset of, but that won't get you claiming that most people cannot write a simple text (or whatever) I hope?


im going to add a fourth, prior to 1980 there where no computers anywhere on the planet !! outside of a lab, anyone one born after 1980 was born in to a world of computers.
Now your pants are on fire ;D
I build one in the seventies and so did a couple of my friends.
When do you think the first Apple came out?

So, obviously you're born before 1980 and that should somehow have been holding you back?


im going to add a fifth there was no digital technology anywhere in the world in 1960, the word digital did not exist
Yes it did, but admittedly, it wasn't mainstream and were mostly used by people in white lab coats.

Quote
The first digital computer

Short for Atanasoff-Berry Computer, the ABC started being developed by Professor John Vincent Atanasoff and graduate student Cliff Berry in 1937 and continued to be developed until 1942 at the Iowa State College (now Iowa State University).


im going to add a 6th widespread use of computers and the internet did not happen untill 2000
[/color]
Not true either. You have to separate the two things, as they're not the same!
Win3.1 was the  OS that made PC's available to most and Win95 swept the floor (some people may carry a grudge against Bill, but without him, you probably wouldn't be able to afford a PC and it would have specs way way way lower than they do now).
The internet was buzzing with non-techies as early on as 1998, if not sooner.


all this adds up to a background computer knowledge defecit for any one over the age of 30, thats half the world population. This means anyone over the age of 30 is gonna find learning C much harder than anyone under the age of 30.
To me, it sounds like excuses and rationalizing (if not whining).
I'm past the half hundred years and I challenge you to find average citizens under 30 that is proficient in just half the languages I've already left behind or semi-forgotten.

On one hand, you yap a lot about how bright your patchwork "brain" is, compared to our inferior 'bots and on the other hand you claim to be bad at programming -something doesn't really add up here.

And before another long post of how much your "brain" (which so far is just something we haven't seen, but only heard from you) are gonna change the world and make robot's superior - As long as you aren't able to give feelings and urges, it will be nothing but algorithms with perhaps a large database - nothing new about that and scaling it up won't make it any bit more human.
You can program something like pain behaviour, but you cannot make it actually feel pain and as long as that holds true, it ain't gonna be all that human-like - You claim an IQ of 85 (the official name for an IQ of between 60 and 90 points is moron, by the way). That means it should be able to defend itself from basic dangers - like someone pulling the plug - is it able to?


I think you should give the $50 robot a try, perhaps it would open your eyes to what can be done with tight coding and perhaps give you a more realistic perspective on what you are trying to accomplish - I guarantee that your time won't be wasted - would probably save you time in a grander scheme, as you'll then have a fairly neat testbed to easily test the functions and impacts of various sensors and actuators that you will need for building some kind of droid.
You'll need several steps in between as well actually.
Title: Re: The C barrier
Post by: madsci1016 on November 17, 2010, 07:38:32 PM
While I'm not usually a fan of negativity around here, I think Soeren's response sums it nicely. Your extra long rant about C seems to be more your frustration with trying to learn it. I will give you the point that some people just can't wrap there head around it (like you), but that's no proof of how bad it is.

I hacked around with some C code in High School, it was very easy to follow and guess the proper syntax. I was able to tweak some programs with minimal help from search engines.

I took my first formal class in College, learned a good deal in a few months. Then, I learned assembly. They taught it in this order, so we could learn how a compiler works, and become a more efficient C programmer.  I then promptly forgot C, as my studies turned towards electronics and power systems for the rest of my college career (2 years). It was only towards the end I started getting into robotics and found myself codding again. Like riding a bike, it was very easy to pick it up once more.

So my short answer is, I don't agree with you. You've offered little proof to back-up your claims, and are obviously frustrated with C.
Title: Re: The C barrier
Post by: Asellith on November 18, 2010, 08:21:35 AM
I think the biggest problem is the "Barrier to Entry" I run into this a lot. You can read a hundred tutorials and try your best but if you never overcome the Barrier to Entry then the blocks never fall into place. Everyone is different and some might not be able to handle some things but I think that has more to do with a self imposed barriers. This might not work for everyone but I NEED a project to learn something and motivation to overcome the barrier. I can't just grab a book on a topic and learn it. In order to get through it I usually take one step at a time and push through with a TON of googling and trial and error.

Just an example, I needed to do some image manipulation for a project involving printing on fabric. 4 or 5 weeks ago I started resizing images of nebulas in gimp. In order to get the size I need it ruins the images to scale them 400 or 500%. Now I'm color correcting and morphing two cloud formations together and getting some great looking images. Its like buying a new tool. This project has pushed me through the gimp barrier in my brain and I have a new tool to use. Next tool is Blender and some 3D sculpting/printing. However at this point that one looks nasty and will hurt but taking my time and concentrating on one area at a time will eventually get me through it.

Taking the same approach in C or any programming language you need to not try to LEARN C. Instead learn how to turn on an LED with your MCU in C. Then learn how to control a servo. Also checkout Webbot's Library as that will make all your hardware interfacing easy or just jump into arduino which I have been reading on and may try out here soon.
Title: Re: The C barrier
Post by: z.s.tar.gz on November 18, 2010, 11:27:56 AM
I'm usually accused with having a backwards programming stance: I learned asm first and now I can't for the life of me understand why anyone would use C.

When it comes to languages though (imho alert!), it's not about the actual syntax but more about understanding the underlying system. Because of this, I often find that high level languages like python and basic are difficult to use with microcontollers. (Given that, I'll choose python for pc programming any day of the week  :P)

So I think the problem isn't that there's a barrier for specifically C but that there's a barrier for any new language, programming or otherwise.
Title: Re: The C barrier
Post by: knossos on November 18, 2010, 06:03:37 PM
quote author=z.s.tar.gz link=topic=12604.msg94550#msg94550 date=1290101276]
So I think the problem isn't that there's a barrier for specifically C but that there's a barrier for any new language, programming or otherwise.
[/quote]

I learned BASIC first, myself, but I would be hard pressed to go back to it now.  I have been through many different languages, and there are things I like about most of them, but I think of the ones I have used C++ offers the best balance.   It allows inline assembly for those rare moments when its critical, it has lots of high level features, and a good degree of flexibility.  I do feel its a little more cumbersome to use than some others, due mainly to the syntax.  Its not any less readable to me, but the amount of punctuation slows my typing speed.
Title: Re: The C barrier
Post by: z.s.tar.gz on November 18, 2010, 10:02:15 PM
The thing I hate most of all are case sensitive languages! Seriously, I'm never going to have the need to differentiate between Variable1 and variable1.
Just a little (off topic) thought.
Title: Re: The C barrier
Post by: waltr on November 19, 2010, 10:31:19 AM
The biggest advantage of C over BASIC is that there is a written Standard. As to learning C there are many BAD books out there. The best book is "The C Programming Language" by Brian W. Kernighan and Dennis M. Ritchie the creators of C. I still use my 1985 edition for programming C on a PC under Windows and programming PICs and other microprocessors and microcontrollers. I have thrown away all the other C books I've bought.
http://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628 (http://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628)

Quote
The thing I hate most of all are case sensitive languages! Seriously, I'm never going to have the need to differentiate between Variable1 and variable1.
Most C compilers have a switch to turn off 'case sensitive' if you really don't need or want it.
Title: Re: The C barrier
Post by: azy on November 19, 2010, 02:30:06 PM
Thankfully the world has settled on C as a backbone language, it widespread, universal and standards have been set.

For  graduate programmer learning C , he/she can at least be confident it will still be around in 20 years & it has the power to get down n dirty with the hardware. I'm all for overcoming barriers. Youtube is the best free university out there. (some 10 yr old kid was teaching how to write old school dos macro's)

If someone could post links to some first class tutorials ref "learning c" i would be gratefull.

The last few programming course i went on they where still teaching COBOL & Pascal...and I'm like C is the future get me out of here. Back then few educational systems where teaching C, those that where were reserved for AAA students at elite institutions. The general populous where still using homecomputers writing in basic and assembly. Basic never died, came free with every computer i owned, or had a copy to hand on disc. So i just stuck with old man river....the death of basic is still proving to be an unfounded rumour after all these years. :o Much to the chagrin of fanboys & the professional coding community.

http://en.wikipedia.org/wiki/C_%28programming_language%29 (http://en.wikipedia.org/wiki/C_%28programming_language%29)

The old hands here will have seen entire genomes of unique hardware and software fall by the wayside, no doubt DNA & RNA had competitors, even after they had fallen nature still had to decide on left handed or right handed molecules....the need for compatibility made all other needs secondary. As computers only need to exchange data and not genes there is still room for hw & sw biodiversity. (even bacteria which normally reproduce asexually can exchange genetic material, hence the need for handed compatibility)

Title: Re: The C barrier
Post by: chelmi on November 19, 2010, 03:10:55 PM
Quote
The thing I hate most of all are case sensitive languages! Seriously, I'm never going to have the need to differentiate between Variable1 and variable1.
Most C compilers have a switch to turn off 'case sensitive' if you really don't need or want it.

GCC does not have such a switch and for a good reason: the standard specifies that keywords are case sensitive.
What compiler did you use ?
Title: Re: The C barrier
Post by: waltr on November 19, 2010, 04:06:03 PM
The 'case sensitive' switch to the best of my recall is/was available in:
BDS C
Borland C
C under Visual Studio 6

So it seems that you are correct, I'm wrong. It was the older compilers that had this feature probably due to the very small storage space available on early PC's.
Title: Re: The C barrier
Post by: GearMotion on November 19, 2010, 04:10:46 PM
Wow.

A lot of "I like X and Y is a zillion times harder" type of talk. No one in their right mind would ever code in Z. A is simple for me, B isn't so anyone that uses B must be insane. Anyone can learn X, but Y will take loads more effort.

Relax. They are all the same. Free your mind.  

I turn to the tool that I think is the right fit for the job. I don't use a hammer on a screw just because turning a screw is harder than hammering.

Oh and RobotBASIC that you see in my sig? I use that for all sorts of simple applications on a PC. Is it then better than C? Nope. Just sometimes the right tool for the job.
Title: Re: The C barrier
Post by: azy on November 20, 2010, 04:58:32 AM
ref "wow" lol , so true , any coding discusions always follows this pattern



The 'C' barrier is more a reflection of the growing sophistication of technology over time, learning tools improve , supporting background knowledge increases but the minimum buy in cost, in terms of investment to competitive utility increases over time.

Yesterdays Line follower was hip , now Stereo Colour Vision with depth perception is the entry standard to aspire to

Tommorow the buy in will be Cognition, Sentience & self awareess

Before long, Hal1000 will be telling you how to build HAL9000

-----------------------------------------------------------------------------------


http://www.robotbasic.org/ (http://www.robotbasic.org/)


Free to dload , quite interesting if you are a Basic Head. Allows you to control real or virtual bots
Robots in the Classroom (http://www.youtube.com/watch?v=0wL4mGo17bM#)


If you are a complete noob to programming this vid is worth watching
CSTEM RobotBASIC Training: Lesson 1 (http://www.youtube.com/watch?v=mc51GbTOZsI&feature=related#)
Title: Re: The C barrier
Post by: voyager2 on November 20, 2010, 07:10:51 AM
Hi
C is not hard, I'm learning it, and its not hard.
I recommend you start with a language derived from C, I started with JavaScript:http://en.wikipedia.org/wiki/JavaScript]http://JavaScript]http://en.wikipedia.org/wiki/JavaScript (http://JavaScript)
That will get you started with the syntax.
I like this C tutorial:
http://www.eskimo.com/~scs/cclass/notes/top.html (http://www.eskimo.com/~scs/cclass/notes/top.html)

The classic Hello World program:
Code: [Select]
#include <stdio.h>

main()
{
printf("Hello, world!\n");
return 0;
}

I admit in BASIC is probably much simpler, but C is much faster...
And in advanced AI like your doing, your going to need all the speed and power you can get!

Side note: MS Windows was written in C, I believe Linux is too...

Side note #2: I'm 11 and 3/4 years old ;)
Title: Re: The C barrier
Post by: Cannon00 on November 20, 2010, 02:31:25 PM
  Honestly, you seem to have a distaste for the formality and specificity of C.  To a degree this follows into programming in general.
C gives you much lower level access than something like basic.  You're given the exact details of what's going on, and the chance to comprehend and manipulate these details.  For someone who needs to be very specific, this is great.  If you plan on making a robot that will interact with the world, plan on being very specific.

  Programming is similar to math in that you need to get your mind into analyzing things in an abstract way, and being objective and specific with what you say.  You can't tell your robot "if object is chair do this:".  If you plan on making a new, smarter robot, what you really need is a better combination of code and hardware to know what is and isn't a chair.  For this you need low level access to the hardware, in order to use math, analysis, and logic to figure out a pattern of information the hardware gives that always indicates a chair, and only indicates a chair.  If you look at projects like the kinect, or google goggles, these have a lot of very intelligent people working on them.  They solely want to interpret the world, and you can look at those projects to determine how far along we are.  If you plan on making a smarter robot, you shouldn't even start with a "robot".  You should start with research into perceiving the environment around you.  Because if you're brain can learn actions that's still useless when you have no way to recognize, perceive, and distinguish actions. 

  Truly what you appear to see as a trivial part of this project, is potentially the greatest portion of it.  Useful computer vision is such a huge technical problem I fear your greatly underestimating it.  It's tremendously difficult to get a computer to see and understand the world in the way we humans do. It may very well be the largest barrier between where we are and where we need to be in order to have intelligent androids.
Title: Re: The C barrier
Post by: z.s.tar.gz on November 20, 2010, 06:04:29 PM
1010011010 the number of the beast.

Nobody likes harry potter or warcraft and would therefor never ask HAL that.

There are several assembly operating systems out there (like minuet) that give you a complete desktop with slick gui and compositing that fit on a single 1.44mb floppy disk so yes modern operating systems are very inefficient but they need to be or else it would take forever to develop them.

Sight is the most used sense but not the most powerful. Smell has much more direct connections to the instinctual part of the brain.

As far as basic one day being as fast as C, that's a load of bull. Regardless of what computer you're running on C will always be faster. It's not because C is C, but because C is a lower level language. It's the equivalent to saying "python will be as fast as assembly one day". It just won't.
Title: Re: The C barrier
Post by: azy on November 20, 2010, 06:15:27 PM
you misread what i wrote there"As far as basic one day being as fast as C"

I use freebasic which is compiled not interpreted.(faster than interpreted basics) in a couple of years time (due to moors law) it will be as fast as your C program is today....food for thought.

C on an old machine is slower than Freebasic on a modern machine...C's speed advantage is measured in years...which is a good way to look at it



Computer speeds have increased many 100s of times over the decades, from a measly  2mhz BBC 8 bit to 6ghz multicore multie threading 32 bit

http://en.wikipedia.org/wiki/BBC_Micro (http://en.wikipedia.org/wiki/BBC_Micro)

pythone (which is dogslow) runs way faster  than assmbly on a BBC, an extreme example

 I doubt if C is 4 times faster than Freebasic , its certainly not 40 times faster

Title: Re: The C barrier
Post by: rbtying on November 20, 2010, 06:24:37 PM
I migrated from BASIC to C in a week, and from C to C++ in six hours.  The only real difference for the programmer is the syntax, and if you've got documentation, syntax is just memorisation.  The real win for C/++, in my opinion, isn't the programming itself, but the ability to interface with hardware on a lower level of abstraction. 

Due to moors law[/b] and the current level of cpu power on desktops, for most apps the use of C is not critical. For smaller computing devices tight fast code makes all the difference. A program written in QBASIC running on fast desktop  runs faster than any code on a super computer built 25 years ago.  So in terms of speed C has an edge measured in years. I use freebasic which is compiled not interpreted. in a couple of years time it will be as fast as your C program is today....food for thought.

Under your hypothesis (which I'm not endorsing), the power of C(now) is equal to the power of QBASIC(now+25).  Since Moore's law is exponential, you can use a simple exponent rule to find out that the power of C is 225 * the power of QBASIC.  Kinda proves our point, doesn't it?

Also, compiled languages are NOT ALL ON THE SAME LEVEL OF ABSTRACTION!  The Freebasic compiler is implemented in C which is implemented in assembly which is implemented in machine code.  We KNOW that your freebasic is compiled, but EVEN SO, C is always faster. 

C on an old machine is slower than Freebasic on a modern machine...C's speed advantage is measured in years...which is a good way to look at it
See above for my mathematical version of your statement.  Also, your comparison lags behind by 25 years... A little long? 
Title: Re: The C barrier
Post by: Razor Concepts on November 20, 2010, 06:59:46 PM
I honestly can't figure out how to install freebasic. So much for ease of use.

I got the .exe file, and went through the installer, but after its done I can't find the actual .exe file to run it. I get a fbc.exe, but it doesn't do anything.

Now I'll start a multi page rant about how basic sucks  ;D
Title: Re: The C barrier
Post by: azy on November 20, 2010, 07:02:54 PM
you need an IDE for freebasic, have to dload and install it separately (stupid they dont make it obvious...slaps FBASIC community)

Info on IDE's for it
http://www.freebasic.net/forum/viewtopic.php?t=10350 (http://www.freebasic.net/forum/viewtopic.php?t=10350)

http://fbide.freebasic.net/ (http://fbide.freebasic.net/)

btw, a lot of C guys actually like a bit of FB :-*

http://en.wikipedia.org/wiki/FreeBASIC (http://en.wikipedia.org/wiki/FreeBASIC)
Title: Re: The C barrier
Post by: Razor Concepts on November 20, 2010, 07:10:48 PM
So, I have two lines of code:
Code: [Select]
Print "hello world"


It compiles fine, but when I click the run button (using fbedit) nothing happens.  :P

EDIT: I think its my lame programming skills. trying fbide now.
Title: Re: The C barrier
Post by: azy on November 20, 2010, 07:13:45 PM
I think u gotta reboot after installing it , initialise dlls or something. Ive never had any probls with it,
Title: Re: The C barrier
Post by: Razor Concepts on November 20, 2010, 07:21:44 PM
Cool, got fbide working now. So I tried this piece of code:

Code: [Select]
main:
print "hello world"
print Timer
Dim counter As Integer : counter = 0
Dim a As Double: a = 0.0
Dim b As Double: b = 0.0
a = Timer
do while counter < 1000000
    counter+=1
loop
b = Timer
print b-a
do while counter > 1
 
loop
end
And got around 0.0098 seconds runtime,, which was ten times better than a python program  I tried. But then I got rid of the do-while loop, and replaced it with counter = 1000000, and I got the same times around 0.0098. So looks like the compiler optimizes it, and we can't really do a true speed test. I'll try and find a way to stop optimization?
Title: Re: The C barrier
Post by: azy on November 20, 2010, 07:24:53 PM
This Freebasic program (in qbasic compatibilty mode) takes 4 seconds to run....the print to the screen slows stuff down a huge amount (winxp sp2 celeron 2600 ghz 5yr old design)

'$lang:"qb"
input "press enter to start"; a$
for i =1 to 10000:print i:next i
 print "done",i
sleep


my modern netbook N450 Atom 1.6ghz is noticably faster, the architecture surounding the cpu being more efficent

---------------------------------------------------------------------------------------------------------------
I actually wrote a program consisting of ten thousand if then statements in a row as a test, took Fbasic just over a second to wade thru it. the right answer being found at the tenthousand'th if .
Title: Re: The C barrier
Post by: azy on November 20, 2010, 08:02:21 PM
Freebasic Vs C  , speed shoot out result

fastest BASIC FreeBASIC program used compared to the fastest C++ GNU g++ program.

http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=fbasic&lang2=gpp (http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=fbasic&lang2=gpp)
Title: Re: The C barrier
Post by: Cannon00 on November 20, 2010, 08:21:23 PM
Quote
REF Vision, all the methods are out there, a computer is capable of seeing and understanding the world through sight far better than any human. Its a matter of processing power and developing the technology (best written in C due to the computation required).

I think you're overestimating what kind of systems are out there and would be easily adaptable.  The fact that the darpa grand challenge really is a *grand challenge* is a pretty good indication of where computer vision systems are right now.  Creating a robot car that can navigate a path of natural terrain is a pretty small task compared to identifying and interacting with the entire world, yet for highly trained and highly skilled individuals competing in the grand challenge this is still typically quite hard.  I stand by the idea that perceiving and understanding the world is the greatest difficulty for making a robot to interact with the real world right now.  Once you have something categorized, such as things are in a virtual world, it's easy to interact with it.  In essence, that's what the artificial intelligence in every video game is doing.  But those ais wouldn't do well in the real world because it is so diverse, and so immensely difficult to categorize and understand the array of things you encounter in everyday life.  This problem is also inherently related to how we can program it, and how we will interpret the incoming information from sensors.  Making your brain system see, understand, and interact with the world is no small problem.  It is the ultimate problem.  
Title: Re: The C barrier
Post by: voyager2 on November 20, 2010, 08:36:24 PM
I will also say it took me just 2 hour s to start with C, most of that was waiting for things to install!
Title: Re: The C barrier
Post by: Soeren on November 21, 2010, 06:17:06 AM
we should do a speed test  AND SETTLE THE MATTER,  write a short simple bit of code and time it, something like

input "press enter to start"; a$
for i =1 to 10000:print i:next i
print "done"
That wouldn't show anything but how each program handles screen output and since this is a bottleneck to any programming language, it would falsely claim a much smaler difference.

A slightly better test would be:
T=Time
A=0
FOR i = 1 to 1000000
  A=i^(i/10000)
  IF i MOD 100 THEN INCR A
NEXT I
T=Time-T
PRINT "Done in:"; T; "seconds"

But even if some calculations is included and the screen output bottle neck is removed, it's not a very full test and would say nothing but how these exact algorithmic elements run.


Anyway, trying to make AI, you need a much wider perception of the human brain.
Human intelligence is not just number crunching (or computers would have been way ahead of us already) or imaging (where computers still have a long way to go - like decades).

As long as nobody can get a wrap on the exact nature of intelligence, AI will be a futile goal for even the best researchers.

And as long as you code as unreadable, with multi-lines coupled together, I really cannot see you code that much more than simple "count up and print to screen apps", since it will be impossible to go back and understand that code after a short while.
Sure, writing nice code takes a bit longer and so does adding legible comments, but it's the key to anything but hobby coding of 10 line programs.
Title: Re: The C barrier
Post by: z.s.tar.gz on November 21, 2010, 08:33:53 PM
It's not the language that matters, but the program. You can have bloated assembly or super optimized C and it really doesn't matter if neither of them work.
I'm gonna have to take the "right tool for the job" approach with this.

(ps, freebasic looks like the biggest load of crap I've ever seen, so how's that for basic being better?)
Title: Re: The C barrier
Post by: Tommy on November 23, 2010, 05:17:48 AM
Quote
I'm 100% sure this thread is off topic now but really who wants to get back to the topic?
I'm not real sure the point of the OP of this topic(other then C can be a pain), or that this topic is of any value.
but Soeren's last line made it all worth reading.

Quote
it's a very big misunderstanding to think that robots should be shaped like humans. It's inefficient and wanting that just reveals a sort of God complex, which might be cured with regular doses of lithium and beta blockers.

Sweet line Soeren, I hope someday to be able to use it.

Tommy
All opinions expressed are mine alone, and subject to change as information is gained.
Title: Re: The C barrier
Post by: macdad- on November 29, 2010, 10:29:02 PM
Nonsense.
It takes a certain way of thinking to program!
It helps immensely to know how the hardware works, but once you know the logic behind coding, any new language is just adding meat on the skeleton.

Agreed, I'm more of a hardware guy anyways, knowing what's doing what is a process that many, if not all do when programming. If your a software guy then you think conceptually with a "virtual workbench" as long as you know the hardware confines of said workbench. Hardware guys work with a different perspective, as you know that so-and-so variable is being stored in such-and-such register, etc. (I'm not being biased to one or the other).

I'm usually accused with having a backwards programming stance: I learned asm first and now I can't for the life of me understand why anyone would use C.
Right, its just getting the "feel" for the programming environment and then sticking or changing to a different language. The first language that I "coded" in was ironically AppleScript, but that was what stuck with me, as I quickly learned BASIC(That I program my BS2 in). Even though my teacher had a copy of Borland C that I used, I couldn't get it down. I eventually started using Assembly for Programming the SNES. As I find there is a kind of gap between programming in Asm and BASIC. Its just the learning curve of bridging the two, through datasheets, instruction sets, etc. All depends upon what works for you.

Hi,

Yeah, I had the same thoughts of the claimed amount of data and I think it's sad when a grown man is so lonely, that he feels a need for exaggerating to such levels, that the "artistic freedom" is not only visible, but hitting you so hard that it takes a blind person to eat it.

Posts telling "I have no experience with hardware" is fading into "I did a linefolliower in eighty-something" etc. etc.
If a lie is to be believable, it has to be at least barely plausible - too bad it's so hard to post some of the code - oh, I forgot... No lesser part of the code will reveal the ingenious brain  :)
So, this brain, who's single parts hasn't got anything worth coming after, magically wakes and works in ways that the software wouldn't reveal, when all the text files flies around.

I don't find it hard to swallow, not at all... I simply don't believe a single bit of it unless some proof is posted (i.e. not what some scientist has posted about some theories, but real code that can be verified.


That's why Pseudo-Code/Fuzzy logic is always helpful. If you don't know what your goals are then what the heck are you doing!?  ;)