Pages: 1 [2] 3 4 5   Go Down
Author Topic: Not TRYING to start a flame war honest.  (Read 4990 times)
0 Members and 1 Guest are viewing this topic.
SE USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 3783
@ssh0le
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 98
Posts: 4807
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Lancashire, UK
Offline Offline
Edison Member
*
Karma: 9
Posts: 1991
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ah, Pascal, My first real programming language..........  smiley

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


Ayer, Massachusetts, USA
Offline Offline
Edison Member
*
Karma: 54
Posts: 1848
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
a = b & b;
a = b | b;

will always equal b, while:

Code:
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:
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
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 98
Posts: 4807
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ah, Pascal, My first real programming language..........  smiley

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

Why?
Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17294
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: August 16, 2012, 11:42:15 am by retrolefty » Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 98
Posts: 4807
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 133
Posts: 6756
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.))
Logged

0
Offline Offline
Faraday Member
**
Karma: 8
Posts: 2526
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

-j
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26313
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

Dallas, Texas
Offline Offline
God Member
*****
Karma: 31
Posts: 887
Old, decrepit curmugeon
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

New true random number library available at: http://code.google.com/p/avr-hardware-random-number-generation/

Current version 1.0.1

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26313
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

Dallas, Texas
Offline Offline
God Member
*****
Karma: 31
Posts: 887
Old, decrepit curmugeon
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

New true random number library available at: http://code.google.com/p/avr-hardware-random-number-generation/

Current version 1.0.1

South Texas
Offline Offline
Edison Member
*
Karma: 8
Posts: 1025
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 98
Posts: 4807
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Pages: 1 [2] 3 4 5   Go Up
Jump to: