Go Down

Topic: Not TRYING to start a flame war honest. (Read 5796 times) previous topic - next topic

Osgeld

I have made more than enough pascal code in the last 20 something years (keeping in mind I am 33 years old) so when I hear

Quote
remember the simple C way


I automaticly dive into a hissyfit of piss poor documentation that only after I actually do it, does it seem "simple" ... in a C way heh

Disclaimer: I am Ctarded
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL

GoForSmoke

I think I still have the 1985 issue of BYTE where Niklaus Wirth introduced Modula-2. He prefaced with the adage that if you want to write a computer program right, you write it twice and throw the first one away. Pascal was his first. But by 1985 Pascal was so entrenched it just wouldn't die.

It's so restrictive. Kind of like, retch, COBOL.
Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

pluggy

Ah, Pascal, My first real programming language..........  :)

BASIC doesn't cut it as a 'real' language.
http://pluggy.is-a-geek.com/index.html

MichaelMeissner


I Think ^ is not the same as XOR but the rest seems to yeild identical values, but then my maths sucks badly, i use my fingers to count on still lol...

anyway, could someone throw it some real values to check to see what the differences actually are?

In the interests of brevity, I'm not going to quote your code, but it is seriously flawed, since you are using only one variable.  In particular:

Code: [Select]

a = b & b;
a = b | b;


will always equal b, while:

Code: [Select]

a = b ^ b;


will always equal 0.  In fact, xor reg,reg,reg is sometimes used to clear a register.

Now, if you want to see what the logical ops do, you need to do something like:

Code: [Select]

void setup (void)
{
    int i, j;

    Serial.begin (9600);

    for (i = 0; i < 2; i++) {
        for (j = 0; j < 2; j++) {
            Serial.print (i);
            Serial.print ("&");
            Serial.print (j);
            Serial.print (" = ");
            Serial.print (i & j);
            Serial.print (", ");
            Serial.print (i);
            Serial.print ("|");
            Serial.print (j);
            Serial.print (" = ");
            Serial.print (i | j);
            Serial.print (", ");
            Serial.print (i);
            Serial.print ("^");
            Serial.print (j);
            Serial.print (" = ");
            Serial.println (i ^ j);
       }
    }
}

void loop (void)
{
}


And it will print out:

0&0 = 0, 0|0 = 0, 0^0 = 0
0&1 = 0, 0|1 = 1, 0^1 = 1
1&0 = 0, 1|0 = 1, 1^0 = 1
1&1 = 1, 1|1 = 1, 1^1 = 0

GoForSmoke


Ah, Pascal, My first real programming language..........  :)

BASIC doesn't cut it as a 'real' language.


Why?
Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

retrolefty

#20
Aug 16, 2012, 06:39 pm Last Edit: Aug 16, 2012, 06:42 pm by retrolefty Reason: 1
My early experience using Turbo Pascal in the mid 80s, first on Z-80 CP/M systems and then later on IBM PC x86 systems, was my first exposure to a true structured high level language. It was a much better experience then my early exposures to various Basic languages available at the time. So when I finally decided to try and learn C/C++ as used on the arduino, it was not all the hard to understand what was going on and why.

Pascal forced one to understand and obey highly typed variables, where C seems to let you do stupid things if you are careless in mixing variable types in expressions. Scope of variables was also a major difference from Basic. So I'm happy I started with Pascal but glad I get to use C/C++ now on my Arduino projects.


Lefty

GoForSmoke

My idea of not real computer languages are things like RPG, DBase, FoxPro and other similar configurable apps.

Interpreter Basic is clumsy but the compiled Basics have been getting more C-like since the early-mid 90's.

Being able to mix types, LOL, that's a feature!
Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

westfw

I got very disenchanted with Pascal when I realized that it routinely broke the restrictions that it imposed on programmers (consider that WRITE() can have a variable number of arguments, but your own function can't...)

Like BASIC, there are updated versions of Pascal that fix most or all of annoyances.  But it's too late for me!

(OTOH, I have written systems programs for a mainframe in Lisp.  (well, modified, actually.  FLAIR replace the Tops20 file archiver daemon with a MacLisp program that FTPed the files to unix systems (which had much cheaper disks), and they needed it updated for a new version of Tops.))

kg4wsv

If you want a Pascal that isn't broken, it's called Ada.

-j

AWOL

Quote
If you want a Pascal that isn't broken, it's called Ada

Or, in other words, a language where you can't tell if an expression is a function call or an array access.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

wanderson

Everyone should learn to program in hand assembled/compiled assembly language...  Not only is this ultimately what all languages boil down to, but it is invaluable knowledge debugging the problems when that high level language doesn't do what it should...

All high level languages are ultimately garbage, albeit useful garbage...

Actually I am going to amend my statement to; Everyone should learn to program in hand assembled/compiled assembly language on a compulter that they have hand assembled from discrete logic gates.  Bonus points from assembling those gates using tubes or relays...
New true random number library available at: http://code.google.com/p/avr-hardware-random-number-generation/

Current version 1.0.1

AWOL

Quote
All high level languages are ultimately garbage

I've always considered C to be an intermediate-level language (let's face it, it doesn't have many high-level constructs, and was intended to streamline porting low-level processes), so there's a great let-off from the "garbage" label.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

wanderson


Quote
All high level languages are ultimately garbage

I've always considered C to be an intermediate-level language (let's face it, it doesn't have many high-level constructs, and was intended to streamline porting low-level processes), so there's a great let-off from the "garbage" label.


Any language that isn't machine code is high level in the sense that it masks the details.  But some are more high level then others.  C has the virtue of allowing itself to be a little closer (though it doesn't have to be) to the machine code than most other 'high level' languages.

Any language can be used for just about any purpose.  Doesn't mean it is a good fit for a particular problem.  I tend to be of the opinion that markets tend to demonstrate the 'best' languages for a given problem.  Since they tend to account for all of the externalities such as, availability of programmers who understand the problem domain, and the selected language, the cost of time to implement the solution in that language, the costs of maintaining the solution in that language, etc...

So with that understanding it is hard to argue that any language other the C/C++ is better, since the only real competition is 'assembly', which isn't one language at all...
New true random number library available at: http://code.google.com/p/avr-hardware-random-number-generation/

Current version 1.0.1

kf2qd

Here is the problem - we are trying to use many of these "languages" for things for which they were never designed. Each language has its place, and in its place they can be amazing. There are things you can do in CoBOL that eally cut down programming, and are absolutely awesome in and accounting type environment. If you only need reports, RPG is quick and concise(at least in the older forms) The problem has come as some of these languages have been adapted for applications for which they were never designed.

C was originally developed for system level work with operating systems and utilities. It very much shows that it was developed by a small team with a specific application in mind. It has become the do-all - end-all of languages and as such there are some aspects of C that have become a real cludge. Loose typing is actually a nice feature, but it WILL get you in trouble if you fail to pay attention. The "pointer problem" will also bite you in the butt when you are starting out. I use C as most of what I have seen in C++ made even less sense than doing it in C, seemed to be just more levels of obfuscation, but then C programmers seem to think of that as a laudable goal... (Who can do X in the least amount of code...)

I have used Pascal - It is real nice for application writing and does a lot to keep you from getting yourself in trouble. And there are some work arounds that make it work for some systems programming. Haven't used it much in the last 20 years but I can still pick up Pascal code and work with it, even larger applications.

BASIC only has the problem that everyone is taught that BASIC is the problem rather than a lack of instruction in good programming practice. Newer BASICs help by requiring variable declaration and having globals and locals. It is much easier to remember that C (why else do we all have the Arduino Reference in our list of favorites...) as it doesn't use a number of odd symbols that are confusing if you don't use them regularly. I use VB6 to generate all kinds of quick programs to do various things. Lots of tools, easy to use and relatively fast. Even create my own controls when the stock ones don't fit.

I an even slide into assembler when needed, Have done it on the Z80, 68000, VAX and ATMega chips. Tried to do it on the 8088/8086 family and the process was more of a pain than it was worth. Wonder what the PC would have been if it had been built around the 68000 rather than the intel chips. Assembly has its place and often lets you write much smaller code because you don't have all the assumptions made for you like with a compiler.

GoForSmoke

Just keeping up with cpu and system changes shook me off assembly, wonderful though the early experience was.

I also think that interpreters are good for new people to learn from. The lessons are more direct, feedback is fast and no 'mysterious' compiler steps.

Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

Go Up