Previously, The Reg pointed sysadmins toward a slew of iPad apps that might brighten their workaday worlds. The target market for today's second installment of our iPad-app round-up is coders.
If you missed our first installment of "119 iPad apps for admins, coders, and geeks", you might want to take a quick peek at its intro, …
"C++ Cheat Sheet" has a nice picture explaining inheritance, which suggests using the ever-unpopular private inheritance (see e.g. http://www.parashift.com/c++-faq-lite/private-inheritance.html#faq-24.3). While legitimate, possibly this is not the most commonly-used C++ inheritance.
You're missing an AND operator there, the correct syntax is:
!pointless && (useful || fun);
After briefly looking through the app store, I moved the not-pointless test to the head of the expression, so that can short-circuit the other tests...
But compilers being what they are with their somewhat holier than thou "I know this chip FAR better than you, you blockhead" attitude can sometimes surprisingly compile a statement in an order in which you least expect.
I do not believe the c standard MANDATES that the compiler has to strictly compile that above example from left to right (I could be wrong). Just that it executes "as if it were compiled from left to right."
Doesn't matter ultimately as long as it executes logically correctly.
Unlike the bitwise binary & operator, the && operator guarantees left-to-right evaluation; there is a sequence point after the evaluation of the first operand. If the first operand compares equal to 0, the second operand is not evaluated.
"
The logical-OR operator || has the same short-circuit behaviour if the left-hand operand is non-zero.
A lot of C code relies on this behaviour. For example, this common idiom: if (ptr && *ptr ) // make sure ptr is not null and not empty string
... without short circuiting, it's a segmentation fault waiting to happen.
Seeing how Apple's Numbers offers an alternative virtual keyboard layout when entering cell data, I was wondering why those code editing apps don't do the same. Without a numerical upper row, cursor movement keys and a few extra characters around, having to use the .?123 all too often will result in intense expletivity and genocidal impulses.
A lot of supposedly C++ is actually just C with a sprinkling of C++ flavouring dusted on the top. This is especially true or high performance and low level code. This is mainly because a large number of people who code in C++ knew C beforehand. In fact if a lot of new C++ coders learnt C first it would probably make their code a lot more readable and effecient. The number of times I've seen some bloated iostream abortion 2 lines long used to print out some formatted log message when printf() could have done it in 10 characters I've lost count of. Also the (mis)use of inefficient std::string by people who seem to have no clue how to string splice using pointers is legion.
With the right privilege a run away pointer is a wondrous thing to behold and C is one of the few languages (above assembler) that lets you do this.
When you can code safely and reliably with C pointers, you have mastered the art of coding without shifting huge buffers of data needlessly around the place, and this skill holds good for higher level languages with proper pointer support.
I code micro-controllers as part of my electronics hobby (many years ago used to be my work, but now I enjoy it) and still think C is a great balance between total control and coding efficiency. I have to resort to assembler on occasion, but not that often, C is able to get most things done.
C coders who didn't code particularly well in C being unleashed on C++. I've seen numerous examples of legacy code done by people with that background which ends up with huge classes that do lots of different things. Or using polymorphism only to needlessly break it a few lines later. Or sprinkling mallocs in code. And so on...
Granted the problem isn't necessarily that they were C coders beforehand, but at least part of it is that they think functionally and with a C-mindset instead of a C++ one and didn't spend the time switching that mindset before starting to write C++. For what it's worth I agree that C++ coders should learn C first, for the same reason that I think any C-style OO language developer should have a grounding in C++ first.
Ah the memories. I remember learning C in the late 80s on a BTEC in Computer Studies. I did pretty well. Then it all went out the window and I've forgotten virtually all of it. Perhaps this little app you mention is in order! Now the kids are allowed to do HTML and can even use colour, whatever next!
You might have told us that Puchkoff SDK Tutorials HD is only meant for the iPad. I bought it on your recommendation only to find that it will not download to my iPod touch. To add to the confusion, the payment didn't register immediately on my online bank statement and I suspect I may have inadvertantly ordered it twice. And last but not least, the cost was $4.95 or so...sigh....
119 iPad apps for admins, coders and geeks
Previously, The Reg pointed sysadmins toward a slew of iPad apps that might brighten their workaday worlds. The target market for today's second installment of our iPad-app round-up is coders. If you missed our first installment of "119 iPad apps for admins, coders, and geeks", you might want to take a quick peek at its intro, …
This topic is closed for new posts.
Posted Monday 23rd August 2010 09:12 GMT
Anonymous Coward
class Employee : Person #
"C++ Cheat Sheet" has a nice picture explaining inheritance, which suggests using the ever-unpopular private inheritance (see e.g. http://www.parashift.com/c++-faq-lite/private-inheritance.html#faq-24.3). While legitimate, possibly this is not the most commonly-used C++ inheritance.
Unless, of course, an earlier page advises saying
#define class struct
Posted Monday 23rd August 2010 09:13 GMT
Tim Parker
Syntax checker ? #
..perhaps that might be useful if
Useful || fun ! pointless; // for coders*
is meant to be C/C++ (if it's legal Java or whatever language would allow such an abomination then, my apologies.. and my sympathies)
Maybe (for C++ anyway)
(Useful || fun) && ! pointless ; // for journalists
or even
(Useful or fun) and not pointless ; // for heretics
Posted Monday 23rd August 2010 09:13 GMT
Kristian Walsh
Syntax error at subhead #
You're missing an AND operator there, the correct syntax is:
!pointless && (useful || fun);
After briefly looking through the app store, I moved the not-pointless test to the head of the expression, so that can short-circuit the other tests...
Posted Monday 23rd August 2010 11:59 GMT
Tim Parker
Excellent optimization.. #
..even Knuth would have approved
Posted Saturday 28th August 2010 23:34 GMT
sT0rNG b4R3 duRiD
Technically Yes... #
But compilers being what they are with their somewhat holier than thou "I know this chip FAR better than you, you blockhead" attitude can sometimes surprisingly compile a statement in an order in which you least expect.
I do not believe the c standard MANDATES that the compiler has to strictly compile that above example from left to right (I could be wrong). Just that it executes "as if it were compiled from left to right."
Doesn't matter ultimately as long as it executes logically correctly.
Posted Monday 30th August 2010 00:52 GMT
Kristian Walsh
Re: Technically Yes... #
From the horse's mouth:
"3.3.13 Logical AND operator
[...]
Unlike the bitwise binary & operator, the && operator guarantees left-to-right evaluation; there is a sequence point after the evaluation of the first operand. If the first operand compares equal to 0, the second operand is not evaluated.
"
The logical-OR operator || has the same short-circuit behaviour if the left-hand operand is non-zero.
A lot of C code relies on this behaviour. For example, this common idiom: if (ptr && *ptr ) // make sure ptr is not null and not empty string
... without short circuiting, it's a segmentation fault waiting to happen.
Posted Monday 23rd August 2010 10:31 GMT
snafu
Editing and virtual keyboards #
Seeing how Apple's Numbers offers an alternative virtual keyboard layout when entering cell data, I was wondering why those code editing apps don't do the same. Without a numerical upper row, cursor movement keys and a few extra characters around, having to use the .?123 all too often will result in intense expletivity and genocidal impulses.
It already does in normal tasks.
Posted Monday 23rd August 2010 12:07 GMT
boltar
C isn't in memory lane yet #
A lot of supposedly C++ is actually just C with a sprinkling of C++ flavouring dusted on the top. This is especially true or high performance and low level code. This is mainly because a large number of people who code in C++ knew C beforehand. In fact if a lot of new C++ coders learnt C first it would probably make their code a lot more readable and effecient. The number of times I've seen some bloated iostream abortion 2 lines long used to print out some formatted log message when printf() could have done it in 10 characters I've lost count of. Also the (mis)use of inefficient std::string by people who seem to have no clue how to string splice using pointers is legion.
Posted Monday 23rd August 2010 13:13 GMT
Anonymous Coward
Ah pointers! #
With the right privilege a run away pointer is a wondrous thing to behold and C is one of the few languages (above assembler) that lets you do this.
When you can code safely and reliably with C pointers, you have mastered the art of coding without shifting huge buffers of data needlessly around the place, and this skill holds good for higher level languages with proper pointer support.
I code micro-controllers as part of my electronics hobby (many years ago used to be my work, but now I enjoy it) and still think C is a great balance between total control and coding efficiency. I have to resort to assembler on occasion, but not that often, C is able to get most things done.
Posted Tuesday 31st August 2010 12:27 GMT
Shakje
The real problem is... #
C coders who didn't code particularly well in C being unleashed on C++. I've seen numerous examples of legacy code done by people with that background which ends up with huge classes that do lots of different things. Or using polymorphism only to needlessly break it a few lines later. Or sprinkling mallocs in code. And so on...
Granted the problem isn't necessarily that they were C coders beforehand, but at least part of it is that they think functionally and with a C-mindset instead of a C++ one and didn't spend the time switching that mindset before starting to write C++. For what it's worth I agree that C++ coders should learn C first, for the same reason that I think any C-style OO language developer should have a grounding in C++ first.
Posted Tuesday 24th August 2010 00:20 GMT
Yet Another Anonymous coward
Syntax error #
"builds form an another class" (sic)
You have to worry if this is how well they proof-read the screenshot for the app.
Posted Tuesday 24th August 2010 01:05 GMT
JB
C for miles! #
Ah the memories. I remember learning C in the late 80s on a BTEC in Computer Studies. I did pretty well. Then it all went out the window and I've forgotten virtually all of it. Perhaps this little app you mention is in order! Now the kids are allowed to do HTML and can even use colour, whatever next!
Posted Tuesday 24th August 2010 11:47 GMT
Anonymous Coward
You might have given us better info #
You might have told us that Puchkoff SDK Tutorials HD is only meant for the iPad. I bought it on your recommendation only to find that it will not download to my iPod touch. To add to the confusion, the payment didn't register immediately on my online bank statement and I suspect I may have inadvertantly ordered it twice. And last but not least, the cost was $4.95 or so...sigh....
Posted Tuesday 31st August 2010 09:44 GMT
Anonymous Coward
Perhaps the title of the article was a hint #
Given that the article's called "119 iPad apps for admins, coders and geeks" ....
Posted Saturday 28th August 2010 21:41 GMT
Tom 7
But surely these are #
doing apps - not consuming apps and so of no use to an IPad user - other than paying for content that is available free almost everywhere on the web.
Looking forward to the Hiroshima quantiser tho...
This topic is closed for new posts.