Pages: 1 2 3 [4] 5 6   Go Down
Author Topic: Programming in C  (Read 3303 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
God Member
*****
Karma: 21
Posts: 650
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

"bool" works... I use it all the time.

Yes, so do I. Why would you even want to use "boolean"?

But try "boolean" (which is the "standard" in "Arduino Language") on a C/C++ compiler and see what it thinks of it! (Probably much the same as what I think of it, actually.)

And why is "boolean" supposed to be any easier for a beginner than "bool" anyway? It's introducing difference for the sake of difference! Madness.

« Last Edit: November 23, 2012, 10:55:54 am by pico » Logged

WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

Offline Offline
God Member
*****
Karma: 21
Posts: 650
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I would add, however, that K&R is probably beyond the comprehension of most C programmers and 99.99% of the arduino community. Without years or programming, making mistakes and tracking down those nasty bugs, it is not possible to appreciate it fully.

I must disagree. I think the book is clear and simply written so that it is very suited to the novice C programmer. It was the first book I bought for learning C, and now of course it is used as a reference.

If I knew of a better book to get into C programming, I'd recommend it. I don't, however.

Logged

WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 331
Posts: 16499
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

"bool" works... I use it all the time.

Yes, so do I. Why would you even want to use "boolean"?

But try "boolean" (which is the "standard" in "Arduino Language") on a C/C++ compiler and see what it thinks of it! (Probably much the same as what I think of it, actually.)

And why is "boolean" supposed to be any easier for a beginner than "bool" anyway? It's introducing difference for the sake of difference! Madness.



 So what is your purpose for all your 'arguments'? That the arduino developers should see the sins of their way and redo the platform to attain C/C++ purity? Or is to make sure that beginners be made aware that they are not choosing to take the true path towards C/C++ priesthood by using the arduino IDE? Or that anyone that tells arduino beginners that the arduino platform is using C/C++ as it's programming language are leading them down a destructive path similar to what a crack dealer might do or say? Or is this all about nerds just discussing nerd topic to each other, which I really do enjoy by the way.  smiley-wink

Lefty  
Logged

Offline Offline
God Member
*****
Karma: 21
Posts: 650
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The purpose to all my 'arguments' is to critically examine the claim that "there is no 'Arduino Language' -- it is programmed in C++".

C++ is a standardized programming language. "Arduino language" varies, and in some places varies considerably, from that standard. That's why I think calling it a "dialect" is most appropriate.

Also, don't forget the claim that there is an "Arduino programming language" is proposed by "Team Arduino" itself on the home page of this web site. So it seems quite reasonable for newcomers to come in with that expectation. To be then told "no, there's no 'Arduino programming language', it's just C++" isn't quite accurate, in my opinion.

In any case I don't think it is unreasonable to alert beginners, casual observers, and the unwary generally, to the differences. Or even just that there _are_ differences.

« Last Edit: November 23, 2012, 11:33:54 am by pico » Logged

WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 331
Posts: 16499
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
In any case I don't think it is unreasonable to alert beginners, casual observers, and the unwary generally, to the differences.

Your points do have merit I'm sure, don't misunderstand me. What would you suggest be a nice concise and accurate 'standardized' response one should post when a beginner asks "what programming language is the arduino using"? One sentence would be nice if possible, and no nerd words would be helpful.  smiley-wink

Lefty
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 118
Posts: 4545
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

... is to make sure that beginners be made aware that they are not choosing to take the true path towards C/C++ priesthood by using the arduino IDE?

I don't think 'bool' vs 'boolean' is the deal breaker, you can fix it with a typedef.

The real thing preventing people from gaining their C++ robes is that Arduino doesn't push RAII - nobody's using std::vector or smart pointers. I'd flame people for that on programs for big machines but I'll let it go on the Arduino where you typically only have have a dozen global arrays. On the plus side they're not using C pointers much or any of the other real bad parts of C. This is good - they're not developing any mind-altering habits that'll get carried over to other platforms if they ever start writing code on those machines.

The Java people are trying to use "String" and failing but that's just Karma. I try not to interfere with Karma.
Logged

No, I don't answer questions sent in private messages...

Offline Offline
God Member
*****
Karma: 21
Posts: 650
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

[What would you suggest be a nice concise and accurate 'standardized' response one should post when a beginner asks "what programming language is the arduino using"? One sentence would be nice if possible, and no nerd words would be helpful.  smiley-wink

How about:

"The 'Arduino Language' is a dialect of C/C++ that attempts to make programming simpler for the beginner at the expense of not being completely standard. Refer to this _web page_ for a summary of the important differences from standard C/C++. This will be particularly helpful if you already have experience with programming in C/C++ on other platforms."

Something like that. Someone has to write a _web page_, though.
Logged

WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 118
Posts: 4545
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The purpose to all my 'arguments' is to critically examine the claim that "there is no 'Arduino Language' -- it is programmed in C++".

C++ is a standardized programming language. "Arduino language" varies, and in some places varies considerably, from that standard. That's why I think calling it a "dialect" is most appropriate.

I think the style of programming is a much bigger difference than the slight differences in semantics.

eg. If I had to recommend a book to learn the language the obvious choice is a C++ book.

OTOH there's going to be a lot of stuff in that book which is good C++ practice but you shouldn't ever use on the Arduino.

A C book doesn't work either, because you'd be missing out on some of the best improvements of C++ over C.
Logged

No, I don't answer questions sent in private messages...

Offline Offline
God Member
*****
Karma: 21
Posts: 650
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If I had to recommend a book to learn the language the obvious choice is a C++ book.

I agree it's the _obvious_ choice, but not necessarily the correct one.

In any case, there are many reasons not to go too far outside standard C when programming microcontrollers. At lot of C++ stuff is completely inapproriate in a micro environment, and it takes a lot of experience to know what parts of C++ you can sensibly use and what you can't.

A C book doesn't work either, because you'd be missing out on some of the best improvements of C++ over C.

A good C book is _perfect_ for the beginner. There is plenty of time later on  to learn about all the 'improvements' of C++ over C. And also some of the things that didn't turn out so well... smiley-wink
« Last Edit: November 23, 2012, 12:15:14 pm by pico » Logged

WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 118
Posts: 4545
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There is plenty of time later on  to learn about all the 'improvements' of C++ over C. And also some of the things that didn't turn out so well... smiley-wink

I think most things made it better.

The syntax of some things isn't ideal but you can get used to it.

I can only think of one 'big' feature that should never be used under any circumstances - C++ arrays (ie. new[] and delete[]) - ick!

Logged

No, I don't answer questions sent in private messages...

UK
Offline Offline
God Member
*****
Karma: 1
Posts: 530
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

[What would you suggest be a nice concise and accurate 'standardized' response one should post when a beginner asks "what programming language is the arduino using"? One sentence would be nice if possible, and no nerd words would be helpful.  smiley-wink

How about:

"The 'Arduino Language' is a dialect of C/C++ that attempts to make programming simpler for the beginner at the expense of not being completely standard. Refer to this _web page_ for a summary of the important differences from standard C/C++. This will be particularly helpful if you already have experience with programming in C/C++ on other platforms."

Something like that. Someone has to write a _web page_, though.


I'd agree this would be more than an appropriate discription. Best I get reading C :-)
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I think the book is clear and simply written

Come back in 10 years and see if you still think so, smiley
Logged

Offline Offline
God Member
*****
Karma: 21
Posts: 650
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I think the book is clear and simply written

Come back in 10 years and see if you still think so, smiley


Well, I still think so after owning the book (well, more than one edition) for nearly 30 years.

If I start finding it hard to understand after 40 years, I will put that down to dementia, rather than the quality of authorship having changed.

I'll let you know.

Out of interest, what parts exactly do you think are not clearly and simply written?
Logged

WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
If I start finding it hard to understand after 40 years, I will put that down to dementia, rather than the quality of authorship having changed.

Everytime, if you find that you are discovering new things in the book, you are making progress in understanding C.

If you have come to the point where you have stop'd to find new things in the book, two possibilities:

1) programming isn't for you;
2) you are extremely gifted and it is high time for you to write a C book to replace K&R.

Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I can only think of one 'big' feature that should never be used under any circumstances - C++ arrays (ie. new[] and delete[]) - ick!

new and delete solve specific problems, it's a pity there is a bug in free, which make the use of them somewhat academic.
Logged

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