Slashdot Mirror


Is IoT a Reason To Learn C? (cio.com)

itwbennett writes: Whether or not beginning programmers should learn C is a question that has been roundly debated on Slashdot and elsewhere. The general consensus seems to be that learning it will make you a better programmer -- and it looks good on your resume. But now there might be another reason to learn C: the rapid growth of the internet of things (IoT) could cause a spike in demand for C skills, according to Gartner analyst Mark Driver. "For traditional workloads there is no need to be counting the bytes like there used to be. But when it comes to IoT applications there is that need once again..."

374 comments

  1. Until by denisbergeron · · Score: 1, Insightful

    Someone create a IOT language!

    --
    Ceci n'est pas une Signature !
    1. Re:Until by Anonymous Coward · · Score: 2, Insightful

      Ugh... Please don't give them any ideas. C is plenty fine for the task.

    2. Re:Until by K.+S.+Kyosuke · · Score: 2

      So is Oberon, for example.

      --
      Ezekiel 23:20
    3. Re:Until by MightyMartian · · Score: 1

      If I can't use Rust or C# for low-level coding, then I demand my money back!!!!!!!!! For fuck's sake, I want to compile Ruby to run executables on my fridge!

      --
      The world's burning. Moped Jesus spotted on I50. Details at 11.
    4. Re:Until by Anonymous Coward · · Score: 0

      Ugh no.

      If anything make people learn 6502 assembler and actually conserve bytes. Geez.

      C is at the very minimum a way to make things portable. C++ is not.

    5. Re: Until by Anonymous Coward · · Score: 0

      I work on mainframes. Don't wish Assembler on them.

    6. Re:Until by 0100010001010011 · · Score: 1

      There's MicroPython and you can also build stuff with Simulink.

    7. Re:Until by iduno · · Score: 1

      Its called assembly :-)

    8. Re:Until by Anonymous Coward · · Score: 0

      Which is what Java was originally intended to be...

    9. Re:Until by serviscope_minor · · Score: 2

      You canuse rust, that's kind of what it's designed for. It's got more or less the same view of the machine as C, but with a much more sophisticated compiler front end.

      --
      SJW n. One who posts facts.
    10. Re:Until by Anonymous Coward · · Score: 0

      Some of us know and use assembler.

      Still some pascal guys around too.

      IoT needs someone that talks to the metal or didn't you know that.

    11. Re:Until by Anonymous Coward · · Score: 0

      Already exists. It's called Rust.

    12. Re: Until by Anonymous Coward · · Score: 0

      Exactly, Embedded Java; a micro virtual machine for every microcontroller from here to Malaysia.

    13. Re:Until by Anonymous Coward · · Score: 0

      "you can also build stuff with Simulink."

      Sure, you can, in much the same way I can come over to your house and kick you repeatedly in the head. Neither option is going to be fun for anybody.

    14. Re:Until by Z00L00K · · Score: 3, Insightful

      If you really want something unmaintainable you should go for Simulink.

      On the other hand - I have never seen a good reason NOT to learn C. It's one of the basic building block languages that's widely used on almost every platform, so you won't waste your time if you learn C.

      --
      If builders built buildings the way programmers wrote programs, then the first woodpecker would destroy civilization.
    15. Re:Until by Anonymous Coward · · Score: 0

      Here is a good reason not to learn C: shitty memory management.

    16. Re:Until by goose-incarnated · · Score: 2

      A C64 game written in C++17.

      This kinda displays why C++ is unsuitable for small memory stuff. The C64 had remarkably large games in its time, and yet by using C++ all that is possible is a simple pong clone. I wrote for the C64. This "demo" is very unimpressive.

      --
      I'm a minority race. Save your vitriol for white people.
    17. Re:Until by Anonymous Coward · · Score: 0

      A C64 game written in C++17.

      This kinda displays why C++ is unsuitable for small memory stuff. The C64 had remarkably large games in its time, and yet by using C++ all that is possible is a simple pong clone. I wrote for the C64. This "demo" is very unimpressive.

      Just link with nostdlib and you will be fine :P

    18. Re:Until by Anonymous Coward · · Score: 1

      That isn't the main thing I took from it.
      What he shows is that it is possible to make code that is targeted at the optimizer to create code that is removed at compile time.

      If you get that code handed to you together with a feature request, any change you do will likely make that code explode into bloatware that will run extremely slow if it fits in the memory footprint of the computer at all.
      That is unless you dig down through the abstractions.
      Not only do you need to have a complete understanding of the entire code base to begin to touch on the main loop. You also need to take compiler optimizations into consideration.

      The entire video is a showcase to why C++ isn't really a good language for computers where memory and processor usage actually matters.
      For a computer where you won't notice if your program takes a few extra megabytes of memory or a million cycles more it's fine. Then you don't have to worry about the abstractions hiding bloat away, but why not go for a higher level language like Java, Python or VB.net then?

    19. Re: Until by slashdot_commentator · · Score: 1

      Except most microcontrollers don't implement embedded java.

      --
      There is no America. There is no democracy. There is only IBM and AT&T and DuPont, Dow, General Electric, and Exxon
    20. Re:Until by queBurro · · Score: 1

      I've not watched all of the video, just a few minutes, but what I'm getting is that there's *no* (or some) overhead in using a modern C++ compiler over C? what am I missing? does it blow up later on in the video?

      --
      sag
    21. Re:Until by Anonymous Coward · · Score: 0

      The game was small because it was a demo for a 1-hour talk when you survey the entire code.

      Also, the point was that this game was written with *no variables on the stack whatsoever* - only registers. And it demostrated just how capable C++ is on these devices, allowing you to efficiently larger games then you could probably do in C.

    22. Re:Until by jellomizer · · Score: 1

      A lot of these performances features of language such as C isn't from the language but the compilers. The language itself is just a wrapper to the machine code being generated.
      Sure there are some low level features that may allow assembly code but that is rather rare in today's coding methodology because we have with most compilers and OSs a big set of libraries to do most of the stuff we need.
      That said compiling a language such as Python could have just as good performance as C over time as the compiler gets optimized.

      --
      If something is so important that you feel the need to post it on the internet... It probably isn't that important.
    23. Re:Until by jellomizer · · Score: 1

      A lot of this bloat we see in today's programs is actually future proofing the code vs just being lazy.
      The systems of old on computers that were not as powerful didn't have room for for this and most developers didn't have history to realize what are the average changes overtime are. So they wrote tight code to do exactly what was needed. Today a lot of resources goes into hooks in code to allow to expand featured, change UI elements. With gigs of ram available some algorithms can work faster with more readable code using more RAM and less CPU especially on higher load systems.

      --
      If something is so important that you feel the need to post it on the internet... It probably isn't that important.
    24. Re:Until by Anonymous Coward · · Score: 0

      True, but remember that the C++ overhead is fairly constant. And the C64 example serves to show that C++17 overhead to be still 64 KB. So, for your typical IoT device with a Cortex-M series microcontroller and ~1MB of memory, it's fine. For Raspberry Pi-class devices, it's a trivial overhead.

    25. Re:Until by Anonymous Coward · · Score: 0

      Here is a good reason not to learn C: shitty memory management.

      Your argument is akin to claiming that learning assembly language programming is a waste of time due to its lack of higher level control structures. In other words, your argument is meaningless.

    26. Re:Until by DrXym · · Score: 1

      They have. It's called Rust and it solves many of the problems that traditionally plague C or C++ - memory leaks, dangling pointers etc. The net result is more stable, reliable software that has a built in resistance to some forms of attack. I think if I were writing IoT software I would choose Rust unless there was a genuine reason that it could not be used.

    27. Re: Until by Anonymous Coward · · Score: 0

      tl;dw ?

    28. Re:Until by TheRaven64 · · Score: 1

      Samsung has released a JavaScript implementation for devices with under 64KB of RAM and 200KB of ROM. There's also a version of Python that targets the BBC Bit. The idea that you can't run high-level languages on these systems is laughable when you consider that a Cortex M0 is more powerful than the Xerox Alto, which was able to run an entire multitasking GUI written in a high-level language (Smalltalk) in well under 1MB of RAM.

      --
      I am TheRaven on Soylent News
    29. Re:Until by Anonymous Coward · · Score: 0

      *No* memory management. Big difference. If you want to discuss shitty memory management there's always Java.

    30. Re:Until by Anonymous Coward · · Score: 0

      Right, but it's shitty for the programmer to manage it manually, isn't it?

    31. Re:Until by Anonymous Coward · · Score: 0

      No it's not. In assembly you can write macros and make things a lot easier on that respect. What can you do in C about memory management?

    32. Re:Until by Anonymous Coward · · Score: 0

      Right, but it's shitty for the programmer to manage it manually, isn't it?

      Not in heavily-constrained environments.

      And, it's not hard to manage memory if you actually know what you're doing.

      I used to work on a point-of-sale system that had: 7-8 networked machines per store, touch-screen user interface, with each machine acting as a file/database/printer/custom hardware server. It ran in 2MB of ram. It used heap memory extensively, and we knew it didn't have any memory leaks because it allocated and freed almost all of it's data every day, and every day each memory item landed at the same address as it occupied the day before. These systems ran non-stop for months and years without stopping.

    33. Re:Until by Joce640k · · Score: 1

      C is at the very minimum a way to make things portable. C++ is not.

      This isn't 1992.

      Do you know any platforms where there's a C compiler but not a C++ compiler?

      --
      No sig today...
    34. Re:Until by Anonymous Coward · · Score: 0

      The BBC MicroBit is a really expensive board.
      64kB of RAM is gigantic, a truly small embedded system will more likely have 1 kB max., some will only have 32 bytes and for a lot of applications that is enough.
      And those 64 kB don't even include that your JavaScript code in many cases will take up a more space than a compiled program, and the variables inside that JavaScript will take up a LOT more than hand-allocated ones in C code, not to mention that I don't think that JavaScript implementation will do JIT, so it will be badly slow.
      On the one hand, 64 kB may not cost much, but on the other hand bloating your system requirements 1000x just because of your choice of programming language is really questionable.

    35. Re:Until by Joce640k · · Score: 3, Insightful

      Complete bollocks.

      I use C++ on a day to day basis on Atmel chips. I've written ray tracers in C++ on chips with 4K Flash and 128 bytes of RAM using ordinary "float" data types.

      The entire "Arduino" ecosystem runs on C++, driving 3D printers, robots, etc. on tiny microcontrollers. How do you explain that Pesky Fact?

      Java, Python and VB.net don't have a snowball's chance in hell of running on one of those chips.

      (Most likely you've never even used C++, you're just repeating crap you once read on the Internet)

      --
      No sig today...
    36. Re:Until by Joce640k · · Score: 1

      C++ has no overhead compared to C unless you choose it. The most repeated phrase in C++ design was/is "you don't pay for what you don't use".

      eg. If you choose to use virtual functions in classes then there's some overhead. If you don't, there isn't. Your choice.

      --
      No sig today...
    37. Re:Until by Joce640k · · Score: 1

      C++ powers the entire Arduino ecosystem. Chips with 32kb flash and 2K RAM are happily running C++ all over the world as we speak. Most of those programs will run on chips a quarter of the size (the Arduino IDE prints out how much flash/RAM your program uses on every upload to the chip so you can see it).

      --
      No sig today...
    38. Re:Until by Joce640k · · Score: 0

      Here is a good reason not to learn C: shitty memory management.

      Yep, and that's where C++ came in.

      NOBODY should be writing real code using malloc/free. Use std::string and std::vector instead. You can use them perfectly well in "C" code so there's no excuse.

      --
      No sig today...
    39. Re:Until by Joce640k · · Score: 1

      What can you do in C about memory management?

      Simple: Use C++ memory management instead. Your existing "C" compiler can probably do it if you let it.

      When you're there you might find you enjoy some of the other features too.

      --
      No sig today...
    40. Re:Until by Joce640k · · Score: 4, Insightful

      Right, but it's shitty for the programmer to manage it manually, isn't it?

      Not as shitty as having to guess when Java will close the file you just wrote (eg. so you can copy it to a USB stick).

      Resource management is much more than RAM, it's files, network connections, etc. Garbage collectors handle RAM OK but they're really really crap for everything else. In reality languages like Java need just as much manual resource management as C.

      The only language which really doesn't need manual work is C++. C++ has stack unwinding. C++ frees resources immediately when objects go out of scope, not when some garbage collector decides to wake up (which might be "never" - your file might _never_ close unless you quit the program).

      --
      No sig today...
    41. Re:Until by Joce640k · · Score: 1

      I manage a 500,000 line C++ program which does a lot of memory management. There's exactly nineteen "delete" statements in all that code and the last one was added about 10 years ago. The person who adds number 20 has to invite everybody out for dinner.

      Nobody in the last ten years has done any manual memory management in this program or had a leak or a dangling pointer. It also closes all files promptly, etc. (try getting a garbage collector to do that!)

      Whatever else Rust may do, C++ memory management isn't one of the problems it solves.

      --
      No sig today...
    42. Re:Until by TheRaven64 · · Score: 1

      IoT devices are, by definition, running a network stack. That brings you into the 32KB of RAM requirement as a minimum. The requirements for JavaScript are pretty small relative to that.

      --
      I am TheRaven on Soylent News
    43. Re:Until by Anonymous Coward · · Score: 1

      C lets you manage your memory in any way you want. Whether to do it shitty or properly is entirely up to the programmer.

    44. Re:Until by Anonymous Coward · · Score: 1

      NOBODY should be writing real code using malloc/free

      Why not? malloc() and free() work perfectly fine and have done so for decades.

      Use std::string and std::vector instead. You can use them perfectly well in "C" code so there's no excuse.

      Uhm, no. Both are C++ additions that are not in any ISO C standard. If you want to use them, you need to compile with a C++ compiler and you need to link against C++ libraries, which may or may not be available for your target platform, even if you don't mind the additional clutter without any real added functionality.

    45. Re:Until by DrXym · · Score: 1

      That's great for you. It doesn't alter the point in the slightest. Even if there is a subset of modern C++ which (when used with discipline and years of knowledge) can avoid problems prevalent in C and C++ doesn't mean those problems aren't prevalent. They are.

    46. Re:Until by Joce640k · · Score: 0

      Use std::string and std::vector instead. You can use them perfectly well in "C" code so there's no excuse.

      Uhm, no. Both are C++ additions that are not in any ISO C standard. If you want to use them, you need to compile with a C++ compiler and you need to link against C++ libraries, which may or may not be available for your target platform, even if you don't mind the additional clutter without any real added functionality.

      I didn't say they were in the ISO C standard, that's why I out "C" in quotes.

      You can write old fashioned C code but use std::string instead of malloc/strcpy/strdup/etc. There's no clutter or overhead, std::string most likely uses malloc/free underneath so in effect the compiler will produce the exact same code as you.

      The difference is that the compiler never has a bad hair day and messes up the size of a malloc. It's also easier, you don't have to worry about ownership, you can throw exceptions in a deeply nested file reader and all the temporary strings will be freed for you automatically (assuming they're stack-based objects). etc., etc.

      Anybody using malloc/free to manage strings in 2017 is doing it wrong.

      And by extension: Anybody managing data arrays without std:vector is also doing it wrong.

      --
      No sig today...
    47. Re:Until by 0100010001010011 · · Score: 1

      The car you drive, the planes you fly in, and a whole host of other engineering tools use Simulink, it works just fine.

      A poor carpenter blames his tools.

    48. Re:Until by 0100010001010011 · · Score: 1

      [Citation Needed]

      It's used literally everywhere in engineering. Your on road vehicle, off road vehicles, airplanes, it's maintainable just fine.

    49. Re:Until by Joce640k · · Score: 1

      OK, I'll give you that.

      Still, people like Linus Torvalds aren't helping by insisting that Linux never be tainted by a single C++ feature.

      Even if he only allowed STL usage (std::string/std::vector/std::list, etc) and stack unwinding it would still be a huge step forwards.

      --
      No sig today...
    50. Re:Until by Anonymous Coward · · Score: 0

      > In assembly you can write macros and make things a lot easier on that respect.

      In C you can write functions and make things a lot easier on that respect. :-P

    51. Re:Until by Megane · · Score: 4, Interesting

      The trick to using C++ in embedded is to throw away stuff like the STL that depends on memory allocation, and the ivory-tower stunt crap like iostreams. Even templates are generally bad because they cause code size to explode by compiling a new version of each method for every class that uses them.

      Basically, do what mbed does and use it as "C with classes". If you declare global objects for each I/O device, the class declaration then becomes an API for the device, and the object hides all the internal state. The operational details of it can be rewritten for a similar kind of device, without changing the code that uses it. If you do things right, you might even save some bytes. C++'s inlining of method calls when there is no ambiguity also contributes to the efficiency. It is also much easier to use virtual methods than to deal with the twisty function pointer syntax in C, plus you only get one set of virtual function pointers generated per class in the vtable, and can't use the wrong function pointers by accident.

      --
      #naabhaprzrag, #sverubfr-000, #agi-fcbafberq, negvpyr[pynff*=' negvpyr-ary-'] { qvfcynl: abar !vzcbegnag; }
    52. Re:Until by Megane · · Score: 1

      I still don't know how you can get that much overhead unless you try to use the really heavy stuff like STL. I mean, I know the 6502 isn't exactly designed to run C, but for a pong game? You shouldn't need shit like locale support, floats in printf, or even memory allocation for a freaking pong game. And if you don't disable RTTI and exceptions in compiler options when doing embedded C++, then you're a complete idiot.

      --
      #naabhaprzrag, #sverubfr-000, #agi-fcbafberq, negvpyr[pynff*=' negvpyr-ary-'] { qvfcynl: abar !vzcbegnag; }
    53. Re:Until by Anonymous Coward · · Score: 0

      Read the GP post, he (you?) was comparing the absence of high level control structures in assembly with the absence of automatic memory management in C.

    54. Re:Until by jimtheowl · · Score: 1

      My C Compiler is written in Oberon and every time I have to port C to a new platform, I have to compile it with Oberon first, so I might as well use Oberon in the first place...except on the Unisys MCP where they use Algol as a system language.

      Ok.. I jest, and despite that have great respect for Niklaus Wirth. But it is not like Oberon is a straight forward drop in replacement for C.

    55. Re:Until by Anonymous Coward · · Score: 0

      and every day each memory item landed at the same address as it occupied the day before.

      Isn't that a weakness? ASLR on any modern OS already fixed that.

    56. Re:Until by Anonymous Coward · · Score: 0

      C lets you manage your memory in any way you want. Whether to do it shitty or properly is related to how reasonable are the deadlines imposed on the programmer by management.

      FTFY

    57. Re:Until by Anonymous Coward · · Score: 0

      Great, I will give it a shot! Thanks for the pointer (no pun intended).

      Do you think I could use this C++ feature in IoT devices?

    58. Re:Until by petermgreen · · Score: 1

      No, with std:: string each time you write something like "a =b" the compiler has to either mess with reference counts (most implementations of c++03 and earlier) or copy all the data (c++11 and later). You can work around that by using references but then you lose the safety advantages of automatic memory management and add an extra level of indirection to accesses .

      --
      note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
    59. Re:Until by Anonymous Coward · · Score: 0

      The only language which really doesn't need manual work is C++. C++ has stack unwinding. C++ frees resources immediately when objects go out of scope, not when some garbage collector decides to wake up

      and the reason that this incredible feature of C++ was not replicated in any other language is because the designers of the rest of the languages are incredibly lazy or incompetent?

    60. Re:Until by ahadsell · · Score: 1

      C's memory management is performed by the programmer. So if it's shitty, you made it that way.

    61. Re:Until by thegarbz · · Score: 1

      The entire "Arduino" ecosystem runs on C++, driving 3D printers, robots, etc. on tiny microcontrollers. How do you explain that Pesky Fact?

      People who really know what their doing and how to optimise for the case they are writing. It's interesting you mention Arduino since Arduino's own manual specifies the primary way to change the status of the pin is digitalWrite(pin, number). This wonderful instruction takes 55 cycles to complete.

      C++ provides a layer of abstraction, and in general doesn't provide the layer of optimisation Atmel's C compiler has. This is quite powerful and will quite easily let people shoot themselves in the foot. But for experts who really know what they are doing, they would be able to write it in brainfuck for all anyone cares.

    62. Re: Until by Anonymous Coward · · Score: 0

      Yeh because closing files yourself when your done is so complicated, and being lazy and letting the garbage collector is the right way...

    63. Re:Until by david_thornley · · Score: 1

      There's a very useful subset of modern C++ that can be used without years of knowledge and whose discipline can be enforced by code reviews. You're going to want people around who know C++ better than that, but for most purposes there's no need to use a lot of C constructs.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    64. Re:Until by Z00L00K · · Score: 1

      Just because it's used there doesn't mean that it's very good for it, I have seen how bad it can become in vehicle engineering - and trust me, it would make Classic Basic look maintainable.

      --
      If builders built buildings the way programmers wrote programs, then the first woodpecker would destroy civilization.
    65. Re:Until by K.+S.+Kyosuke · · Score: 1

      That's possible, but people seem to be quite happy with Astrobe.

      --
      Ezekiel 23:20
    66. Re: Until by Anonymous Coward · · Score: 0

      Java has many problems, but this isn't one of them.

      Speaking as a Java programmer (who is also fluent in C and C++)... if you are relying on the garbage collector to close your files for you, you are doing it wrong. Virtually every Java tutorial in existence warns against this. You should instead be using an explicit "close" call in conjunction with a try...finally block (or the new try-with-resources, which will do the close for you) so that the file gets reliably closed at a definite point in time even if exceptions are thrown. (This is basically Java's version of RAII.)

      The fact that the garbage collector will possibly eventually close the file for you anyway if you forget to explicitly close it yourself (which you should have!) is a defensive programming feature, not a bug, and one that C doesn't have. In C, if you forget, the file never gets closed. In Java, it probably will be, eventually, despite your buggy code that failed to close it in a timely manner as it should have.

      Garbage collection is not magic. In Java, it is useful for basically managing one type of resource: memory. For most other types of resources (open files, network sockets, etc.), some kind of try...finally block is the right language construct to use.

      Criticising a language without knowing how it is intended to be used is seldom useful.

    67. Re:Until by Anonymous Coward · · Score: 0

      Well, software written under shitty management sucks, but that is hardly news and it is independent of the features of the language. In a different language, people will find different ways to fail under unreasonable pressure.

    68. Re:Until by DrXym · · Score: 1
      The problem is not that C++ has some subset which is safe, but that it everything else is unsafe and neither the compiler, nor your code reviewers are necessarily going to save you. C and C++ suffer bugs that COULD and SHOULD be caught by the compiler but aren't.

      You can code review this subset of C++ til you're blue in the face but the next project over to you may not. Even some of the most reviewed and widespread code in existence has suffered serious errors that were the fault of the language. Look at the Heartbleed bug as one example. And it's extremely clear that when we're talking of software that powers IoT devices, or cars, or hydraulic presses in factories, or X-Ray machines or anything else which has a critical function that even ONE screwup could have catastrophic consequences. Even if your software has less critical failure modes, it's still a pain in the ass if it crashes, leaks, suffers mysterious race conditions or is exploitable because the code has to enforce its own buffer checks.

      That's why Rust makes such a good fit for systems software. It shuts down an entire swath of potential programming errors before they can even happen. In the normal course of programming there are no pointers, or null pointers, or explicit memory allocation/deallocation. Things like strings and arrays are intrinsic types and are enforced against their length. Threads that share data MUST protect them with locks or mutexes or have ownership. Things that break in C/C++ at runtime are stopped by the compiler.

      C and C++ aren't going anywhere I'm sure, but neither are they defensible by saying if you know the exact subset which is safe that it absolves all the stuff which isn't in that subset.

    69. Re:Until by david_thornley · · Score: 1

      Heartbleed was not a problem with C. The maintainers put runtime efficiency over everything else, which you can do with any language. They had their own memory allocation system going, which prevented using any debugging malloc/free libraries. They skipped basic security precautions.

      Heartbleed worked by reading garbage left in memory. Ideally, when a piece of security software calls free() with a custom free(), it should zero memory. At the very least it should make sure newly malloced memory is blank (in C, you can use calloc() instead of malloc(), or call memset()). It would have been easy to avoid Heartbleed using standard C. Had the maintainers had the same priorities in other languages, I'm sure they would have found a way to screw it up.

      I don't care about the next project over. Every C++ program in this shop is code reviewed by people who mostly agree on the standards. This means that certain common classes of errors in C programs are not going to happen.

      As far as Rust goes, it sounds like you're talking about enforced safety, and most of the stuff you're talking about can be easily duplicated in C++. However, in systems software, you may run into situations where you need the raw performance. As Stroustrup pointed out, if you have a fast unchecked access it's easy to slap a check on it, but if you start with a not-as-fast checked access you can't make a checked access out of it.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    70. Re:Until by Anonymous Coward · · Score: 0

      https://micropython.org/

      I second MicroPython. I put away my Arduino once I bought one of these. Although I'm still a big fan of Python on Raspberry Pi.

    71. Re:Until by Anonymous Coward · · Score: 0

      Except if you use smart pointers to "free you of the burden of thinking about object lifecycles".

    72. Re:Until by jimtheowl · · Score: 1

      Astrobe looks nice, but runs on Windows only. I might otherwise check check if out, even if it only targets a few ARM microcontrollers and FPGAs.

      Fine if you are designing the hardware with the constraint of what the tool supports. It may work for some, but not everyone.

      C on the other hand is ubiquitous.

    73. Re:Until by DrXym · · Score: 1

      Heartbleed was a problem with C because C allowed the code to walk straight right off a buffer and send the contents to the client. If you tried that in Rust you would get a runtime panic.

    74. Re:Until by david_thornley · · Score: 1

      Except that the people who wrote the code would have found some way to lose security in the name of speed. Do you realize what it means to have people disregard C's security features?

      I don't know Rust. If it had been available back then, why do you think the code authors would have used it? They clearly would have bridled at what they saw as inefficient code generation.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    75. Re:Until by DrXym · · Score: 1
      Rust generates code which is different in performance than C or C++ code written correctly.

      Most of Rust's safety is done at compile time and compiles away to nothing or is in the design of the apis that check you're not doing something dumb when you call them. So if you tried to copy a slice of a buffer in excess of a buffer it would panic but it wouldn't impact on performance any more than C code doing the same.

      Obviously you can forego safety in C but that's the point Rust is trying to address - safety without penalising performance. That makes it perfect for IoT and its why the assumption that C can rest cosy because of IoT is a bad one. If I were writing any code for IoT I wouldn't choose C unless I had no choice. I might choose C++ assuming I could be sure of using only C++11/14 and nothing else. But I would choose Rust in preference to either of them.

    76. Re:Until by DrXym · · Score: 1

      "Rust generates code which is no different in performance than C or C++ code written correctly. ". I hate seeing typos the split second after I hit submit.

  2. DO NOT ANSWER THIS QUESTION by Anonymous Coward · · Score: 0

    IoT == massive surveillance bots + massive zombie botnet

    The premise of this question is evil.

    Choose to learn or not learn C for whatever the reason. But it is disingenuous to ask this loaded question pre-laden with an evil assumption.

    1. Re:DO NOT ANSWER THIS QUESTION by Anonymous Coward · · Score: 0

      IoTs are the best reason to go to antique stores.

    2. Re: DO NOT ANSWER THIS QUESTION by Anonymous Coward · · Score: 0

      And flea markets...

    3. Re:DO NOT ANSWER THIS QUESTION by Anonymous Coward · · Score: 0

      Fear the internet and anything connected to it because it's a massive surveillance bot!

  3. A damn good reason to learn security best practice by haruchai · · Score: 5, Insightful

    and I not sure learning C will help much with that.

    --
    Pain is merely failure leaving the body
  4. snarky: managed languages RulZ! by Anonymous Coward · · Score: 0

    Why bother with learning C when "learning" Java or other managed-runtime-based languages can get you employed based upon your interviewing skills with "design pattern" knowledge? From experience, candidates which focus on design-pattern knowledge are actually the least competent....

    1. Re:snarky: managed languages RulZ! by MightyMartian · · Score: 3, Interesting

      If you're applying at a shop that does a lot of low level coding or coding on processor, memory and/or storage restricted platforms, if you're only experience is in Java or C#, I'd say your chances are pretty low. Walk in with a good practical grounding in C coding, I would imagine your chances go up. Not every shop is occupied by hipsters looking for keywords like "Python".

      --
      The world's burning. Moped Jesus spotted on I50. Details at 11.
    2. Re:snarky: managed languages RulZ! by MikeBabcock · · Score: 1

      Then again if you claim to be a programmer who can't pick up python in a few sittings, you don't deserve the title.

      --
      - Michael T. Babcock (Yes, I blog)
    3. Re:snarky: managed languages RulZ! by ShooterNeo · · Score: 1

      Where do you find these shops? I look on job postings and everyone is asking for the latest buzzwords it seems.

    4. Re:snarky: managed languages RulZ! by ShooterNeo · · Score: 1

      Yes, but shops want "senior" Python programmers. You can't claim to be that after a few sittings.

    5. Re:snarky: managed languages RulZ! by Anonymous Coward · · Score: 0

      That's because in many shops, your "senior" programmers only graduated college a few years ago.

    6. Re:snarky: managed languages RulZ! by tepples · · Score: 1

      Does "Python, PHP, SQL, C, and MOS 6502 assembly language" look good on a generalist resume? For example, I've used Python to make data conversion tools for games on 6502-based retro platforms.

    7. Re:snarky: managed languages RulZ! by Darinbob · · Score: 2

      There are a lot of people who say they know C who can't handle some of the simple stuff in C, as I have seen in many interviews.

      I started saying "I'm sorry that I will ask some very simple questions..." because I felt embarrassed asking someone with so much on-paper experience who is applying for a hands on development job to do such simple things. Then so many of them flub it. Now I'm wondering if my apologies that the question is "simple" actually ends up as an insult for someone who can't figure them out.

    8. Re:snarky: managed languages RulZ! by Anonymous Coward · · Score: 0

      Any programmer that thinks whitespace should be significant doesn't deserve the title.

    9. Re:snarky: managed languages RulZ! by AaronW · · Score: 2

      Sadly I run into that a lot, and I've interviewed a lot of people for low-level (i.e. bare metal) programming. Generally speaking, C is a fairly simple language, but in my line of work you better know damned well what various keywords mean and how they behave (like volatile) and know pointers backwards and forwards.

      --
      This post is encrypted twice with ROT-13. Documenting or attempting to crack this encryption is illegal.
    10. Re:snarky: managed languages RulZ! by zieroh · · Score: 0

      This, 100 million times. I used to be embarrassed to ask such basic questions, but so many people miss the most fundamental things that I don't apologize any more.

      My favorite question to determine if someone likely has spent any time at all in C: ask them to describe how a C string is stored in memory. I find a lot of people who know some OO derivative of C will think they are, by definition, also C programmers, but this tends to utterly stump them.

      Why is this important? Well, I'm a career OS engineer, so I'm biased. But if you don't have the faintest idea how a C string is stored, you probably also can't tell me how the stack works, or know intrinsically (without thinking about it) whether a given hunk of memory is on the stack or on the heap. I've done probably 1000 technical phone screens in the last 4-5 years, and I see a pretty clear pattern emerging: Java programmers (those whose primary instructional language during college was Java) are, by and large, awful programmers. Even if you put aside the fact that they don't understand memory basics, can't use pointers (and often argue with me as to whether that matters) and don't know how anything outside of Java works, they are just plain shite programmers with bad instincts and bad coding habits.

      I have often found it necessary to restrain myself from telling a candidate that they should go back to their alma mater and ask for their money back. Seriously, college CS programs are doing an enormous disservice to their students by sticking primarily to Java.

      --
      People who say "sheeple" have about as much sophistication as an AOL user, and in fact are probably actually AOL users.
    11. Re:snarky: managed languages RulZ! by TheRaven64 · · Score: 1

      This is a big part of the reason that Google has started looking for experience working on compilers for general programming jobs. It's pretty hard to get that experience without understanding how fundamental language concepts are implemented, even if it's just a one-month internship.

      --
      I am TheRaven on Soylent News
    12. Re:snarky: managed languages RulZ! by Wrath0fb0b · · Score: 1

      Absolutely untrue. I work in a group that does low-level coding on a processor with 48k of RAM and 1MB of storage.

      Yes, knowledge of C is essential. But so is Python. I would say that I write about 10x more Python than I do C, partially because there's so little code on the actual platform and so much test code, analysis code and framework code that needs to be written to validate that small amount of embedded code.

      So this whole dichotomy is totally nuts.

    13. Re:snarky: managed languages RulZ! by Darinbob · · Score: 1

      While serving as a teaching assistant for a compiler class back in the 80's, I had one student who was ordinarily pretty bright ask me "why do we need to learn how to write a compiler, since we already have a compiler?"

    14. Re:snarky: managed languages RulZ! by Darinbob · · Score: 1

      Occasionally for a laugh I will click on a web link to a Yahoo Answers or other such site that asks "How does a computer work?" Invariably it's something like "This is the cpu, it does the thinking" and then moves on to the monitor and keyboard. So simplified even a kindergartener would roll their eyes. And yet the same site when asked about an automobile will mention internal combustion, pistons, gears, etc. For some reason, it's considered normal to treat computers like they're magic.

    15. Re:snarky: managed languages RulZ! by david_thornley · · Score: 1

      At one job interview, I was asked to write a simple SQL query, so I turned to the whiteboard and wrote it down. It had a SELECT clause, a FROM clause, and a WHERE clause. I was standing there waiting to be asked to do something not immediately obvious to the SQL novice, and was slightly startled when they didn't.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    16. Re:snarky: managed languages RulZ! by CSMoran · · Score: 1

      Any programmer that thinks whitespace should be significant doesn't deserve the title.

      You must wield C-x, M-c butterflies to get the badge?

      --
      Every end has half a stick.
    17. Re:snarky: managed languages RulZ! by Anonymous Coward · · Score: 0

      I like to ask candidates to debug and critique sample code. "What does this code do?" "What is wrong with it?" Some of the built-in errors (a mixture of syntax & logic) are blatant, some are subtle. "How would you improve this?" So much of programming involves starting with another person's code, I'd like to know what the candidate's thought process is. This method allows a discussion of more complicated code than a candidate can be reasonably expected to write during an interview. If they can debug it, they can probably write it.

  5. Arduino uses C++, Pi uses Linux by Anonymous Coward · · Score: 0

    IoT is not confined to something as low level as C.

    1. Re:Arduino uses C++, Pi uses Linux by ClickOnThis · · Score: 1

      Fair enough. You can always write C code in C++. But at the risk of being flamed, IMHO both are high-level languages. C++ is just higher level.

      I recall reading (maybe in Stanley Lippman's primer book) an exercise question that asked why the language is called C++ and not ++C. Worth pondering.

      --
      If it weren't for deadlines, nothing would be late.
    2. Re: Arduino uses C++, Pi uses Linux by Anonymous Coward · · Score: 0

      It was the first name that came to Bjarne's mind and he had better things to do than waste time on a name for a method of forcing the C language into the OOP paradigm?

    3. Re:Arduino uses C++, Pi uses Linux by OrangeTide · · Score: 1

      Most of the arguments that embedded C developers had against C++ are obsolete. The language has been updated over the decades, and the compilers are much better. The C++ runtime libraries used to be a lot of black magic that was hard to get working in kernel space, and many kernels had to limit themselves to a subset of C++ in order to function (L4Ka, Symbian, and others). There are now lots of compilers that work reliably and lots of papers on how to get as many of the C++ features working on supervisor mode as you're willing to invest time into doing.

      Disclaimer: I'm very much a C++ hater, and I'll never use it again even if that means I have to switch careers. But it's a purely subjective thing with me. Most of my old arguments against it no longer apply. These days I spend my energy attacking Python instead.

      --
      “Common sense is not so common.” — Voltaire
    4. Re:Arduino uses C++, Pi uses Linux by Darinbob · · Score: 2

      I dunno. There is still significant overhead with C++, which is a big problem with small devices (128KB of code for example). There's the issue of the linker not really figuring out how to share object code for templates to avoid typical bloat. There's the hidden operations behind the scenes that cause problems for novice programmers running out of space or wandering why their code is so slow. There really is no good way to make exceptions both fast and use little code space (a shame since I like them if used properly).

      I do want to use a better-C-than-C. C with classes just for the sake of structuring code more coherently. C with better type checking rules. C where I can release a semaphore on any exit from a function. A stripped down C++ that more resembles Cfront without all the newer fluff.

    5. Re:Arduino uses C++, Pi uses Linux by Anonymous Coward · · Score: 0

      Its sometimes difficult to share template code, since a major point of templates is to reduce source code. Code that works for doubles cannot be the same code as code that works for ints. So how its not bloat. In C you would get exactly the same amount of bloat plus twice the source.

    6. Re:Arduino uses C++, Pi uses Linux by goose-incarnated · · Score: 1

      Its sometimes difficult to share template code, since a major point of templates is to reduce source code. Code that works for doubles cannot be the same code as code that works for ints. So how its not bloat. In C you would get exactly the same amount of bloat plus twice the source.

      Just off the top of my head, a single template function instantiated with the same type arguments in two different compilation units produces two (identical) copies of the same code in the final executable.

      --
      I'm a minority race. Save your vitriol for white people.
    7. Re:Arduino uses C++, Pi uses Linux by AaronW · · Score: 5, Interesting

      I work at a company that makes chips for IoT, though in this case the chips are targeted at things like routers, switches, network security appliances and highly intelligent network cards. While C++ is supported, all of the stuff I work on is C. Our SDK is C. All of the vendor SDKs I've come across for dealing with different devices are written in C. Interfacing to C is fairly simple and well understood compared to introducing C++ in an embedded environment. Now the environment I deal with is either the Linux kernel or lower, usually lower since I work with bare metal most of the time.

      C is used for a number of reasons.
      1. The generated code is quite fast and fairly compact. With my experience with MIPS the output of the compiler is pretty close to hand-tuned assembly in most cases.
      2. It's easy to deal with hardware registers in C. Hardware registers can be defined by volatile bitfields so a simple pointer can be used to access them.
      3. There is no unintended overhead or hidden behavior. With C it is very much what you see is what you get. It doesn't do stuff under the covers.
      4. Memory mapping data structures and things like that are very easy in C.
      5. One is not dependent on things like a certain standard library. The amount of code needed for basic C support is fairly minimal. All you really need is a stack. I have plenty of code that does not have a heap.
      6. Things like interrupt handlers are fairly trivial to code in C.
      7. One can do interesting things using the linker with C code that are not really possible with most other languages. For example, I can easily link my code to execute at a particular address and generate a binary without any elf headers or any other cruft and there are interesting things that can be done with linker scripts.
      8. There is no unexpected overhead due to the language. There is no background garbage collection that can run at some inopportune time. There's no extra code to do bounds or pointer checking to slow down the code or even get in the way.
      9. Generally it is pretty easy to move between different versions of the toolchain. C generally doesn't change much.
      10. C seems to resist bloat better than other languages, in part because it does exactly what you tell it to and nothing more.

      Much of this can apply to C++ as well, though C++ requires a lot more overhead in order to properly support it due to some of the language features and C++ can hide certain things if you aren't careful.

      That's not to say that things can't be written in high-level languages. There is plenty of flexibility once you get to something like a Raspberry Pi user-space program.

      Arduino uses a subset of C++ but it's such a small subset that it might as well be C.

      I write this as someone who has been writing embedded C code and assembly (98% C) for the last 20 years, though I have also worked on a few C++ projects as well. Most of this was device drivers, Vx Works, bootloaders (U-Boot and custom), bare metal applications and SDKs (dealing with high speed networking, 1, 2.5, 5, 10, 25 and 40Gbps) and some Linux kernel work and Arduino. I've worked with a variety of different CPU architectures (Intel, MIPS, ARM, PowerPC and more) including one that ran a functional programming language natively in hardware (the processor was physically incapable of running C code).

      --
      This post is encrypted twice with ROT-13. Documenting or attempting to crack this encryption is illegal.
    8. Re:Arduino uses C++, Pi uses Linux by Anonymous Coward · · Score: 0

      > Just off the top of my head, a single template function instantiated with the same type arguments in two different compilation units produces two (identical) copies of the same code in the final executable.

      Get a better head.

      Failing that, get a better linker.

    9. Re:Arduino uses C++, Pi uses Linux by AaronW · · Score: 1

      I have worked in one such environment. While C++ was nice there was still a lot of work needed to make it work properly, though this was 20 years ago for a large 100K C++ driver for OS/2 that ran in kernel space. The main thing was to not go overboard with C++ features and for performance reasons to keep the class hierarchy short (non performance-critical code didn't have this issue). This seems to be the exception rather than the rule though. Other than that project, everything else I have dealt with was in C and I don't really consider Arduino C++.

      Properly written, the overhead from C++ was pretty minimal. The driver binary was around 1MB. The interesting part was that we had an equivalent driver for Windows NT written in C that was 360K lines of code with a significantly larger binary and the C code was much buggier and harder to work with. Compilers have improved significantly since that time but I recall that with the C++ code only one specific version of the compiler could be used, Watcom 10.0b as I recall. 10.0c, the updated version, could not be used.

      Implementing the assembly code to support C is trivial compared to the minimal code required to support C++.

      --
      This post is encrypted twice with ROT-13. Documenting or attempting to crack this encryption is illegal.
    10. Re:Arduino uses C++, Pi uses Linux by AaronW · · Score: 1

      Properly written C++ actually has fairly minimal overhead from my experience, though in this case you want to limit what features you use in C++ and how you use it. Like you say, though, it's easy to get carried away and get a lot of bloat.

      --
      This post is encrypted twice with ROT-13. Documenting or attempting to crack this encryption is illegal.
    11. Re:Arduino uses C++, Pi uses Linux by goose-incarnated · · Score: 1

      > Just off the top of my head, a single template function instantiated with the same type arguments in two different compilation units produces two (identical) copies of the same code in the final executable.

      Get a better head.

      Failing that, get a better linker.

      The linker can't help if the compiler in-lines the function, which it may choose to do regardless of programmer intention.

      --
      I'm a minority race. Save your vitriol for white people.
    12. Re:Arduino uses C++, Pi uses Linux by Lisandro · · Score: 1

      Agreed on all items. Another big selling point for C is that your code will likely run on all computer architectures out there with minimum modifications, and it is pretty much guaranteed to do so if you plan in advance about things like endianness.

    13. Re:Arduino uses C++, Pi uses Linux by TheRaven64 · · Score: 1

      128KB is only a problem for C++ if you want exceptions and RTTI (which you probably don't in an embedded system). Embedded also has the massive advantage of being closed-world. This means that you can turn on LTO, which helps with code size a lot (or, if your toolchain doesn't support LTO, do it the old-fashioned way and #include everything into a single file for compilation). Multiple template instances tends not to be a problem because even a fairly primitive linker will throw them away, the bigger problem with C++ is that you can end up with versions of a template being instantiated for different types, yet with the same code (e.g. an int and a float instantiation for a vector - there's no reason for them to be different because the vector doesn't perform arithmetic on the types and only cares about the sizes). Modern optimisers are getting pretty good at spotting that these are identical code and combining them into a single implementation, but they could do better.

      --
      I am TheRaven on Soylent News
    14. Re:Arduino uses C++, Pi uses Linux by TheRaven64 · · Score: 1

      The template function is marked as externally visible, so the inliner will only inline it if there's a very large chance that after inlining the cost of the inlined version will be less than the cost of a call (when optimising for size, not speed - the heuristic is a bit different in the latter case). In this case, you'll get smaller code if you inline it everywhere and the linker will then throw away the definition entirely.

      --
      I am TheRaven on Soylent News
    15. Re:Arduino uses C++, Pi uses Linux by TheRaven64 · · Score: 2

      Hardware registers can be defined by volatile bitfields so a simple pointer can be used to access them.

      Unless, of course, you have multiple registers with ordering constraints between them (e.g. write some data into one register, toggle a flag in another), because the volatile keyword in C does not give any guarantees of ordering between accesses to different volatile objects and the compiler is completely free to reorder the write to the flag before the write to the data.

      Things like interrupt handlers are fairly trivial to code in C.

      As long as someone else is writing the assembly code that preserves state for the interrupted context, prevents the interrupt handler from being interrupted, and so on, and then calls into the C code. And with those constraints, pretty much any compiled language is equivalent.

      One can do interesting things using the linker with C code that are not really possible with most other languages. For example, I can easily link my code to execute at a particular address and generate a binary without any elf headers or any other cruft and there are interesting things that can be done with linker scripts

      That's pretty much true for any compiled language.

      There is no unexpected overhead due to the language. There is no background garbage collection that can run at some inopportune time. There's no extra code to do bounds or pointer checking to slow down the code or even get in the way.

      The flip side of this is that you either do the bounds checking yourself (and often get it wrong, leading to security vulnerabilities) and end up passing it through a compiler that isn't designed to aggressively elide bounds checks that it can prove are not needed.

      Generally it is pretty easy to move between different versions of the toolchain. C generally doesn't change much.

      I can't tell from the Internet. Did you actually say that with a straight face? Even moving between different versions of the same C toolchain can cause C programs that depend on undefined or implementation-defined behaviour (i.e. basically all C programs - including yours given that several of the things that you listed in another post in this thread as really nice features of C are undefined behaviour, such as casting from a long to a pointer) are now optimised into something that doesn't do what the programmer intended.

      --
      I am TheRaven on Soylent News
    16. Re:Arduino uses C++, Pi uses Linux by Megane · · Score: 1

      I do want to use a better-C-than-C. C with classes just for the sake of structuring code more coherently. C with better type checking rules. C where I can release a semaphore on any exit from a function. A stripped down C++ that more resembles Cfront without all the newer fluff.

      That's the basic point of Embedded C++. (Actually, that's not true, the real point was that in the '90s, companies making C++ compilers were having trouble implementing things like templates, and EC++ was an attempt to give them more time.) But if you disable RTTI and exceptions in the compiler options, avoid using anything that loves to use memory allocation (bye, bye, STL) in favor of your own fixed-sized memory pools, completely ditch unnecessary I/O crap (iostreams, locales), use the leanest run-time libraries (no floats in printf, etc.), and avoid going nuts with templates, the resulting subset of C++ can be quite lean. It also isn't hard to mix with plain C code as long as you declare things extern "C" when necessary.

      It just so happens that mbed uses C++ this way, and it works quite well on small micro-controllers. The big thing that C++ does is to allow a class to be used as an API for a hardware device. All the details of a device's state are hidden inside its object, and similar hardware with different details can have a new class written for it with no changes to the code that uses it.

      --
      #naabhaprzrag, #sverubfr-000, #agi-fcbafberq, negvpyr[pynff*=' negvpyr-ary-'] { qvfcynl: abar !vzcbegnag; }
    17. Re:Arduino uses C++, Pi uses Linux by Anonymous Coward · · Score: 0

      Expections and RTTI are core parts of C++, if you disable them you are not actually using a compliant C++ compiler, so it would be reasonable to say you are NOT using C++.
      Plus, you also need to use memset instead of constructors (have a look at the code that gcc generates for an array of classes initialized via constructor vs. via memset to see what I mean).
      You also have to write code generators for any sparse lookup tables instead of just writing them (designated initializers to only initialize some elements don't exist in C++).
      You will also need at least C++11 because you'll absolutely need constexpr.
      Also don't use virtual functions, because the cost is likely to break your neck.
      Also better avoid templates, since most compilers will not be able to share the code parts that are not actually different between the different template variants, thus bloating your code size.
      Even on a desktop, remember to never use iostreams, because it will absolutely kill your performance for anything except absolutely rare prints (easily 10x slower than printf/scanf, which are already snails compared to a hand-written parser).
      For a lot of problems, the time you spend fighting your C++ compiler because of the bloat it adds in unexpected places will be more than you gain in productivity from using C++.

    18. Re:Arduino uses C++, Pi uses Linux by Darinbob · · Score: 1

      The problem I found with templates is that extra instantiations are *not* thrown away. They may be 99% the same but it doens't know that without actually comparing the code, and if it does know they're the same it is hard to keep that 1% difference and throw away the rest. You really need a C++ oriented linker with hins from the compiler, as opposed to a general purpose linker using name mangling (ie, binutils).

      For instance, a template instantiated with "unsigned int" will result in slightly different code than one for "unsigned long".

      In the past I have written templates that are nothing more than type casting wrappers around a basic type Ie, an collection of "void*" but then a template that lets you have a collection of any pointer type while still being strongly type checked.

    19. Re:Arduino uses C++, Pi uses Linux by Darinbob · · Score: 1

      This is essentially what "Embedded C++" is, it gets rid of the bloat or features that tend to bloat and then relies on programmer discipline after that. So not strictly C++, but highly compatible with it (and even more so with older C++ standards).

      RTTI really is extra fluff that probaby never should have been added, in my opinion (and I used C++ before it was there). It's a high level language feature, and C++ really does hurt itself by trying to simultaneously be a high level language and a low level language.

    20. Re:Arduino uses C++, Pi uses Linux by OrangeTide · · Score: 2

      I disagree, I think objects, templates and the static type system are core parts of C++. Exceptions and RTTI are nice features but not necessarily helpful to have in every C++ program.

      --
      “Common sense is not so common.” — Voltaire
    21. Re:Arduino uses C++, Pi uses Linux by Darinbob · · Score: 1

      Yup. Having been at a C house for some years now after having done C++ embedded systerms earlier, I am amazed at some of the early code had so little concept of encapsulation, functional coherency, extensibility, and so forth. Which is something you normally figure out very quickly in C++. Of course you can do this in C, but you need the experience on how to do it. In C++, once you have a class it's second nature to stick with that class when you have a newer variant of what you're interfacing with, maybe it's a subclass, maybe it's an interface class, but in C I see so many people just create a new API, throw in ifdefs, etc.

    22. Re:Arduino uses C++, Pi uses Linux by david_thornley · · Score: 1

      If the compiler inlines the same function in two different compilation units, you'll have two copies of the function. That's what inlining means. There's nothing special about a template function in this regard.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    23. Re:Arduino uses C++, Pi uses Linux by david_thornley · · Score: 1

      There's other reasons to keep inheritance trees short. Inheritance produces very close coupling between the classes involved, and if you're not actively taking advantage of inheritance (typically using polymorphism), don't use it.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    24. Re:Arduino uses C++, Pi uses Linux by AaronW · · Score: 1

      In this particular case it was taking advantage of polymorphism in the main data path of a network driver (ATM networking, LAN emulation). The inheritance tree was quite short and kept to a minimum. This was because it could emulate different types of networks. Overall I don't think there was any additional overhead from C++ vs the same functionality written in C which would have needed function pointers instead of virtual functions.

      --
      This post is encrypted twice with ROT-13. Documenting or attempting to crack this encryption is illegal.
    25. Re:Arduino uses C++, Pi uses Linux by AaronW · · Score: 1

      Hardware registers can be defined by volatile bitfields so a simple pointer can be used to access them.

      Unless, of course, you have multiple registers with ordering constraints between them (e.g. write some data into one register, toggle a flag in another), because the volatile keyword in C does not give any guarantees of ordering between accesses to different volatile objects and the compiler is completely free to reorder the write to the flag before the write to the data.

      That is what barriers are for to guarantee the ordering or the use of accessor functions. I'm not saying that volatile is a cure-all since it is not. It is a tool that needs to be understood. On many architectures one also needs to understand that a write to memory may not actually write to memory. For example, on MIPS a SYNC instruction is needed to flush the write buffer to guarantee that the data has been written to cache memory. On processors that are not cache coherent a cache flush is also required for data structures stored in memory that are accessed via DMA by hardware and a cache invalidate is needed before the hardware updates the memory before the CPU can read it.

      Things like interrupt handlers are fairly trivial to code in C.

      As long as someone else is writing the assembly code that preserves state for the interrupted context, prevents the interrupt handler from being interrupted, and so on, and then calls into the C code. And with those constraints, pretty much any compiled language is equivalent.

      In C the context is usually fairly small compared to many other languages.

      One can do interesting things using the linker with C code that are not really possible with most other languages. For example, I can easily link my code to execute at a particular address and generate a binary without any elf headers or any other cruft and there are interesting things that can be done with linker scripts

      That's pretty much true for any compiled language.

      Not really. Many compiled languages need a lot of support to handle things like memory management which C does not.

      There is no unexpected overhead due to the language. There is no background garbage collection that can run at some inopportune time. There's no extra code to do bounds or pointer checking to slow down the code or even get in the way.

      The flip side of this is that you either do the bounds checking yourself (and often get it wrong, leading to security vulnerabilities) and end up passing it through a compiler that isn't designed to aggressively elide bounds checks that it can prove are not needed.

      Languages that do bounds checking and other hand holding generally don't work well on bare metal and in low-level (i.e. device drivers) environments. If you're relying on the language to catch your bugs then you have no business writing code in this sort of an environment. In this sort of environment a pointer often needs to be a pointer with no hand holding or the compiler or runtime trying to second guess the programmer. Compilers and languages do not understand hardware.

      Generally it is pretty easy to move between different versions of the toolchain. C generally doesn't change much.

      I can't tell from the Internet. Did you actually say that with a straight face? Even moving between different versions of the same C toolchain can cause C programs that depend on undefined or implementation-defined behaviour (i.e. basically all C programs - including yours given that several of the things that you listed in another post in this thread as really nice features of C are undefined behaviour, such as casting from a long to a pointer) are now optimised into something that doesn't do what the programmer intended.

      Yes I did and on

      --
      This post is encrypted twice with ROT-13. Documenting or attempting to crack this encryption is illegal.
    26. Re:Arduino uses C++, Pi uses Linux by jon3k · · Score: 1

      These days I spend my energy attacking Python instead.

      What's with all the python hate lately?

    27. Re:Arduino uses C++, Pi uses Linux by david_thornley · · Score: 1

      Sounds to me like good C++ style.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
  6. They said the same about mobile by lucasnate1 · · Score: 3, Interesting

    I heard this said before about phones, but eventually technology developed enough to allow mobile devices to have a strong enough processor. People are already too used to program higher-level and I see no reason why the same environments we have in our phones can't run on our fridges or boilers or ovens, therefore I do not think that people will use C.

    1. Re:They said the same about mobile by MightyMartian · · Score: 1

      Someone at some level is going to be using C, even on smartphones and IoT devices. Yes, writing apps doubtless will be done in higher-level languages, but there's going to be someone working in C, at the very least writing drivers for a minimalistic Linux environment.

      --
      The world's burning. Moped Jesus spotted on I50. Details at 11.
    2. Re:They said the same about mobile by lucasnate1 · · Score: 1

      Summary said:

      For traditional workloads there is no need to be counting the bytes like there used to be. But when it comes to IoT applications there is that need once again...

      Writing drivers and infrastructure is normal C use, why would it cause the so-called "spike" that the summary refers to?

    3. Re: They said the same about mobile by Bing+Tsher+E · · Score: 3, Interesting

      With low cost IoT designs, memory is sometimes measured in bytes. I have coded processors with only 16 bytes of data memory.

    4. Re:They said the same about mobile by JanneM · · Score: 3, Informative

      The high-level VMs and the drivers to drive the specific hardware isn't developed by magical Low-Level Elves in Happy Rainbow Fairly Land. Every IoT device is going to have their oen special hardware stuff, and somebody needs to write the low-level code to interface with it. That is done in a combination of C and assembler.

      Also, at volume the price difference between a MCU that can run a VM and one that can not will be on the order of tens of cents (either currency). If you plan to make on the order of a million devices, then 20 cents per unit will more than pay for a programmer that knows to use the small MCU over a Java hack that does not.

      --
      Trust the Computer. The Computer is your friend.
    5. Re:They said the same about mobile by Darinbob · · Score: 1

      What do you think the higher level languages are written in, or the operating system on those phones? The high level stuff is for the frigging apps writers, not for the engineers building the device. The apps aren't written in C and the radio layer isn't written in Java.

    6. Re:They said the same about mobile by phantomfive · · Score: 1

      I see no reason why the same environments we have in our phones can't run on our fridges or boilers or ovens, therefore I do not think that people will use C.

      Because CPUs aren't really getting faster anymore, and no one wants to pay an extra $60 for a microwave just so the company could get away with hiring a cheaper programmer.
      I hope I'm wrong and you're right, I would love a ~20GHZ processor in my microwave because it was cheap enough.

      --
      "First they came for the slanderers and i said nothing."
    7. Re:They said the same about mobile by LordWabbit2 · · Score: 1
      but eventually technology developed enough

      Yes eventually it did.
      If you want to connect every lightbulb in a big building to the IoT it's going to cost a fuckton to do it on hardware which can run higher level languages. A small $1 6bit chip with 1k of RAM and things get a bit more affordable. There is definitely a need for C in the emerging IoT market, I agree it may change as per Moores Law, but it's not there yet, and may not be for a while.

      --
      There are three kinds of falsehood: the first is a 'fib,' the second is a downright lie, and the third is statistics.
    8. Re:They said the same about mobile by TheRaven64 · · Score: 1

      Most of the Android runtime is written in C++, as is most of Apple's Objective-C runtime. Microsoft had a project to turn Singularity into a product (which, sadly, was cancelled before completion) where the implemented their entire .NET runtime and OS in C#. The Jikes RVM is written mostly in Java - specifically, the JIT compiler and garbage collector are both Java. The Squeak Smalltalk VM (and descendants such as Pharo) are written in Smalltalk, with a small core that is statically compiled and the rest then running on this bootstrap subset.

      --
      I am TheRaven on Soylent News
    9. Re: They said the same about mobile by adam.voss · · Score: 1

      I have coded processors with only 16 bytes of data memory.

      Honestly curious, what did you use it for?

    10. Re:They said the same about mobile by Darinbob · · Score: 1

      Well, C++ is essentially C, especially the part of it that is low level. And Android has C in the kernel, which is Linux. The point was at the bottom of it all is almost always C.

      Squeak primitives are written in an extreme subset of Smalltalk that translates directly to C, much of this just for the practical ability to debug it while building Squeak from scratch. After the fact though it's possible to do Squeak totally in Squeak, once you have an assembler. And this brings up one very common reason for C being at the bottom of so many things - it's the most common portable way to do very low level code. In other words, C acts like a portable assembler. Squeak wants to be portable, so it's easier to have the primitives in C rather than port them every time you move to a new machine. Sure, Rust can do this, but it's essentially brand new.

  7. Meh by Anonymous Coward · · Score: 0

    MIPS ASM or GTFO

    1. Re:Meh by ClickOnThis · · Score: 1

      MIPS ASM or GTFO

      Grandpa, get off Slashdot. It's time for your Metamucil.

      --
      If it weren't for deadlines, nothing would be late.
    2. Re: Meh by Anonymous Coward · · Score: 0

      IoT is on ARM (nordic) or 8051 (ti) anyway!

    3. Re:Meh by Anonymous Coward · · Score: 0

      Grandpa, get off Slashdot. It's time for your Metamucil.

      Spoken by someone who probably thinks javascript is an awesome language.

    4. Re:Meh by ClickOnThis · · Score: 1

      Grandpa, get off Slashdot. It's time for your Metamucil.

      Spoken by someone who probably thinks javascript is an awesome language.

      Actually, no I don't. But it does have some awesome libraries, like d3.

      --
      If it weren't for deadlines, nothing would be late.
    5. Re:Meh by AaronW · · Score: 1

      I love MIPS assembly. I actually have a page of MIPS assembly open at this very moment. In terms of programming, it's beautifully designed. The extension from 32-bit to 64-bit is pretty seamless. The only real gotchas are the branch delay slots, but I actually find it to be a nice challenge to fill those slots. (I always have .set noreorder set).

      MIPS assembly is extremely clean, far cleaner than ARM, for example, and the online documentation is superb. I like the MIPS Architecture for Programmers Volume II. Volumes 1 and 3 are also useful. I have yet to find as clean of a document covering ARMv8.

      Even the MIPS instruction encoding is quite clean and the CPU design makes it easy for vendors to add their own interesting instructions to coprocessor 2. For example, my employer has a bunch of encryption and hashing related instructions added there. ARM does not allow you to add your own custom instructions to ARMv8, for example.

      MIPS is still used in many Internet appliances and home routers, though things are quickly moving to ARM. One advantage of the MIPS instruction is it very cleanly moved from 32-bits to 64 bits. With ARM that is not the case. AARCH64 is very different than 32-bit ARM. The differences are bigger IMO than the switch from X86 to X86_64. Another advantage of MIPS is that the licensing costs are quite a bit lower than for ARM.

      --
      This post is encrypted twice with ROT-13. Documenting or attempting to crack this encryption is illegal.
    6. Re:Meh by TheRaven64 · · Score: 1

      I love MIPS assembly.

      Really? Branch delay slots (with 'unpredictable' behaviour if you put a branch in them), no complex addressing modes, weird instruction names (an unsigned add is the same as a signed add, except one will trap on overflow, because that's obviously what the difference between signed and unsigned means), special $hi and $lo registers because some instructions have an implicit destination. Half-arsed transition from a fixed-design pipeline so that some operations have hardware interlocks but some need some magic (and implementation-dependent) number of NOPs to work. Oh, and my favourite bit of MIPS, the superscalar NOP. When your ISA has a superscalar NOP, that's when you should realise that you've done something badly wrong.

      In terms of programming, it's beautifully designed.

      If you ever have to write ARM assembly, your head might explode if you think MIPS is beautifully designed.

      The extension from 32-bit to 64-bit is pretty seamless.

      The 'oh, by the way, if you don't sign-extend into the top 32 bits then you get undefined behaviour for any 32-bit arithmetic operation' thing is seamless? So any code that has to deal with 32-bit values ends up doing a left-shift by zero instruction (which makes the code totally readable - 'Hey, this looks like a nop, can we remove it?' 'no, it looks like a job, but we'll get garbage values if we remove it') at multiple points to enforce this invariant.

      Even the MIPS instruction encoding is quite clean and the CPU design makes it easy for vendors to add their own interesting instructions to coprocessor 2. For example, my employer has a bunch of encryption and hashing related instructions added there. ARM does not allow you to add your own custom instructions to ARMv8, for example.

      I'm guessing your employer is Cavium? Thank $DEITY that they're starting to produce decent ARMv8 chips and we can kill off support for their MIPS products in a few years. You might see this as a strength of MIPS, but to everyone else it's a massive weakness. Every MIPS vendor takes a version of GCC, hacks it up to support their extensions, and breaks support for other extensions in the meantime. They then can't get their patches upstreamed (the few that even try) and so their customers end up with an unmaintained dead-end fork. Worst ecosystem ever.

      One advantage of the MIPS instruction is it very cleanly moved from 32-bits to 64 bits. With ARM that is not the case. AARCH64 is very different than 32-bit ARM.

      I think that you and I have very different definitions of clean. MIPS quickly hacked on a 64-bit extension without thinking it through, AArch64 was the result of careful study of the intersection between code sequences that compilers like to generate and instructions that are efficient to implement. For example, a lot of the predication (really useful for assembly programmers, hard to implement in superscalar pipelines, hard to use for compilers) is gone, the user-addressable PC is gone (makes branch-prediction really hard on in-order pipelines) and so is store/load multiple (basically needs microcode). You keep all of the really useful bitfield manipulation instructions (no MIPS equivalent, and oh how I miss them when I have to deal with MIPS, which sadly I do on a regular basis), store and load pairs (including atomics on pairs) and so on.

      Oh, and MIPSr6 is not backwards binary compatible with previous versions. All of the branch-likely opcodes were recycled as compact branch (no delay slot), you you need to patch your binaries if you want them to work.

      --
      I am TheRaven on Soylent News
    7. Re:Meh by AaronW · · Score: 1

      My definition of clean is that you don't have to completely re-write assembly code when moving from 32-bit to 64-bit. On many other architectures, i.e. AArch64/X86_64 you do.

      I'm not saying that MIPS is perfect. I'm not saying that there's anything wrong with AARCH64, but that it is radically different than 32-bit ARM, and I agree, the changes were very badly needed for the reasons you specify. In no way can you say that the transition from ARM32 to AARCH64 is clean, however. The code needs to be completely rewritten.

      As for GCC extensions, to the best of my knowledge all of the Cavium MIPS extensions have been upstreamed and have been for quite some time. Unlike most MIPS vendors we actually have a sizeable compiler and toolchain team which has also been very active with AARCH64.

      As for bitfield manipulation instructions they are there. Look up the ins (insert), ext (extract), bbit1 (branch if bit 1) and bbit0 (branch if bit 0) instructions. I use them extensively in my code. I know AARCH64 has similar instructions that are even more powerful.

      Cavium actually had to teach ARM about atomic instructions, hence their addition in ARMv8.1 because the load linked/store conditional instructions don't scale. As far as I know we're still trying to get ARM to add transactional memory support (something we support in our MIPS chips) which is better than atomics on pairs. A big reason why they have the atomic instructions was because Cavium pushed hard for them because of our experience with chips with a large number of cores and scaling.

      Also, the branch likely instructions had been deprecated for a very long time. Patching a binary is actually pretty trivial since the instructions just need to be replaced with the non-likely equivalent.

      As for your hi/lo registers, that was done because the result exceeds what could be held in a single register. There's always the mul/dmul instructions introduced in MIPSv6 which does not use the hi/lo registers when you don't care about overflowing the target register. The hi/lo come mostly from the 32-bit days in order to handle a 64-bit result and the effect it had on the pipeline.

      --
      This post is encrypted twice with ROT-13. Documenting or attempting to crack this encryption is illegal.
  8. Nope by Opportunist · · Score: 2

    IoT is a reason to learn a few things about IT security. Whether you plan to develop in the field or go into consulting, IoT means total job security in the IT-Security field for the foreseeable future.

    Quite frankly, if you thought Microsoft is keeping security busy, just wait 'til IoT makes it big into the office space. You're looking at security holes and blunders you can't even imagine today! And every single of them are a sweet, sweet, 4 to 5 digit consulting gig!

    --
    We used to have a Bill of Rights. Now, with the rights gone, all we have left is the bill.
    1. Re:Nope by CaptainDork · · Score: 1

      I think market pressures will fix the security problems, pretty quickly as IoT becomes ubiquitous.

      Recall Apple's and Microsoft's ongoing fight for security.

      --
      It little behooves the best of us to comment on the rest of us.
    2. Re:Nope by Opportunist · · Score: 2

      Look at the mess internet capable TVs are. Then ponder your statement again.

      Most "smart" TVs are horribly insecure. Did that cause an outcry? Nope. And as long as those TVs will just participate in a DDoS while still allowing Netflix to be shown, nobody will give a shit.

      Security is not a marketable feature. Nobody gives a shit about security unless it affects him directly. And since IoT devices are mostly used for DDoS blackmail right now, this doesn't even register with the average user.

      --
      We used to have a Bill of Rights. Now, with the rights gone, all we have left is the bill.
    3. Re:Nope by JaredOfEuropa · · Score: 1

      Good one. IT security already seems to be a fairly in-demand skill, combined with the worries over IoT you'll be set for the foreseeable future.

      But what is IoT? Home automation? Smart appliances? Industrial sensor networks? Inercommunicating cars? What? For now I'll think of IoT as "Any networked stuff, other than servers, workstations or network equipment"

      --
      If construction was anything like programming, an incorrectly fitted lock would bring down the entire building...
    4. Re:Nope by Anonymous Coward · · Score: 0

      Opportunist is right, IOT is going to be an IT security workers bonanza, who knows it may get so bad that plain old switches may start including per port firewalls on top of all the other goodies like vlans.

      It could be a near perfect collection of negatives, market pressures driving products to a price point, weak or non existing standards let alone security standards, poor corporate accountability when products are dumped in foreign markets, short product life cycles to drive forward sales, planned obsolescence, and so much more.

      Perhaps some time in the future a framework/platform/standards will catch up to the boom, but if it takes as long as every other market to become even somewhat secure then its going to be a wild ride.

    5. Re:Nope by Opportunist · · Score: 1

      All that and more. In the consumer environment you're looking at home automation and various gadgets, while companies will certainly want to automatize facility management, physical security and power saving features like lamps that turn on and off depending on where people are, far more accurately than this happens today with simple motion detectors.

      There's plenty of room for IoT devices, and all of them are horribly insecure. I'm looking at a very bright future.

      --
      We used to have a Bill of Rights. Now, with the rights gone, all we have left is the bill.
    6. Re:Nope by Anonymous Coward · · Score: 0

      Industrial sensor networks?

      Industrial IoT is where it makes the most sense and the only area where I take it seriously. It's also a lot more appreciative of security than the commercial and residential "toys" are. IIoT and Industrial Cybersecurity are the only reasons why I am looking to go back into IT after retiring from regular IT several years ago to become a Instrumentation and Controls Engineer. A lot of my old IT knowledge followed me here so this is becoming something of a natural progression.

      I've also been using an Arduino to get back into programming lately and planning to purchase some cheap PLCs soon. It's actually rather fun working on something where I have to again be aware of how much memory I can use and needing to write reliable, fast executing algorithms to handle a lot of simultaneous I/O.

    7. Re:Nope by CaptainDork · · Score: 1

      DDoS blackmail isn't a thing, though some do fall for the scam:

      Given that the attackers can't tell who has paid the extortion fee and who has not, it is perhaps not surprising to learn that they appear to treat all victims the same: attacking none of them. To date, we've not seen a single attack launched against a threatened organization. This is in spite of nearly all of the threatened organizations we're aware of not paying the extortion fee. We've compared notes with fellow DDoS mitigation vendors and none of them have seen any attacks launched since March against organizations that have received Armada Collective threats.

      --
      It little behooves the best of us to comment on the rest of us.
    8. Re:Nope by phantomfive · · Score: 1

      And every single of them are a sweet, sweet, 4 to 5 digit consulting gig!

      That sounds low......I assume that's not per year. How long would each one of those gigs last?

      --
      "First they came for the slanderers and i said nothing."
    9. Re:Nope by Opportunist · · Score: 1

      We're talking a few days to maybe a month. That month could maybe hit the 6 digits, actually, if you want something or someone special.

      --
      We used to have a Bill of Rights. Now, with the rights gone, all we have left is the bill.
    10. Re:Nope by phantomfive · · Score: 1

      That sounds really amazing. Assuming one already has deep knowledge of software security, how does one get into that business?

      --
      "First they came for the slanderers and i said nothing."
    11. Re:Nope by Opportunist · · Score: 1

      Many companies in that field are currently hiring, and it's fairly easy to get a job at one of them (though, as you may imagine, they don't pay 10 grand a day, they keep that part for themselves and pay you way less instead...).

      Freelancing is something you could start doing when you managed to make yourself known in the field. There's some ways you can accomplish that, first of course by working for a security consulting company and making yourself known to customers who then want you to work for them. You can of course try to become one of the few household names when it comes to IT security, though this is a tough road and you should be VERY good for this to fly. Few can do that.

      As you can imagine, in this field a lot hangs on trust. Why would I trust you to not only be good but also to not backstab me? It takes a while to build a reputation, your best bet for that is to rely on the trust companies have in established security firms (whether that trust is well placed is often debatable, I know...).

      --
      We used to have a Bill of Rights. Now, with the rights gone, all we have left is the bill.
    12. Re:Nope by phantomfive · · Score: 1

      What company is doing a good job in that field right now? I've seem enough security companies that are just hucksters, it's hard to find a good one.

      --
      "First they came for the slanderers and i said nothing."
  9. Android Things by Niris · · Score: 1

    Android Things uses Java, and I'm sure other devices will use different languages (python, or something else that comes along). C is a nice to understand kind of language if you want to move libraries for Arduino to other platforms, but understanding any similar language will make that trivial.

    1. Re:Android Things by Z80a · · Score: 1

      Android you can and generally do use the NDK thing, that allows you to create native C compiled libraries to get a really, really nice boost of speed.

  10. Re:A damn good reason to learn security best pract by Opportunist · · Score: 2

    The language that pretty much invented to buffer overflow? Yeeeah, I think you might be right.

    --
    We used to have a Bill of Rights. Now, with the rights gone, all we have left is the bill.
  11. Who is making your IoT device? by AHuxley · · Score: 1

    If its imported as a product what code is going to be done? Branding over some device ready GUI?
    Thats more an art skill for a web app?
    Making your own IoT device in the USA? Whats trendy in 2017 for low level design work?
    A US design team with the needed skills will work on that.
    If the kit is sold, most of the work has been done.
    If your making your own kit, you have the skills or paying a very smart person with the skills.

    --
    Domestic spying is now "Benign Information Gathering"
  12. To C or not to C ... by CaptainDork · · Score: 1

    ... that is the question.

    --
    It little behooves the best of us to comment on the rest of us.
    1. Re:To C or not to C ... by ClickOnThis · · Score: 1

      To C or not to C ... that is the question.

      And the answer would be true, regardless of the value of C. ;-P

      --
      If it weren't for deadlines, nothing would be late.
  13. No ... by CaptainDork · · Score: 1

    ... use BASIC:

    10 get foxnews.com
    20 refresh
    30 goto 10

    --
    It little behooves the best of us to comment on the rest of us.
    1. Re:No ... by Z80a · · Score: 1

      Basic can't do that by its own, But i bet if you add some magical pokes it do.

    2. Re:No ... by CaptainDork · · Score: 1

      We're old and stuff.

      --
      It little behooves the best of us to comment on the rest of us.
    3. Re:No ... by Anonymous Coward · · Score: 0

      On a ZX Spectrum you need to splice in a rand usr 50006.

  14. Learn Swift by SuperKendall · · Score: 3, Interesting

    Swift is a language well-suited to byte counting, if that is a need - at this point because of the tremendous pressure to increase security on iOT devices I really think Swift could have massive uptake.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
    1. Re:Learn Swift by Anonymous Coward · · Score: 0

      You're thinking of an entirely different level of device. What's being discussed here are platforms that need features SWIFT simply doesn't have, like inline assembler to manipulate hardware specific features, manual allocation schemes for shared memory (EG reserved blocks that are processed by hardware interrupts), custom runtimes [CRT], etc. To use SWIFT you'd need to develop entirely different custom libraries for each platform - but you'd never be able to use them because those custom libraries and the runtime for SWIFT alone would be too big and bulky to even be loaded on the target.

    2. Re:Learn Swift by Anonymous Coward · · Score: 0

      I don't think so. I think Rust is clearly superior, as do most other people. After all, Rust has the security and performance edge, and more people looking through the code, versus the proprietary nature of Swift. Plus, there's real community with Rust, not like that privileged white people clique you get with Swift or C++.

    3. Re:Learn Swift by Anonymous Coward · · Score: 0

      In the past I've found it much easier to use the Nim programming language with the --gc:none setting to disable the garbage collector. Better language, higher order features (macros) and straight down to C with manual memory allocation if needed.

    4. Re:Learn Swift by Lisandro · · Score: 1

      I liked Go much better, in the sense that it compiles to actual binaries. The main problem with both languages though is that they're limited to a small number of OSs/architectures.

  15. Rust? by Anonymous Coward · · Score: 0

    Or another reason to learn Rust?

    It seems to be the best positioned alternative systems language at the moment.

    1. Re:Rust? by Anonymous Coward · · Score: 0

      Exactly. It is the best positioned and best designed language for the task. We need to get rid of these archaic languages like C which cause buffer overflows and serious security issues. That's why I teach my students Rust. The more people start using Rust, the sooner we can solve these types of problems, from security, performance to white privilege.

  16. Sigh by Waffle+Iron · · Score: 1

    In an ideal world, developers of this newly emerging industry would try to avoid the mistakes of the past. They would gravitate towards one of the "safer" low-level languages such as Rust or Ada instead of C.

    Of course, from the news headlines it seems that IoT developers are already intent on recreating every bad security practice that's been described since the Morris Worm. So I'm not holding my breath.

    1. Re:Sigh by Anonymous Coward · · Score: 0

      In an ideal world, developers of this newly emerging industry would try to avoid the mistakes of the past. They would gravitate towards one of the "safer" low-level languages such as Rust or Ada instead of C.

      Of course, from the news headlines it seems that IoT developers are already intent on recreating every bad security practice that's been described since the Morris Worm. So I'm not holding my breath.

      I work in the automotive industry, and I really like Ada, actually (although, I have never had to ship production Ada, so take that with a grain of salt. Unfortunately, here in Detroit, there is a metric boat-ton of people who can (and will) write C code. Getting people who can (or will) write Ada is much harder. Basically, we stick with C because we have multiple generations of engineers who know it very well. It's like sticking with imperial units. Sure, there would be benefits to a change, but it's a lot of work to make the change.

    2. Re:Sigh by cpghost · · Score: 1
      Concerning Rust, it still has to be seen if it is not just yet another fad of the year. We've seen programming languages come and go in the last couple of decades, and the sheer inertia of the C/C++ code-base and programmer-base would make me very skeptical w.r.t. any new languages, including Rust (not that I dislike it, far from that).

      As to Ada... I've coded in Ada too back then, and I know of some big code-bases that are rock solid in Ada. Unfortunately, there is a severe shortage of Ada programmers who are willing to maintain those code-bases, so what happens is that a lot of money is being thrown at converting all that Ada code to C++ code, using semi-automated tools where possible. This auto-generated C++ code is then manually re-validated by C++ hackers (and that's what is so costly), and from here on, it will persist as C++ code, maybe for decades.

      That's the way it goes. A language may have merits of its own, but if it is not popular and if you can't get enough people to maintain your sizeable code-bases, that language is ultimately of no use. C++ seems like a good compromise between openness, royalties/patent-lessness, speed, type safety, maintainability (when done right!), and long-term maintainability through coders. Despite its known shortcomings. No Rust, not even Ada can beat that.

      --
      cpghost at Cordula's Web.
  17. Better options by snadrus · · Score: 1

    Rust does anything in any space C can, but more safely.
    Light IoT will always need languages that are very power cautious, but I see that bringing a rise of CUDA IoT, or even FPGA skills.

    Heavy IoT will always be flavor-of-the-month.

    --
    Science & open-source build trust from peer review. Learn systems you can trust.
    1. Re:Better options by Anonymous Coward · · Score: 0

      Rust does anything it does, poorly and buggily. Not great for IoT or anything else, really.

    2. Re:Better options by AaronW · · Score: 1

      BS.

      Rust handles things like low-level bare metal poorly. What happens when you don't have a nice operating system underneath you? What happens when you're dealing with bitfields and memory mapped hardware registers? C is very well designed for this, and even has a keyword, volatile, for just such occurrences. Rust hand-holding becomes a major hinderance and gets in the way. C is very efficient with minimal language overhead. I can have C code running from the reset vector with only a page or two of assembly code on the 64-bit MIPS processors I deal with, and that includes stack. The output from the compiler with the right optimization features rivals hand tuned assembly and often beats it in terms of space requirements. C doesn't require any external libraries. I've written plenty of bare metal bootloaders in C with minimal assembly that do an incredible amount of stuff with very limited memory.

      I have a bootloader that includes drivers for SD cards, embedded MMC (managed flash memory chips frequently found on embedded devices, phones and tablets), FAT filesystem support (FAT16 and FAT32), partitioning support and serial drivers in under 8K, and this is for a 64-bit 48-core network processor running in 64-bit mode that happens to run Linux.

      There are a lot of things C can do that Rust cannot, and in many cases, the safety and hand holding of Rust just gets in the way. I need pointers to specific memory addresses, for example, and I don't want bounds checking or thread support.

      Try writing an interrupt handler in Rust. Good luck with that.

      --
      This post is encrypted twice with ROT-13. Documenting or attempting to crack this encryption is illegal.
    3. Re:Better options by Lisandro · · Score: 1

      Go is very nice and should be considered. It is a very terse, non-expressive language much like C is, but it was born with concurrency in mind and produces fast, small binaries. The problem is that is not available on such a wide number of architectures as C is.

    4. Re: Better options by snadrus · · Score: 1

      As a Go developer by day, I would like this to be an option too, but it will take significant rework on minimizing libraries and the runtime in order to fit on extremely low size installations.

      Go runtime also requires an operating system. I'm very interested in removing this restriction, but it's there today.

      --
      Science & open-source build trust from peer review. Learn systems you can trust.
    5. Re:Better options by prunus.avium · · Score: 1

      As much as Go is "compiled" it cheats. There is a runtime in there which handles all of the memory management stuff it just gets linked in to the executable. Check out the size of the "Hello world!" in Go vs. C and you can see the difference.

    6. Re:Better options by Lisandro · · Score: 1

      Go 1.7 greatly improves on this, but yes, it is an issue - a simple hello world clocks at around 1.5Mb. Having said that, it is way better than the footprint for other interpreted/bytecoded languages.

    7. Re:Better options by prunus.avium · · Score: 1

      I actually like Go. And as run-times go, Go has a very nice one. I was simply pointing out that it still has a run-time so it can't really be used as a low level language where direct manipulation of the hardware is required.

      Of course, the whole IoT argument brings up some interesting discussions as it shows what people think IoT is and should be.

      Coming form an embedded side, IoT is small, specialized hardware that has a network connection bolted on to the side. In this case, we need C and assembler. Managed languages can't do bare hardware.

      Coming from a web services side, IoT is just another computer on the network. This would mean that we can create the web service in any of the high level languages and we don't care what's under the hood.

      Both sides are kind of correct based on their assumptions. Personally, I'm an embedded guy. C is needed to get the hardware up...and then we can start whatever run-time we can fit in the left over memory. :-)

  18. Re:A damn good reason to learn security best pract by bug1 · · Score: 4, Interesting

    C was invented as portable assembly IIRC. If you cant sort out a buffer overflow then dont call yourself a programmer.

    Real programmers see their job as making the computers job easy, not the other way around.

  19. Learn C for advanced security, not for basics by raymorris · · Score: 5, Interesting

    Career network security programmer here.

    Absolutely of you're programming a device that connects to the internet, you should understand a bit about security and have a security mindset. If your device won't get regular updates, this is even more true.

    Where does C fit in? It's unnecessary, if you just want to learn basic security best practices.

    If you want to really understand how exploits work, and some advanced protections, you need to understand how your program and your data are arranged in memory, what actually happens in the hardware to when your asynchronous timer goes off, etc. For that, C is the language to learn. Java programmers know how to use Java. C programmers know how Java works, internally. The bad guys writing exploits are (typically) C programmers, they can defeat your PHP or Python program because they know how PHP and Python work internally.

    You've always used languages with automatic garbage collection, so you mostly don't have to worry about freeing memory after you use it? Great. You don't know how and when memory is freed, and what happens when a hacker exploits a "use after free" to execute code that he's put into the variable you think no longer exists.

    To be clear, I'm not saying that people need to *use* C to write secure software. I'm saying that if you *learn* C, you'll learn a lot that applies to advanced security knowledge in any language. Higher level languages are most commonly written in C; if you know how things are done in C you'll understand what your high-level language is doing behind the scenes. You'll understand your Ruby software much better if you understand how the same program works in C.

    1. Re: Learn C for advanced security, not for basics by Anonymous Coward · · Score: 1

      You have never written code that initiates from a reset vector, so you comments do not belong here.

    2. Re:Learn C for advanced security, not for basics by Anonymous Coward · · Score: 0

      I agree but the IoT is intrinsically insecure. Which makes debating any sort of security debates, putting the cart before the horse. C doesn't exactly have a tracke record for being secure either, not because of C but because of people. Java and Python aren't typically used as hacking languages because they require an interpreter. A C binary is one package. Most server attacks aren't implemented in C.

    3. Re:Learn C for advanced security, not for basics by shoor · · Score: 1

      I learned C after I learned assembly language. As a matter of fact, when I was reading the C programming language book, I would write sample programs, compile them (what was it, the -S option? Been so long) and look at the assembly language output to figure out what was going on. (The architecture I was doing this on was the Motorola 68000.)

      Now, using a lot of C, people will probably get familiar with how pointers work, gain experience with malloc and free, and a bit of longjump would help also, even if they don't know assembler. But I think they'd catch on to the concepts a lot sooner if they had a dash of assembler to go with it. Particularly with experience writing a few interrupt service routines thrown in for good measure.

      Also, they wouldn't go around showing off their ignorance by saying C is an 'advanced' or 'universal' assembly language.

      --
      In theory, theory and practice are the same; in practice they're different. (Yogi Berra & A. Einstein)
    4. Re: Learn C for advanced security, not for basics by AaronW · · Score: 4, Interesting

      I agree. I write bootloaders for multi-core 64-bit processors. I've mostly been working on MIPS. C is very easy to get running. In one of my bootloaders which boots off of a SD card or eMMC chip all of the assembly code fits inside the 512-byte boot sector, and that includes the partition table and some UART functions because I had extra space. Most code is written in C. The C compiler does close to hand-tuned assembly code in terms of code density and the compiler often makes decisions that only a well seasoned assembly programmer would think of. C code provides a lot of flexibility but it also keeps the overhead to a minimum. You know exactly what the code will do. There is no hidden garbage collection or anything else. A pointer is just that, an actual address. You can easily convert them to an unsigned long or other numerical representation. You can also easily do things like have bitfields that map directly to hardware registers.

      On the processors I work with we have scripts that parse the hardware design and generate bitfields and addresses for all of the hardware registers (and there are many thousands of them on the chips I work with). C is the language to use when you want to get down and dirty with the hardware. On top of that, with gcc and many other compilers it is easy to incorporate inline assembly where needed since there are instructions and things that the compiler will not know how to properly deal with. It's also easy to call C code from assembly or assembly code from C.

      Working down at the hardware level you have to know what the language is doing and C does this very well and has all the constructs to do this. For example, the volatile keyword is perfect for mapping a pointer to a memory-mapped hardware register since that tells the compiler that the value can change at any time and not to cache it.

      That's not to say that other languages can't also be used. At one point I worked on a large (100K lines of code) kernel-level device driver that was written almost entirely in C++. There was a huge amount of work that was needed to make it work. The drawback was that only one particular version of the Watcom compiler could be used. It had to be 10.1b (I don't remember the exact version but it was 10 something b). Revision C could not be used. There was all sorts of magic that had to be implemented in order to support some of the memory magic that went on due to C++. This was also before exceptions. While the driver worked great and was easy to maintain once all the magic had been implemented, it also required a lot more skill to work with compared to C since one had to know all the caveats involved.

      From my initial reading of Rust, it would have major problems due to the way it deals with pointers. If the language is holding your hand to be "memory safe" then there's a good chance it won't work well when dealing with low-level stuff.

      Another advantage of C is that there is minimal overhead. C isn't going to do crap behind the scenes. If you assign an array it's just a block of indexed memory with minimal overhead.

      Things like pointer arithmetic and typecasting are extremely useful. I can't count the number of times I need to map between a pointer and a unsigned long (or unsigned long long) and it's easy to switch between them.

      Features like the volatile keyword in C are extremely useful, and most higher-level languages don't support that (C++ does). Java and C# have the keyword but it doesn't mean the same thing. In C one can also implement things like read and write barriers which are needed for drivers that talk to the hardware.

      --
      This post is encrypted twice with ROT-13. Documenting or attempting to crack this encryption is illegal.
    5. Re: Learn C for advanced security, not for basics by DrXym · · Score: 1

      From my initial reading of Rust, it would have major problems due to the way it deals with pointers. If the language is holding your hand to be "memory safe" then there's a good chance it won't work well when dealing with low-level stuff.

      Rust has an explicit "unsafe" keyword which allows you to write a block that does pretty much any dangerous operation including pointer manipulation if you so wish. If you had to set a value into memory, or set or get a pointer from a lib written in C then you can do that.

      The benefit is that the rest of your code (i.e. outside the unsafe block) is checked by the compiler and things like lifetimes, borrowing etc. are enforced. It's very hard to leak memory or forget to close a file because everything is managed by its lifetime and all resources are RAII style. It's also very hard to break a Rust program in an undefined way. The only way I'm aware of is a stack overflow past the guard page on platforms which don't support stack probes. Otherwise at the very least you'll get a panic and a stack unwind / program halt in a controlled fashion.

    6. Re:Learn C for advanced security, not for basics by Anonymous Coward · · Score: 0

      this comment should be modded to +10

    7. Re: Learn C for advanced security, not for basics by Anonymous Coward · · Score: 0

      And which are the Rust keywords for "I want things to be checked unless it costs me more than 5% runtime performance"?
      Or the option of "I want things checked unless it increases code size to above 2kB"?
      Also you seem to assume a system where "program halt in a controlled fashion" is any better than what would happen with a C program (it could in fact be worse, as your program MIGHT continue just fine after a buffer overflow).
      Rust certainly has a lot of interesting things, but for a microcontroller environment where you'll often enough have trouble getting the C compiler to produce sufficiently efficient code (and might need inline assembly to make it work) I seriously doubt it has a place.

    8. Re: Learn C for advanced security, not for basics by DrXym · · Score: 1

      Most of Rust's checks compile away to zero runtime cost so your questions are invalid to start. It probably doesn't fit every use case but Rust is targeting small devices and has been ported to run on some microcontrollers.

    9. Re: Learn C for advanced security, not for basics by david_thornley · · Score: 1

      If the latest Watcom C++ was 10.something, the year was 1994-1997. In those years, C++ was developing, there was no standard, and so compatibility could be a bitch. I don't know what sort of magic you had to do, because in that period my only C++ was on the Metrowerks compiler for the Mac, and that had its own idiosyncrasies. (I worked on a project in 2002 to convert my employer's code to standard C++, rather than keeping the differences with pre-standard Sun, HP, and one other compiler and adding an AIX one. It had complications.)

      Also, C++ has no more overhead than C. There are a lot of ways you can create overhead, but those are optional, if you're willing to sacrifice the functionality (and if you're considering C instead you're willing to sacrifice it).

      Read and write barriers? In C++, anyway, the program is required to do all volatile memory accesses in the order specified by the program, I may be suffering a post-lunch loss of imagination, but I'm not seeing why that would be inadequate.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    10. Re: Learn C for advanced security, not for basics by AaronW · · Score: 1

      You talk about closing a file. We're talking kernel level here. Rust may work well in user space, not so much at the kernel level. None of that "management" exists. Guard pages? What are those? What's this virtual memory thing you're talking about?

      --
      This post is encrypted twice with ROT-13. Documenting or attempting to crack this encryption is illegal.
    11. Re: Learn C for advanced security, not for basics by AaronW · · Score: 1

      I agree with you about the overhead. The C++ overhead is generally minimal which I always find I have a hard time convincing people of. Back in the day all of my debugging was at the assembly level because there was no source level debugger for kernel device drivers.

      Write barriers also guarantee that the data is actually written to memory. On many platforms (i.e. MIPS) when you write to memory with a store instruction it may not actually be written to the cache but sit in a write combining buffer. Also there are different sync instructions where some preserve the order and others don't. One has to explicitly issue a sync instruction in order to flush the write buffer to the L2 cache. If the processor is not cache coherent (like a number of processors I've used) then you also need to explicitly flush or invalidate the cache as needed. Of course all of this also depends on where the write is. Writes to I/O registers typically don't need the synchronization.

      --
      This post is encrypted twice with ROT-13. Documenting or attempting to crack this encryption is illegal.
    12. Re: Learn C for advanced security, not for basics by DrXym · · Score: 1
      Where did the "we're talking kernel level here" nonsense arise from? This is a thread about a resurgence of C for programming IoT devices. This may surprise you but IoT devices do not implement their functionality in the kernel. Either the board is a microcontroller of some sort and has no kernel, or the board ships with an SDK consisting of a kernel and the developer writes a userland process on top which to all intents and purposes behaves as you may expect with access to files, sockets, memory etc.

      Either way Rust is a viable option providing the architecture is supported. Rust relies on LLVM to generate machine code so if LLVM supports an architecture then so potentially does Rust. It already supports a lot of architectures ARM, MIPs, x86 on Windows, Linux, OS X and a bunch of microcontrollers.

      I'd also point out that at least one kernel HAS been written in Rust. I wouldn't seriously propose using Redox in its existing form, but it kind of pisses on the argument that even if we were talking about the kernel (and we're not) that somehow Rust is ruled out there either.

    13. Re: Learn C for advanced security, not for basics by Anonymous Coward · · Score: 0

      On many platforms (i.e. MIPS) when you write to memory with a store instruction it may not actually be written to the cache but sit in a write combining buffer. Also there are different sync instructions where some preserve the order and others don't. One has to explicitly issue a sync instruction in order to flush the write buffer to the L2 cache.

      There is support for that in C++. See C++ header file atomic.

    14. Re: Learn C for advanced security, not for basics by AaronW · · Score: 1

      Many of these IoT devices have small amounts of memory and do not run Linux. Even those that do run Linux, understanding C is still a must when you deal with hardware. I'm sorry for you, but the embedded world is based almost entirely on C, not Rust or any other language. Learning C for embedded work is essential. You'll get a lot further knowing C than knowing Rust or even Python (which is making some inroads). The most valuable jobs basically all require C.

      --
      This post is encrypted twice with ROT-13. Documenting or attempting to crack this encryption is illegal.
    15. Re: Learn C for advanced security, not for basics by DrXym · · Score: 1
      I'm sure learning C is essential. It doesn't mean it's the only language and as I said if Rust were a choice I'd have to have a strong reason not to use it. And you're not paying attention to what's going on in IoT if you think everything is bare metal these days. The likes of Samsung, Google, Amazon et al are building software stacks over a kernel, so compliant devices are separated from the metal by a substantial amount of layers. And even if they weren't, Rust is available for some microcontrollers and there is no reason to think that won't grow over time.

      Yeah C is there and I haven't said any different. But it's a horribly dangerous language to code IoT and I expect that will reflect in the languages people choose to develop such devices over time.

  20. Reason to learn C++ by Tough+Love · · Score: 1

    Just C on your resume without C++ will pigeonhole you as a code monkey. Learn C++ and you will also know C, which is essentially just C++ with subtractions. These days, it would be rare to encounter an embedded tool chain that does not support both C and C++, usually with the same compiler.

    --
    When all you have is a hammer, every problem starts to look like a thumb.
    1. Re:Reason to learn C++ by ebonum · · Score: 1

      I'm a COO, and I have C and C++ on my resume.

      It is not C on your resume that limits you, the limit is only in your mind.

    2. Re:Reason to learn C++ by lucasnate1 · · Score: 1

      I do C++ for a living, and it's very different from C. C++ is becoming more and more high level, while in C people use more traditional allocation schemes and weaker type systems that require more manual bookkeeping. Furthermore, most C programming is done on either embedded environments or kernel mode, while most C++ is done on Windows/Linux/Mac in user mode.

    3. Re:Reason to learn C++ by Tough+Love · · Score: 1

      C++ style development is obviously different, but If you are incapable of translating any high level thing you do in C++ back into plain C then your weak fundamentals make you a second string developer. Most embedded development is not kernel programming and the shift away from C to C++ in that space is real. You can choose to be ahead of the curve or behind it.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    4. Re:Reason to learn C++ by Anonymous Coward · · Score: 0

      LOL. You C++ people should realize it's your days that are counted. C will still be used in 2038.
      What is C++ used for, where it isn't yet on its way out? HFT software?
      It was never used in Linux in the first place, steadily being phased out from Windows userland, deprecated in Apple products, QT is used in some places, but it isn't winning against Android or even HTML5 based toys, the companies are just leveraging 90s-educated code monkeys.
      The 90s dads are using their positions of power to push code that absolutely doesn't need C++ into C++ out of desperation for job security. Anyone outside of their generation just hates them for that.
      C++ programmers can't write C.
      C++ compilers can't compile C.
      C compilers written in C++ eat C code out of spite.
      The day there is a clear winner among the new languages, nobody will look back and switch away from C++ like it's the plague.
      It actually is.

    5. Re:Reason to learn C++ by Tough+Love · · Score: 1

      You C++ people should realize it's your days that are counted blah blah blah...

      Haha, you are very funny. I'm a C person.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    6. Re:Reason to learn C++ by Anonymous Coward · · Score: 0

      No, I can absolutely guarantee that if you learn C++ without specifically learning C, then you do NOT know C.

    7. Re:Reason to learn C++ by Tough+Love · · Score: 1

      No, I can absolutely guarantee that if you learn C++ without specifically learning C, then you do NOT know C.

      Wrong, it only shows that your knowledge of C++ is incomplete, and that you will be a clear and present danger to any serious programming project. If your understanding of C++ is so limited you would be well advised to stick to the ilk of Java or html.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    8. Re:Reason to learn C++ by MikeBabcock · · Score: 1

      C++ is not C and C is not C++.

      --
      - Michael T. Babcock (Yes, I blog)
    9. Re:Reason to learn C++ by Tough+Love · · Score: 1

      Spoken as someone who has mastered neither.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    10. Re:Reason to learn C++ by phantomfive · · Score: 1

      After working with C++11, and seeing where C++17 is going, I decided I don't want to do C++ anymore. It's still on my resume (just like C#), but I'm not taking any jobs in it. The language is usable, but C++ codebases tend to suck.

      --
      "First they came for the slanderers and i said nothing."
    11. Re:Reason to learn C++ by Tough+Love · · Score: 1

      Sounds like you found it too confusing. But really, C++ is much better with lamdas, you can get rid of functors for one thing, type deduction is working really well these days, generalized const exprs are really handy, etc etc. I'm not sure you understood what you were reading, you certainly did not provide any specifics. Better think about taking C++ off your resume, because if you run into a competent practitioner you risk being unmasked as someone who knows about the language, does not know the language.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    12. Re:Reason to learn C++ by phantomfive · · Score: 1

      But really, C++ is much better with lamdas, you can get rid of functors for one thing, type deduction is working really well these days, generalized const exprs are really handy, etc etc.

      I can link to half a dozen nice looking codebases in C. Can you link to even one in C++? The only ones I can think of that are any good limit themselves to a small subset of C++.

      --
      "First they came for the slanderers and i said nothing."
    13. Re:Reason to learn C++ by Tough+Love · · Score: 1

      You've pretty much outied yourself as someone who has C++ on their resume in spite of having only a limited reading knowledge at best. Why don't you start by reading some code for the Kate editor? Seems pretty approachable to me. QT centric, but that's not a bad thing.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    14. Re:Reason to learn C++ by AaronW · · Score: 2

      He is absolutely correct. There are some aspects where the two languages diverge. The way you program in C tends to be very different compared to the way C++ code is written. I have worked with both extensively for low-level projects (i.e. bare metal device drivers).

      --
      This post is encrypted twice with ROT-13. Documenting or attempting to crack this encryption is illegal.
    15. Re:Reason to learn C++ by Anonymous Coward · · Score: 0

      You've pretty much outied yourself as someone who has C++ on their resume in spite of having only a limited reading knowledge at best. Why don't you start by reading some code for the Kate editor? Seems pretty approachable to me. QT centric, but that's not a bad thing.

      I think you missed his point. Kate editor might be a clean C++ codebase specifically because it is Qt code base and not a crazy (and typical) template nightmare C++ project where someone implemented a new language using templates.

      This is the main problem with C++. C++ language is very powerfully, however, with great power comes great responsibility. And people are idiots so the power gets abused.

    16. Re:Reason to learn C++ by Anonymous Coward · · Score: 0

      Spoken as someone who only thinks they have masters either.

    17. Re:Reason to learn C++ by Tough+Love · · Score: 1

      Kate editor code base is just the first random repository I happened to hit on the net. Many other examples of competently designed and executed c++ projects are readily available. I get it. OP does not really know the language and wants to blame that on the language. Meanwhile, countless other practitioners are perfectly able to function and use the tool as appropriate and to advantage.

      "Can you even link to one in C++?" What rubbish. Agree that there is a special place in hell for people who implement new languages in template code, but such idiocy is hardly the exclusive domain of C++.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    18. Re:Reason to learn C++ by Tough+Love · · Score: 1

      Spoken as someone who likes the sound of their own voice.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    19. Re:Reason to learn C++ by phantomfive · · Score: 1

      No, that's bad code, and it doesn't take advantage of modern C++ techniques, either. The code would be cleaner using auto in places, and some of the iterations would look much better replaced with range-for loops. The calls to new should be replaced with smartpointers. There is no doubt that modern C++ is an improvement. The code you linked to doesn't look clean to me at all. However, I've never seen a piece of code in modern C++ style that looks clean, either.

      Maybe someday someone will figure out how to use C++ in a clean, nice looking style. Then I'll use it. Until then, I'm staying away.

      --
      "First they came for the slanderers and i said nothing."
    20. Re:Reason to learn C++ by cpghost · · Score: 1

      Maybe someday someone will figure out how to use C++ in a clean, nice looking style. Then I'll use it. Until then, I'm staying away.

      You may also make suggestions and contribute to shape the next iterations of the C++ standard...

      Personally, I really like what has become of C++ since C++11, and I'm seeing that C++17 is getting some real nice additions in the Standard Library too. What I'm still missing though: standardized networking (Boost.ASIO looks like a monster at this stage, don't know if that would or even should make it into the ISO standard anytime soon). Missing networking is a big minus IMHO. I also consider the difficulty of writing more specialized streams, e.g. for encryption etc. a small minus... but that may only be me not yet grokking enough the iostreams / streambuf library design to extend it that way.

      Save for that, C++11's style and philosophy is something you get used to after a while. It takes some time to finally "get it" and get the hang out of it. That's not just a couple of syntactic rules and keywords and weird ways to write templates and template specializations and throw in iterator flavors everywhere where you don't expect them to come up, it is more than that. Once you finally reach some stage of enlightenment, you'll start to really like C++ and will start coding in it as it was supposed to be and designed to be. I know, it sounds like a pathetic excuse for not being easily accessible...

      --
      cpghost at Cordula's Web.
    21. Re:Reason to learn C++ by phantomfive · · Score: 1

      Once you finally reach some stage of enlightenment, you'll start to really like C++ and will start coding in it as it was supposed to be and designed to be.

      Sure, show me some code that was written at that level of enlightenment.

      --
      "First they came for the slanderers and i said nothing."
    22. Re:Reason to learn C++ by phantomfive · · Score: 1

      Actually, I'm kind of interested why you want a standardized networking API. Is it for working in embedded? Or for the high-performance stuff where select() is too slow? For the most part, BSD networking APIs are so difficult to use that they get encapsulated into a function as soon as possible anyway. From that point, swapping out implementations usually doesn't take too long......

      --
      "First they came for the slanderers and i said nothing."
    23. Re:Reason to learn C++ by david_thornley · · Score: 1

      C++ and C are two different languages. Good C++ style includes never using some basic C constructs (such as arrays and strings) except for APIs, so it's quite possible to be a good C++ programmer and flounder with C.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    24. Re:Reason to learn C++ by david_thornley · · Score: 1

      Ah, the old language wars. $MYLANGUAGE has $FEATURE, and I don't know that $YOURLANGUAGE has $FEATURE, so $MYLANGUAGE is better.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    25. Re:Reason to learn C++ by phantomfive · · Score: 1

      Actually I'd really like to see a nice codebase in C++. If I saw some really nice code, I would copy the style and start using it. I am definitely willing to be wrong in this case, because it would mean an upgrade in my knowledge and skill.

      --
      "First they came for the slanderers and i said nothing."
    26. Re:Reason to learn C++ by phantomfive · · Score: 1

      Although if you really want to see a great, pointless fight of the type you are describing, I am currently involved in a delightful one over here. Complete with gratuitous insults and pointless comparisons.

      --
      "First they came for the slanderers and i said nothing."
    27. Re:Reason to learn C++ by Tough+Love · · Score: 1

      The code would be cleaner using auto in places, and some of the iterations would look much better replaced with range-for loops.

      Your analysis is pathetically shallow. Problem could be you?

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    28. Re:Reason to learn C++ by Tough+Love · · Score: 1

      What I'm still missing though: standardized networking (Boost.ASIO looks like a monster at this stage, don't know if that would or even should make it into the ISO standard anytime soon).

      Given that boost::filesystem is landing in C++17 it is not much of a stretch to expect the network counterpart to follow in C++20. Networking is considerably more complex than filesystem access especially with the asynchronous element, so it will be better for everybody if they take their time and bake it well. Meanwhile, libc provides everything that 99% of networking applications need, in a mature and powerful form.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    29. Re:Reason to learn C++ by Tough+Love · · Score: 1

      OK, maybe I should show less disdain and more sympathy for the space you are in. "BSD networking APIs are so difficult..." No, sorry, not difficult, doesn't even move the needle. Add a new feature to a compiler, or to a network stack, for example. That's more like it. You have a whole lot more time to do as an apprentice before you should even be looking at the grown-up stuff.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    30. Re:Reason to learn C++ by Tough+Love · · Score: 1

      C++11's style and philosophy is something you get used to after a while.

      Much of it is cringe worthy, some of it makes me want to harm someone, but in the end, it is the go to choice for complex projects where performance is critical. It is quite amazingly good at catching issues at compile time instead of run time, and surviving deep design changes and refactoring without introducing bugs. You pay for that in often horribly opaque compile time error messages. It will generally be slower to develop in than modern scripts like Python, so think seriously about prototyping in some other language. B.CmpSci or equivalent skill level is essential. I get the feeling that critics weighing in on the thread are mainly venting because of not having the necessary grounding. Like wanting to do surgery without going to medical school. It just won't work out, and if you listen in on a conversation between surgeons, the things they are saying will make little sense to you. You can weigh in with your opinion of course, but you are likely to be ignored or worse.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    31. Re:Reason to learn C++ by Tough+Love · · Score: 1

      Good C++ style includes never using some basic C constructs (such as arrays and strings) except for APIs...

      Good C++ style includes no such thing. It includes using the correct tool for the job. In case you have not noticed, plain old arrays of char tend to be significantly more efficient than std::string, sometimes by orders of magnitudes. If you are unable to employ these tools in cases where the benefit is large then by hiding behind unsupported claims about style, you are actually just masking incompetence.

      Here is what good C++ style really is: suppose you are faced with a situation where you must work at the char * level for efficiency, because std::string just doesn't cut it. Did you employ the power of C++ - templates, custom allocation, classes, data hiding, etc etc - to make your code more resilient, readable and extensible while still yielding top performance? That is good C++ style.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    32. Re:Reason to learn C++ by Tough+Love · · Score: 1

      If I saw some really nice code, I would copy the style and start using it.

      That is not how you learn a professional programming language. This is how. You learn by writing. When you have learned enough by writing to understand what it is that you are reading, then you continue your learning by reading, and more writing.

      There does exist a breed of C++ programmer whose primary technique is copying. They are easily recognized because they tend to be incapable of accomplishing anything at all unless handed a class library, and then are only able to accomplish trivial things.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    33. Re:Reason to learn C++ by Anonymous Coward · · Score: 0

      Spoken as someone who likes the sound of their own voice.

      Spoken like someone who can't back up their own statements.

    34. Re:Reason to learn C++ by david_thornley · · Score: 1

      std::string is not a particularly good design. It has the two advantages of being standard and being mostly good enough.

      If you really need more speed than you get from std::string, you could try std::vector or std::array, depending on exactly what you're doing. Both are improvements on C-style arrays, and std::array in particular provides the performance of a stack-allocated C-style array.

      Try them and see. I assume that, if you're worried about std::string overhead, you've got the code set up for profiling and timing. (If not, that's your first job. Making the code less clear to get greater performance should be done in conjunction with profiling, so you know you're working on the right piece of code and that you are indeed getting more performance.)

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    35. Re:Reason to learn C++ by phantomfive · · Score: 1

      Your analysis is pathetically shallow. Problem could be you?

      Are you done with gratuitous insults now? Since you're the one who presented it as an example of good code (when it's not great), maybe you should explain why. Show you know how to think.

      --
      "First they came for the slanderers and i said nothing."
    36. Re:Reason to learn C++ by Tough+Love · · Score: 1

      Try them and see.

      Please don't be patronizing. The post you replied to apparently went "whoosh" for you. Try this superficial observation: you aren't stuck with the templates in STL, you can write your own. Judiciously of course.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    37. Re:Reason to learn C++ by david_thornley · · Score: 1

      Writing templates and getting them right is hard. Using what's in the standard library is a lot easier. There's no need to use "templates, custom allocation, classes, data hiding, etc etc" when it's there right in the standard library.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
  21. Wow by ebonum · · Score: 1

    Have we fallen so far that we need a reason such as "IoT" to learn C?

    Sad day.

    1. Re:Wow by lucasnate1 · · Score: 1

      Why do you equate "not learning C" with "falling so far"?

    2. Re:Wow by Anonymous Coward · · Score: 1

      Just the fact you asked the question is a bit frightening. C is one of the base languages, and it's the base language for essentially all of the most popular languages in use today. It also happens to be deployable with extremely small runtimes and supports things like inline ASM - which is why it's the choice for embedded applications. You can develop a complex program in C and deploy it to a device with so little non-volatile storage it couldn't even hold the C++ runtime. To know C well is to be able to understand the hardware and efficiently handle limited environments.

    3. Re:Wow by Anonymous Coward · · Score: 0

      You're being silly. IoT is the reason for learning something that you can "deploy to a device with so little non-volatile storage", because they are the only devices that exist with that little memory for a consumer. My phone has 64 GB of solid state non-volatile storage and a quad core processor. There are fewer and fewer places where the tiny device is relevant. Maintainability, security, time to market, are important.

      C makes sense for device drivers and kernel work. For everything else, it probably makes more sense to use something higher level and quicker to market.

    4. Re:Wow by david_thornley · · Score: 1

      The C++ runtime doesn't have to be bigger than the C runtime, if you don't want to use the features that add to it.

      Most programmers do not in fact work on operating systems, device drivers, or embedded programming, and have no real need to know C. Knowing how things work near the metal is useful but not essential for an applications programmer.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
  22. Counting the bytes? by holophrastic · · Score: 1

    Yeah, I don't think any modern IoT device has any programmer "counting the bytes". I used to count bytes, back when I had 4KB of memory, or 8MB of memory, or 20MB of disk space. I think you'll be hard-pressed to find any IoT device with less than a gig of virtual memory. Considering zero or near-zero graphics output, I think you'll be just fine with any language ever inventing.

    My vote goes to turing, which I haven't seen in twe decades, but for which I have a school-age nostalgia -- I made a street-fighter-style game for high school, with stick-figure graphics!

    1. Re:Counting the bytes? by Anonymous Coward · · Score: 0

      I made a street-fighter-style game for high school, with stick-figure graphics!

      These days Street Fighter needs 20 GB of disk space and a GTX 960.

    2. Re:Counting the bytes? by Kryptonut · · Score: 1

      How about Arduino and WeMos / ESP8266? They don't have a gig of virtual memory.

      There's even services out there already built for them, with mobile apps even, e.g. Blynk and Cayenne

    3. Re:Counting the bytes? by Anonymous Coward · · Score: 0

      You're absolutely clueless. We're talking about running TCP/IP stacks AND a meaningful program on platforms with a budget of 48c per chip - not shoving a snapdragon in a toaster and saying "Go at it".

  23. Re:A damn good reason to learn security best pract by lucasnate1 · · Score: 2

    Computers (and machines in general) were created to make the life of humans easier. Imho, a real programmer also remembers that fact.

  24. Yes, but not for this reason by mi · · Score: 1

    Yes, you should know C well enough to be able to read somebody else's code. At least. You may even switch to it for good, unexpectedly.

    No, IoT-devices are a poor reason to start learning the language. By the time you are done, Moore's Law will make this devices powerful enough to run Ruby, Perl, and PHP, and you'll be able to go back to those...

    --
    In Soviet Washington the swamp drains you.
  25. Re:A damn good reason to learn security best pract by Opportunist · · Score: 4, Insightful

    Real programmers? As compared to the untrue Scotsman?

    Look around you and see what doubles as "programmer" today. Ask them how a stack overflow happens and why that is a problem. If I get a buck from you every time you get a blank stare and you get ten from me every time you get a sensible answer, your house belongs to me before the week is out.

    --
    We used to have a Bill of Rights. Now, with the rights gone, all we have left is the bill.
  26. H1B the needful by Anonymous Coward · · Score: 0

    If your skin isn't brown, don't learn anything, because your chance of finding work is zero.

  27. Re:A damn good reason to learn security best pract by haruchai · · Score: 1

    "If you cant sort out a buffer overflow then dont call yourself a programmer"
    Several decades of severe network exploits show that a huge amount of software, commercial, free, open source, obscure, commonplace, whatever was written by people who can't call themselves programmers and used by those who don't have the 1st clue how to use it securely.

    When I first got serious about computing, 2 decades gone, the common wisdom was that we had not choice but to keep on using the old (mostly very insecure) software because so much depended on it, it would be too costly to rewrite in more secure languages and in time it would all get fixed by better programming practices.
    We are also only 2 weeks away from the 15th anniversary of Bill Gates' "Security is Job 1" e-mail
    https://www.cnet.com/news/gate...

    If we knew then what we knew now, how much damage would be caused by exploits, what it would cost to fix, remediate, the secrets exposed, the privacy intrusions, would that advice still hold or would we have been better off to say damn the torpedoes and rewrite all of it?

    --
    Pain is merely failure leaving the body
  28. No IoT is not a good reason to learn C by Anonymous Coward · · Score: 0

    IoT stuff is probably the worst reason to learn C. Internet exposed services written in C without some knowledge of secure coding practices, is just asking for disaster. Even with large amounts of experience, C will still let you shoot yourself in the foot just fine.

    Now if you want to learn C because you ENJOY working at such a low level, then please do. Learning C is much like BDSM, it's not for everyone. People will think you are weird, but the people in the know, well..they get it ;)

  29. JavaScript ... and maybe Python by rgbe · · Score: 1, Insightful

    Most mods will probably flag this as trolling. But I believe JavaScript is a great language for IoT. There are a few advantages of using JavaScript, it's actually very easy to get networking to work well and reliably. A programmer will be able to write front-end, server-side/less back-end and IoT back-end all in one language. The code will be portable across all these bases (not always needed, but some functions will be universal). There are now a proliferation of embedded devices that support JavaScript "natively" (ESP32, RedBear Duo, and many more). It might not be as fast as C, but it's fast enough. Here is a project I created using JavaScript at every level: https://www.hackster.io/anemoi...

    1. Re:JavaScript ... and maybe Python by Anonymous Coward · · Score: 0

      This is a discussion about platforms that would buckle under the bulk of a micro-OS and a JS interpreter/VM stack. And that's not even handling the issue that most of these devices use embedded hardware platforms that you need to access with specific assembler calls - how would you do that in JS or Python!?

    2. Re:JavaScript ... and maybe Python by Bent+Spoke · · Score: 1

      Or even javascript and C: http://jsish.sourceforge.net/

    3. Re:JavaScript ... and maybe Python by rgbe · · Score: 3, Informative

      This is a discussion about platforms that would buckle under the bulk of a micro-OS and a JS interpreter/VM stack. And that's not even handling the issue that most of these devices use embedded hardware platforms that you need to access with specific assembler calls - how would you do that in JS or Python!?

      There are a few JavaScript interpreters that use very minimal resources and have access to all the necessary hardware (wifi, BLE, SPI, UART, i2c, etc), these are Duktape http://duktape.org/, Espruino https://github.com/espruino/Es..., JerryScript https://github.com/jerryscript..., and more. These are all designed for IoT devices. For performance this is an interesting read: https://www.espruino.com/Perfo...

    4. Re:JavaScript ... and maybe Python by rgbe · · Score: 1

      Or even javascript and C: http://jsish.sourceforge.net/

      Duktape is along a similar line: http://duktape.org/

    5. Re:JavaScript ... and maybe Python by LordWabbit2 · · Score: 4, Insightful

      Good god, just learn C instead of trying to force javascript into everything. It's like my wife trying to drive a nail into a wall with her high heel shoe. Sure, it would probably work eventually, but the right tool for the job is right there in the toolbox. Use it. Step outside your little javascript box and learn something new.

      --
      There are three kinds of falsehood: the first is a 'fib,' the second is a downright lie, and the third is statistics.
    6. Re:JavaScript ... and maybe Python by rgbe · · Score: 1

      Actually I grew up with C, Pascal, Assembly (for many different processors), C++, then learned and taught Java at University. I enjoyed Matlab, Mathematica, Python and Fortran while studying Physics. Now I've landed on JavaScript and if you avoid the ugly bits, it's fun.

    7. Re:JavaScript ... and maybe Python by AaronW · · Score: 1

      The overhead of javascript is still significant compared to C.

      --
      This post is encrypted twice with ROT-13. Documenting or attempting to crack this encryption is illegal.
    8. Re:JavaScript ... and maybe Python by Lisandro · · Score: 1

      JavaScript is just too abstracted from hardware to be an efficient IoT language, IMHO. It is impossible to fine-tune memory management, implement threading or properly access I/O.

    9. Re:JavaScript ... and maybe Python by Anonymous Coward · · Score: 0

      Wait wait wait.

      So you are telling me there is a way to code javascript without running into ugly bits? I thought that was unpossible.

  30. I'd figured you know C by Anonymous Coward · · Score: 0

    if you are a programmer. How can you be a programmer if you don't know C?

    1. Re:I'd figured you know C by Anonymous Coward · · Score: 0

      How can you have any pudding if you don't eat your meat??

  31. Everything is a reason to learn C (and C++) by RogueWarrior65 · · Score: 1
  32. Re:A damn good reason to learn security best pract by guruevi · · Score: 1

    Buffer overflows can be very useful constructs when you handle them very carefully and properly. They can be used as the GOTO for very limited microprocessor's code.

    --
    Custom electronics and digital signage for your business: www.evcircuits.com
  33. Yes by SEGV · · Score: 1

    C or C++, coded appropriately, can best fit technical concerns with business concerns.

    --

    --
    Marc A. Lepage
    Software Developer
  34. No.... by Luthair · · Score: 1

    It seems likely that most IoT devices will rely on a central hub which leaves the devices as relatively dumb. The hub (or the cloud) side will likely be a less constrained environment so will use a higher level language.

    The other factor is that the thing side has a manufacturing component so will probably be commoditized by Chinese manufacturers and relatively few jobs will exist outside.

  35. Re:A damn good reason to learn security best pract by Anonymous Coward · · Score: 0

    You do not RC. C was not intended to be portable, according to Dennis Ritchie. Interest in portability came many years later.

  36. Re:A damn good reason to learn security best pract by Anonymous Coward · · Score: 0

    Real workmen wear safety goggles and use table saws which drop the blade when it detects flesh. Why should programming be different? You can work a lot faster if you don't have to worry about slicing your hand off. It's 2017, buffer overflows shouldn't exist. Programming language developers and/or compiler developers are really slacking off.

  37. R.I.P. MIPS by Anonymous Coward · · Score: 0

    RISC-V is the new MIPS.

    At this point there is no point to having any other general purpose computing instruction sets. Time for POWER, MIPS, SPARC, ARM, AARCH64, x86, x86-64, Tensilica (ESP8266), AVR, Blackfin, Lattice, etc to die.

  38. Re:A damn good reason to learn security best pract by vux984 · · Score: 1

    If you need a stronger microprocessor for a task use one. The notion that using buffer overflow or stack smashing or jumping into data segments with 'dynamic' code is something you should ever do is simply ridiculous.

    Yeah... to get a 60Hz 1970s microprocessor to do something useful in 512 bytes of RAM you had to be creative... and it was expensive to go upmarket for a better CPU. But in the 21st century if you are using a buffer overflow to write code on purpose, the time you spend building and documenting and maintianing that... you should have just spent another nickle and got a more capable processor with more ram.

  39. Re:GOTO by hackwrench · · Score: 1

    I've written code that popped the default return location and pushed a value that took me anywhere in the program I cared to go. https://www.youtube.com/watch?...

  40. Artificial language limits by hackwrench · · Score: 1

    Just about any language can have a compiler written for it that writes code that meets the low-memory requirements. It helps if the programmer is intimate with the details of what language elements map to which machine code.

    1. Re:Artificial language limits by AaronW · · Score: 2

      Actually most modern languages fall apart since you need a certain feature set at the low level that high-level languages try and protect you from. Many languages have significant overhead required just to use the language and thus don't work well in low memory situations.

      I have written a number of bootloaders that have to fit in 8K of RAM. There is absolutely no way I could write them in anything other than C and a minimal amount of assembly. C code can be very efficient with modern compilers optimized for size. I'd put them close to carefully coded assembly. Often the C code is smaller than assembly because the compiler will make choices that the assembly programmer will avoid just for readability and maintainability.

      Most higher level languages do hand holding with things like pointers and memory management which get in the way and consume a lot of resources. C is very good for low level bare metal programming. All that pointer checking and other features have a cost in terms of size and performance.

      --
      This post is encrypted twice with ROT-13. Documenting or attempting to crack this encryption is illegal.
    2. Re:Artificial language limits by TheRaven64 · · Score: 1

      I have written a number of bootloaders that have to fit in 8K of RAM. There is absolutely no way I could write them in anything other than C and a minimal amount of assembly

      And yet people have been writing bootloaders in Forth for smaller constraints than that for decades.

      --
      I am TheRaven on Soylent News
    3. Re:Artificial language limits by Anonymous Coward · · Score: 0

      I have an architecture on my bookshelf for which a port of C is a royal pain in the behind if it's possible at all.

    4. Re:Artificial language limits by Anonymous Coward · · Score: 0

      Good point, although picking one of the only languages that is lower-level than C doesn't help the overall argument.

    5. Re:Artificial language limits by thegarbz · · Score: 1

      can and does are two different things.

      We can do a lot of things. We could use a lot of languages for tight memory applications.

      We will be using C because every major manufacturer will provide a C compiler, and C instructions, and C optimisation tables, and will give you a lot of details on how to use their device in assembler and C.

      Sure we could write a brainfuck compiler, but we won't since in general people take the path of least resistance.

    6. Re:Artificial language limits by AaronW · · Score: 1

      Although forth require BIOS. Try writing forth when there is no forth interpreter or any BIOS. By 8K, that includes everything. I'd like to see a 64-bit 4th program compete. I highly doubt it would. In my case there is no BIOS since this bootloader is the very first thing that executes once the chip exits reset.

      --
      This post is encrypted twice with ROT-13. Documenting or attempting to crack this encryption is illegal.
    7. Re:Artificial language limits by AaronW · · Score: 1

      I'd say it's higher level since it requires a forth interpreter. Forth doesn't run very well without an interpreter.

      --
      This post is encrypted twice with ROT-13. Documenting or attempting to crack this encryption is illegal.
    8. Re:Artificial language limits by JanneM · · Score: 1

      FORTH is the rare language that tends to be even more memory efficient than C. The runtime interpreter is truly minimal (really just following a bunch of jump tables); you can have a small environment and application code in less than 8K.

      On the other hand - and I say this as someone who likes FORTH a lot - you'd be hard pressed to find people claiming that FORTH is any higher-level (or easier to develop in) than C or assembler.

      On the third hand - and off-topic here - it's quite a fun little language to use. Just like you can say that Scheme is programming directly in an AST, using FORTH is writing code directly for a stack machine. It's probably good for you to have a bit of experience even if you never do anything "real" with it.

      --
      Trust the Computer. The Computer is your friend.
    9. Re:Artificial language limits by JanneM · · Score: 1

      Any language that could replace C and assembler would need to be statically compiled. So for Java, C#, Python and so on you'd have to define a subset that does not require a runtime parser or standard library. And you'd need extensions (or a static module system) that allows you to add assembler for direct hardware access. And a new compiler that can generate static code instead of the intermediate VM they target now. Not impossible by any means and probably a fairly interesting exercise too, but the languages would end up rather different and more restricted than the full versions people are used to.

      Rather, I expect and hope that something like Rust will eventually supplant these languages in this space. Rust gives you the best of both worlds, with a statically compiled binaries and good memory safety at compile time, rather than runtime. You pay for it by having to be much more explicit about ownership than in these languages though. I've followed that project for a good while and it's clear that targeting small embedded systems is a struggle even for such a language; Java and friends would be much more difficult still.

      --
      Trust the Computer. The Computer is your friend.
  41. Re:A damn good reason to learn security best pract by ShooterNeo · · Score: 4, Interesting

    I do embedded C programming. With this said, I don't think that improvements to the tools are impossible - sure, I have to prevent buffer overflows myself at the present time - but it doesn't have to be this way. The key thing about embedded programming is that hardware designers are lazy. They want to do the least amount of work possible. So instead of making their hardware easy to program, they like to make it in a way that is easiest to them. So every data sheet contains all kinds of special exceptions to the rules that you the programmer have to take into account. And instead of supporting some fancy, easy to program in language, they do the minimum amount of work to make a C compiler work. (it's really minimal - you only need to map a few base instructions to opcodes on the hardware and you can bootstrap the C compiler).

    One major issue is while every microcontroller or DSP generally has roughly the same stuff - various ports that do the same thing, the MAC instruction, usually a von Neuman architecture, usually interrupts and DMA - you basically have to scrape the datasheet for weeks to do something you've done before on a different microcontroller.

  42. Re:A damn good reason to learn security best pract by Opportunist · · Score: 1

    No. If that's your concern, simply PUSH the target address and RETurn to it. At least if your processor doesn't simply let you MOVe raw data into the IP.

    There is exactly no reason to ever smash the stack to redirect the program flow UNLESS of course you do not have control over the program code, i.e. when you have to do pretty much what those who use that kind of exploit do. But then we're leaving the area of development and enter the realm of ... let's say repurposing.

    --
    We used to have a Bill of Rights. Now, with the rights gone, all we have left is the bill.
  43. Simply because... by God+of+Lemmings · · Score: 3, Insightful

    knowing how to program in C and how C works under the hood makes you a better programmer. Even if you don't program in C. That is reason enough.

    --
    Non sequitur: Your facts are uncoordinated.
    1. Re:Simply because... by Anonymous Coward · · Score: 0

      Most software we use every day was wriiten in C.

      C is a good place to start before going on to languages lik C++, Java, D, C# and many other derivatives.

  44. easy choice by wolf12886 · · Score: 1

    Like it or not, C is still the defacto standard for embedded programming. If you're working in any where near bare metal your going to be using it. That may change but for now, if you dev for Internet of things and you don't know it, you're basically a script kiddie. Source: I'm an electrical engineer.

  45. IoT what now? by Kellamity · · Score: 1

    Am I the only one who has never heard of IoT?? Is that really a real thing? I gotta spend more time on the twitter or something to learn the cool stuff.

  46. Re:What BASIC can do... by hackwrench · · Score: 1

    There's nothing BASIC can't do.. while that is generally true for programming languages in general, BASIC has a long tradition of bringing in house what for other languages are external libraries and turning them into commands that are intrinsics in the language. Take a look at all the modern flavors of BASIC and their built-in commands. If you can code it into a compiler it can be BASIC, baby!

  47. Re:A damn good reason to learn security best pract by Darinbob · · Score: 2

    Well, most systems use third party C compilers, gcc or keil or whatever. C is low level enough that the CPU doesn't have to know it's C anyway, it could be Fortran, Pascal, Ada, or whatever as long as it has a basic stack model. They're not supporting any language. Von Neuman isn't even required, there are many embedded systems that are Harvard architecture (separate regions for code and data) which C supports just fine.

  48. Re:A damn good reason to learn security best pract by Darinbob · · Score: 4, Insightful

    Most buffer overflows weren't necessarily because of being sloppy in the original code, but because the code was copied so readily. Someone has a simple routine without all the necessary checks because it's not being used for anything very important, software that doesn't need to be secure, it's a one-off utility (maybe it converts postscript to PCL). Then someone copies that routine into another program, makes that a set-uid program, and poof you've got a security hole. First programmer says "it was not intended to be re-used", second programmer says "re-inventing the wheel is foolish!", and they blame each other.

  49. Not just small devices. by MouseTheLuckyDog · · Score: 1

    Reducing compute times/memory usage by 0.1% in big data centers reduces the cost of electricity and cooling by millions.

    Reducing compute times/memory usage in battery powered devices increases battery lifetime.

    I view C++ as a better choice then C though, who can code a linked list from scratch more efficient then what they do? You get more abstraction power.

  50. Re:A damn good reason to learn security best pract by bug1 · · Score: 1

    Computers (and machines in general) were created to make the life of humans easier. Imho, a real programmer also remembers that fact.

    There are no technical reason a programmer cant create code that is good for humans (usable), and for machines (efficient).

    The problem is when a programmer decides, or is forced to compromise on quality. That is the lesser programmer.

  51. No, but IoT is a good reason to learn network secu by mbeckman · · Score: 1

    Because the current crop of IoT programmers clearly don't know a thing about it, or just don't care, which is why IoTs are the largest DDoS attack army in history.

  52. That too exists, LLVM barcode by SuperKendall · · Score: 1

    What's being discussed here are platforms that need features SWIFT simply doesn't have, like inline assembler to manipulate hardware specific features

    That's not so; the assembly language of Swift is bitcode - which you can embed in Swift code for customized performance.

    manual allocation schemes for shared memory (EG reserved blocks that are processed by hardware interrupts)

    Although the link is not exactly that case you can use UnsafeMutablePointers for that purpose. Swift is not a garbage collected language, it uses ARC which is already deterministic as to when memory is allocated and released - but you can disable that for code and manually manage memory used.

    To use SWIFT you'd need to develop entirely different custom libraries for each platform

    Ask Apple how they support various ARM architectures...

    No not everything is quite there, but Swift is moving rapidly and the underpinnings were built with the explicit goal that Swift COULD replace C as a language for any purpose, not just another higher level language that really can't apply for low level development. At this point the language is basically locked in but more features will be added over time, including stronger device programming support. That's why taking the time to learn it now means that by the time you understood it well you could probably start doing some hardware development with it... pretty sure LLVM at least and possibly Swift will be involved in some way at Tesla for example. When you are writing code that MUST be stable, like code that controls a car, C is just not going to cut it long term.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
    1. Re:That too exists, LLVM barcode by Trailer+Trash · · Score: 1

      C is portable assembler. I love C, and there will *always* be a place for it, but to really use it safely and properly you simply have to understand how computers work at the lowest levels. I'm old school and at one time could write in 3 different assembly languages fluently. I know how processors and hardware work. But most modern programmers don't, and they need something a little higher level to be able to write reasonably safe code. If Swift can fill that niche, I'm all for it. Ultimately having a somewhat safer compiled language is a really good thing since almost all language development these days is tending toward scripting languages with better VMs - not something to put in your IoT device.

    2. Re:That too exists, LLVM barcode by Anonymous Coward · · Score: 0

      Your links suggest to me that you have no idea what inline assembly is, what it's used for, or even what bitcode is?
      None of your links show any support for embedding bitcode into Swift (only embedding it into .o files, but that is kind of the opposite thing), but apart from that it is not assembler and you cannot use it to insert CPU instructions your compiler does not know about/does not know how to use.
      And Apple doesn't write any low-level code in Swift (and/or have support from a more microkernel like kernel, we are talking about platforms with no space or use for a kernel). I don't even know what you meant to say with "various ARM architectures". Self-driving cars is often called "embedded", but it has absolutely nothing in common with the microcontroller environments the previous poster was concerned with.

  53. Forgetting something? by Anonymous Coward · · Score: 0

    But when it comes to IoT applications there is that need once again.

    Yeah, for five or ten minutes, then it'll be like, "Oh, hey, the new Samsung Toast-X is out! Peak bread-toasting power 750 watts, comes standard with Bluetooth and WiFi, the basic entry-level toaster can do 6 slices at a time, AND it has 4GB or RAM, so it'll run Windows 10, (2018 IOT Edition)!

    I just bought a wristwatch that runs apps, and basically a full-blown OS in miniature... I'm pretty sure that capability will be BAKED into ovens and the like before long at all, pun TOTALLY intended.

  54. Re:A damn good reason to learn security best pract by Anonymous Coward · · Score: 0

    A real programmed wont use a sawed off shotgun to hammer in a nail, unless there is no reasonable alternative. The issue with C is not that you have to sort out buffer overflows, nearly every language has that - most modern high overhead languages just throw an exception. The issue with C is that you get a buffer overflow by default nearly every time you copy a string or resize an array ( a real C programmer uses doubly linked lists of course ) and that is both anoying to deal with and horribly brittle.

  55. Re:A damn good reason to learn security best pract by ShooterNeo · · Score: 1

    Sure. And if somebody has bothered to do the porting work and write a third party tool that uses a different compiler - and your project has the budget for such a tool - it's better. But it still isn't easy. You still end up reinventing many things.

  56. Swift is open source too you know by SuperKendall · · Score: 1

    Swift itself is also open source.

    It also can be used as a full replacement for C in a way Rust cannot; see my response to someone saying Swift can't be used for device programming for examples. Rust is a nice language but it's just not as architected as Swift is for use across the space of devices like C is already.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  57. Re:A damn good reason to learn security best pract by phantomfive · · Score: 1

    Worth mentioning that a half-way decent string and buffer library will solve basically all buffer overflow issues. If you're using strcpy(), gets(), or even strncpy() (without knowing the pitfalls), then you're in trouble.

    --
    "First they came for the slanderers and i said nothing."
  58. Interpreted languages only please by Anonymous Coward · · Score: 0

    Security is about mitigating risk and security requires defense in depth. The language of the embedded device should NOT be C. C is a bottom less pit of memory corruption issues: see ANY operating system.

    The programming language of any device should be a type-safe memory-safe interpreted language: .net, java, scheme, you name it. There was a .net research operating system from microsoft that looked interesting. Maybe a core version of that open sourced would make a great foundation for not screwing shit up through buffer overflows or any other memory/type corruption issues.

    There is a stereotype and anachronistic idea that embedded devices lack CPU power. CPU power is bought in spades for trivial pennies to dollars.

    That will leave all the other hundreds of logical security issues to address.

    Standardized components for those would be great.

  59. C is fun, if you enjoy coding by Anonymous Coward · · Score: 0

    When someone is solid in C, it's a great indicator that they care about their craft. The curious and passionate will inevitably dive into it. I find that it becomes a great litmus test for hiring.

    I'll dare say this potentially unpopular statement: If you have no interest in C, then you're in this for money and not love. How can you not love the foundation that your entire career is based upon??

  60. no by Anonymous Coward · · Score: 0

    lot is a reason not to own a lot device...wtf does a heater need to be hooked up to the web for?? Or some other dire device, the whole concept of lot is stupid beyond belief....

    1. Re:No by Anonymous Coward · · Score: 0

      So if something does not fall into one of three categories I should use some other language which I don't like? Why exactly? C is perfectly fine. I've yet to come across another language remotely as nice to program in.

    2. Re:No by david_thornley · · Score: 1

      Imagine an integrated kitchen, that keeps track of what you've got in the refrigerator and the pantry (perhaps through RFID chips in the packaging). You could have it generate grocery lists, make meal recommendations, all sorts of things. Lights that can turn themselves on and off to simulate someone doing things in the house to make it look occupied. Drawing a bath of desired temperature and depth without watching it. Having the dishwasher, shower, bathtub, and washing machine coordinate the need for hot water. I can think of lots of things I'd like the house to do, and which are technically feasible.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    3. Re:No by jandersen · · Score: 1

      I can think of lots of things I'd like the house to do, and which are technically feasible.

      So can I, but in my case it already does it: provide shelter, give me a private space etc. All this is a matter of taste, of course, but I don't want technology to do things for me, if it means that I will slowly forget elementary skills. A good example, in my view, is the ready-meal culture: what was once an obvious life-skill that everybody would need, is now regarded by some as nearly impossible. The absurd thing is that anybody can learn how to cook a very good meal with little effort and as fast as (or sometimes faster than) the time it takes to unwrap a ready meal, stuff it in the oven and heat it. People have given up the skill, and are now trapped in a situation where they feel they have to expensive, but poor quality food.

      But to get back to the point - I wasn't so much talking about whether these products would become common or stay common, even after the fads have died down. It's like the pocket calculator - once they were among the most desirable gadgets in the world, and you could get them with many different features, and they are still popular - but they have settled down to a very limited number of designs; laptops, phones and tablets fulfill most of the needs now, and most pocket calculators are limited to the very basic arithmetics. Same with IoT: I'm sure we will see loads of gadgets that do something that isn't actually all that useful - like being able to turn the heating up or down while you're away from home - but then, when they start breaking, most won't be replaced. The ones that turn out be of real value to people will probably be of a few, relatively simple designs, and they will be robust and/or cheap and easy to replace. My guess is that there will only be a relatively small need for developers in that industry in the long run.

  61. You have to learn C invariably of what you do by fubarrr · · Score: 1

    C is programming lingua franca. Anybody calling himself a programmer and not knowing C is not a programmer.

    Before the mainstream software programming turned to be web programming, C was taught in every computer science university programme.

    Not knowing C limits your competence to a small pond called web programming.

    1. Re:You have to learn C invariably of what you do by Anonymous Coward · · Score: 0

      C is programming lingua franca. Anybody calling himself a programmer and not knowing C is not a programmer.

      Before the mainstream software programming turned to be web programming, C was taught in every computer science university programme.

      Not knowing C limits your competence to a small pond called web programming.

      Spoken like someone who has never done any systems integration or back-end data munging.

  62. Theres Ada, but who cares by Anonymous Coward · · Score: 0

    Ada is actively developed and has way more features than C++ without resorting to the OOP overhead, but its not hip, and crammed down our throats like Java et. all swift and go so who cares.... people want easy and like the "feel good" of making a C app or two

  63. Re:A damn good reason to learn security best pract by Anonymous Coward · · Score: 0

    If you are working faster because your table saw is a SawStop or is a Bosch with the "Active Response" response feature, you are NOT a good workman. You are being careless and relying on what is meant as a backup safety device to save your fingers/hands. If you ever trigger one of these devices with your flesh (vs., for example, a hot dog, wet wood, or radiant barrier sheathing), at a minimum you should be horribly embarrassed at how careless you were and hopefully it causes you to seek retraining.

  64. Re:A damn good reason to learn security best pract by Anonymous Coward · · Score: 0

    Correct me if I'm wrong, but I think the bad name IoT got in security is mostly due to routers and camera's on the market shipped with old linux installs and backdoors and default passwords set.

    If we're talking C, it's probably about programming microcontrollers. There are no root exploits on microcontrollers. A stack overflow will probably get you a crashed device and in the very best case access to functions you shouldn't have.

  65. No. IoT is a fad. ... by Qbertino · · Score: 4, Insightful

    ... Embedded is a reason to learn C though. And embedded and IoT do have some intersection/overlap. But I IoT itself is mostly a fad involving the slapping together of unsafe preconfection microlinuxes with unsafe overkill websevers/port 80 stuff and adding that to toasters and stuff that really don't need it and won't be used more than ~3 times unless by some bored teenagers wgo wants to screw up your homes heating or AC by surfing on shodan for some lonb forgotten default access to said IoT trinkets.

    Bottom line:
    You shouldn't do anything because of IoT unless it,s avoiding it like the plague (unless you're a hacker that is). OTOH If you want to learn embedded, C with assembler for the basics is the way to go.

    Good luck.

    --
    We suffer more in our imagination than in reality. - Seneca
    1. Re:No. IoT is a fad. ... by thegarbz · · Score: 1

      If you think IoT is a fad then it's a fad as long running as computers themselves. The name may be a fad but the principles of it have been with us for a long time. Just because they now connect to someone's cloud instead of a database under your own control doesn't mean that they haven't existed for 20 years already.

      The low cost of wireless and basic progressing is just an enabler that is causing explosive growth in popularity, that doesn't make it a fad.

    2. Re:No. IoT is a fad. ... by Anonymous Coward · · Score: 0

      Yeah, IoT is a fad, just like I (Internet).

  66. Re:A damn good reason to learn security best pract by LordWabbit2 · · Score: 1

    Hell, ask them what the stack is first, most won't have a clue. I used to ask developers (for C# positions) what the difference between a value and a reference type was. Still have not got a correct answer, eventually stopped asking the question. The problem is only going to get worse as they force more and more people to "learn to code" when they actually don't have the inclination. Cut and paste coders, the lot of them.

    --
    There are three kinds of falsehood: the first is a 'fib,' the second is a downright lie, and the third is statistics.
  67. Re:A damn good reason to learn security best pract by Anonymous Coward · · Score: 0

    Actually the ISO C library have plenty of tools to prevent buffer overflows, but there is a performance tradeoff.
    Since you have buffer overflows you likely have a buffer with a fixed size.
    The idea is to never handle pointers to the end of the data in the buffer or even keep track of how much data is in it.
    If you want to append data at the end you use strncat with you buffer address and a sizeof(buffer).
    Yes, the processor will have to scan through the buffer every time you use so you don't get the performance you might want, but the source will be very clean and you will not have to worry about buffer overflows.
    Many of the string functions also returns the start of the buffer so that you can chain multiple operations together in a oneliner if that is your thing.

  68. sadly, JavaScript does sound good for IoT by Anonymous Coward · · Score: 0

    Unless you're going to sell tens of millions of cheap devices, or more, it's not going to be financially worth it to hire some good programmers to make a nice, tight piece of C code, that will squeeze onto a puny microcontroller. It's probably going to be some mediocre device, interfacing via a web browser, with logic in... JavaScript. So, just make the mediocre device, also in JavaScript. There are a lot of moderately priced JavaScript programmers out there, and it is a more productive language than C, and spend more money on the hardware. I guess if the IoT device is not some cheap pos device, you could put on a full blown Linux or BSD distro. Use the Theo Deraadt!

  69. Re:A damn good reason to learn security best pract by Anonymous Coward · · Score: 0

    One of the microcontrollers I use run at 20MHz and has 256 bytes of RAM and it is less than 10 years old.

    Also, for embedded stuff you can't dump the extra memory cost on the end user. It will cut into your profit.
    That nickle adds up pretty quickly in the quantities that embedded stuff is produced in.

  70. No by jandersen · · Score: 1

    Two of the reasons for learning C are:

    1. It is a good, general programming language that can allow you to produce efficient code.
    2. You want to be a good programmer with a good understanding og the HW and the OS

    I'm not convinced the growth in IoT thingies is other than an ephemeral fad. There will be a period with a lot of innovation, then it will settle down on the relatively minor subset of gadgets that are actually useful and wanted, and there will no longer be a lot of need for programming skills in that area. But the C language has already demonstrated its staying power (as have certain other languages like FORTRAN and COBOL to the surprise of many), and it will be relevant to know for years to come, no doubt.

  71. Re:A damn good reason to learn security best pract by slashdot_commentator · · Score: 1

    K&R C could be considered portable assembly at one time (but a bloated one). Those days are long gone. Abstraction is for humans; abstraction is bloat for microprocessors.

    --
    There is no America. There is no democracy. There is only IBM and AT&T and DuPont, Dow, General Electric, and Exxon
  72. Re:What BASIC can do... by Z80a · · Score: 1

    Indeed indeed.
    Or you can just use enough pokes until it does what you want.

  73. Definitely yes by AaronW · · Score: 2

    While most of my work is for chips that are vastly more powerful than what is found in IoT devices I work on bootloaders and bare-metal programming. In some cases memory is a premium. With only a couple of exceptions, all of the work I have done has always been with C. Most small micros are programmed in C almost exclusively with a sprinkling of assembly.

    C is very good for working closely with the hardware and in memory constrained environments. C code does exactly what it says. There is no hidden overhead. The runtime needed to run C code is pretty minimal. All it really needs to get going is often a few registers initialized and a stack and it's ready to go.

    It works beautifully with memory mapped registers and data structures which are extremely common in this environment. There's even a keyword designed for this, volatile, that is not present in most other languages (or it does not do the same thing).

    I can use a bitfield to define hardware registers and just map a pointer to the address of that register and use it. Mixing in assembly code is easy if it's needed, though generally I find that assembly code isn't needed very often.

    It's also easy to generate a binary blob using C, a linker script and a tool like objcopy.

    My experience has mostly been with 64-bit MIPS and some ARMV8 but it applies to most embedded processors. The output of the C compiler when optimizing for size (with the right options set) is pretty close to hand optimized assembly and often even better because the compiler does things that would make the code otherwise hard to read or maintain. The runtime overhead of C is minimal.

    C's flexibility with pointers is also a huge plus. I can easily convert between a pointer and an unsigned long (or unsigned long long) and back as needed, or typecast to a different data type and pointer arithmetic is trivial. There is no hidden bounds checking or pointer checking to worry about. Many people say that's a bad thing, but when you're working close to the metal it can really turn into a major pain in the you know what. Master pointers and know how and when to typecast them. I've seen too many times where people screw up pointer arithmetic. I once spent several weeks tracking down a bug that showed up in one of my large data structures where I saw corruption. It turned out that some totally unrelated code written by somebody else in a totally different module was written by someone who didn't understand pointer arithmetic and was spewing data all over the place other than where it should be. He also didn't realize that when you get data from a TCP stream you don't always get the amount of data you ask for, it could be less.

    I have been writing low-level device drivers and bootloaders for over 20 years and while programming has changed significantly for more powerful systems in userspace, for low level programming it has changed very little. My advice is to learn C and learn it well. Know what some of those keywords mean like static and volatile. Anyone who interviews in my group damned well better know what volatile means and how to use it.

    C isn't a very complicated language but it takes time to properly master. It also doesn't hold your hand like many modern languages, which is why you often hear it is easy to have things like buffer overflows or stack overflows and it's also easy to shoot yourself in the foot. It doesn't have many of the modern conveniences, but those conveniences often come at a cost in terms of memory and performance.

    The best book I've seen on the language was written by the authors of the language. It's not very long but it is concise and well written.

    The C Programming Language by Brian W. Kernighan and Dennis M. Richie.

    I have also worked on C++ device drivers. While the overhead of C++ itself is generally minimal, it depends that you use only a subset of C++ and you have to know what C++ is doing behind the sce

    --
    This post is encrypted twice with ROT-13. Documenting or attempting to crack this encryption is illegal.
  74. Re:A damn good reason to learn security best pract by lucasnate1 · · Score: 1

    There is a practical reason, programmer efficency. If that programmer compromises, he can do more work.

  75. You should learn C to become a better developer by Lisandro · · Score: 2

    The nice thing about C is that is as close to portable assembler as a language can get. It forces you to understand how computers and OSs work in order to become proficient, and in time your code will become better because of it - even when using other languages.

    Of course, the ugly thing about C is that is as close to portable assembler as a language can get.

  76. Re:A damn good reason to learn security best pract by fisted · · Score: 1

    So what is "the stack"? A core concept of C? Something the standard mentions in passing?

  77. No by zmooc · · Score: 1

    You should only use C if your program has at least one of the following properties:
    - It has extreme CPU efficiency demands; for example, it needs to use SIMD wherever possible and do so efficiently;
    - It has strong realtime demands. E.g. you're rendering video or audio live with very low latency or are reading sensors and controlling something mechanical and therefore cannot have a garbage collector stopping the world even for a millisecond;
    - It has extreme cross-platform requirements; you want to be able compile on many architectures.

    Each of these can be a reason to pick C. However, IoT in general is not. Whenever you can, please pick a language with proper memory management. And if you must absolutely use C, consider writing only the parts of your application that absolutely need it in C.

    When it came to selecting a programming language for writing a software synthesizer/sequencer, after extensive testing, there really wasn't any serious competition to C/C++/gcc w.r.t. auto-vectorization support and realtime characteristics. So I chose C++. And it is a world of pain. However, it is insanely mind-boggingly fast and even under heavy load will respond with sub-millisecond response times.

    So FFS please don't pick C(++) unless you absolutely must.

    --
    0x or or snor perron?!
  78. Re:A damn good reason to learn security best pract by phantomfive · · Score: 1

    Using strncat() has so many corner cases, I would recommend never using it. Too easy to make a mistake.

    --
    "First they came for the slanderers and i said nothing."
  79. Re:A damn good reason to learn security best pract by TFlan91 · · Score: 1

    This SO answer is a pretty good attempt at explaining it:

    https://stackoverflow.com/ques...

  80. Look at the whole stack... by Anonymous Coward · · Score: 0

    And you will see why C/C++ is important for IoT. What's the purpose of IoT? To make hardware available in the cloud. What are the pieces of the "stack"? You have some sort of SoC, an OS, your hardware(fridge, slow cooker, camera, scanner, etc), likely a web server and your app that runs on the web server. On the software components you have two main pieces: talking to the hardware and the app that runs on the web server. Those are two very distinctly different pieces of software and are best suited to be developed via certain languages. Would you use PHP or JS to talk to hardware? Heavens no, you use C, C++ to do that work. Conversely, would you write your web app in C? Heavens no. PHP, JS or another scripting language would do that job. And those two apps need to talk to each other so you also need to understand how both sides work.

    Same old axiom: use the right tool for the job; screwdriver to drive a screw, hammer to pound in the nail. Speaks to why we all have to have a wide range of skills and cannot squat on a single language or technology.

  81. Re:A damn good reason to learn security best pract by argStyopa · · Score: 1

    "Security best practices" would be to shitcan the entire idea of the internet of things as stupid and stop listening to marketing drones whose only motivation is to sell you some thing from which they can forever after farm data-demographic income.

    --
    -Styopa
  82. Re:A damn good reason to learn security best pract by bug1 · · Score: 1

    If that programmer compromises, he can do more work.

    In that case it doesnt matter what language the programmer uses, no language is idiot proof.

  83. Re:A damn good reason to learn security best pract by fisted · · Score: 1

    It was actually a rhetorical question. Standard C does neither specify nor require a stack or a heap, and memory allocation isn't specified in terms of those.
    I'm only pointing it out because of the GP implying that knowing about "the stack" implies competence at C, which is far from true.

    Or to put it differently:
    $ grep -iEc 'stack|heap' c11std.txt
    0
    $

  84. Yes by Anonymous Coward · · Score: 0

    Yes, you should learn C. If you don't know C, you are NOT a programmer. You are a hipster wannabe.

  85. Re:A damn good reason to learn security best pract by lucasnate1 · · Score: 1

    I think we define compromise differently. If someone decides to give up on the quality of something, willingly, not because he can't, but because he has better things to do for the project, why is he an idiot?

  86. Re:A damn good reason to learn security best pract by Anonymous Coward · · Score: 0

    Yeah sure. Blame the programmer for being forced to compromise by bad management or hardware practices.

  87. Re:A damn good reason to learn security best pract by Anonymous Coward · · Score: 0

    If you have no clue about how the computer works, have no idea how large local variables and large global variables differ even if you have only a main() function (for which you NEED to know about stack vs. heap, even though you wouldn't need to know it by those names) I claim you pretty much CANNOT be competent at practical use of C.
    Most people don't care if you could write C programs that would work great on a Turing machine, you absolutely need to know how to write a program that will work well on the actual machine IN FRONT OF YOU, and you can't do that without knowing about stacks, heaps etc.

  88. Re:A damn good reason to learn security best pract by Anonymous Coward · · Score: 0

    The Java serialization issue shows pretty much that those "more secure" languages don't help a bit if there is a cargo-cult mentality of insecure programming.
    In fact, Java made it even easier: Instead of fiddling around with stacks, things that might crash if the program was compiled with a different compiler etc, you nowadays just politely ASK the program to execute whatever code you want, and it just goes ahead and does it.
    You don't even need to have a clue about the CPU, OS, compiler etc.
    There is no point in choosing a language that makes sure all the cracks are nicely filled if your programmers are going to leave the front door wide open anyway. Or worse, your shiny new programming language by default leaves the frontdoor wide open via core language features and expects every programmer to know the obscure magic needed to close them - whether it's Java's deserialization, Windows' SetDllDirectory/SafeDllSearchMode etc.

  89. Re:A damn good reason to learn security best pract by Joce640k · · Score: 0

    If you cant sort out a buffer overflow then dont call yourself a programmer.

    If you can't see that std::string is a better choice then don't call yourself a programmer.

    --
    No sig today...
  90. Re:A damn good reason to learn security best pract by Anonymous Coward · · Score: 0

    A value is the contents of a memory address. A reference type, in C#, is a type that is derived from System.Object and is allowed to be null.

    Or were you asking the difference between a value type and a reference type? Syntax errors suck, even in English.

    BTW, it's worth noting that .Net's value types are still derived from System.Object, but aren't allowed to be null. Every variable in .Net is what C would define as a void**. A handle to an unknown. Yes, that includes both value types and reference types. They're a stack-allocated pointer to a heap-allocated pointer to a heap allocation. Every. Single. Time. Even System.IntPtr. In the reference implementation (Microsoft's .Net, as opposed to Mono or some other implementation of the spec), the only thing preventing value types from holding a null reference is some validation (C programmers just think "overhead") in the CLR.

  91. Re:A damn good reason to learn security best pract by Anonymous Coward · · Score: 0

    Or you have a different opinion than you have.

  92. Maybe? by FilmedInNoir · · Score: 1

    I wrote a program a couple weeks ago that flashes a red light that alerts of a new Twitter post. Uses a RPi 3 and the program was written in Java.
    Java has the ability to run threaded tasks easily which I wanted for polling the Twitter website. I could of used cron I suppose.
    I assume C has something similar but I know Java and Raspbian has Java.

    --
    Sig. Sig. Sputnik
  93. Re:A damn good reason to learn security best pract by Drethon · · Score: 1

    C was invented as portable assembly IIRC. If you cant sort out a buffer overflow then dont call yourself a programmer.

    Real programmers see their job as making the computers job easy, not the other way around.

    And one way a real programmer makes the computers job easy is making sure there code is as easy to work with for those who make updates after they are gone.

  94. Re:That too exists, LLVM bitcode (corrected) by SuperKendall · · Score: 1

    to really use it safely and properly you simply have to understand how computers work at the lowest levels.

    I've done a lot of assembly myself (in the past, not so much these days!). That has been really helpful over the years as I can understand performance issues a lot better than someone who does not have that background...

    I think though the computer industry has shown that even when someone truly understands the lowest levels of how computers work, they can easily write code that is not safe. I don't think there's any way past that other than an inherently safer language that still lets you access very low level parts of the system... Swift (and LLVM) is the first language/system I have seen that I think can take over for C.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  95. Re:A damn good reason to learn security best pract by Anonymous Coward · · Score: 0

    > Standard C does neither specify nor require a stack or a heap

    This is why I laugh when people call C a 'portable assembler.'

    Assemblers are dependent on machine architecture. C isn't even dependent on a Von Neumann architecture.

  96. C - just do it by shortscruffydave · · Score: 1

    C is awesome - that is reason enough to learn it

  97. No. Please don't learn C. by Anonymous Coward · · Score: 0

    Please just stay a script kiddie. Stay ignorant of how the system works. Just relax and believe the folks who tell you that you can do anything you need with Java, Rust, Go, and Swift. Learning the metal is for old guys and non-social weenies who don't even have Facebook, Twitter, and Instagram accounts. You don't need to know that stuff, honest. Slasdhot is right. Nobody hires C coders, uhh, yeah, it's dead and stuff like that.

    Those people who tell you that C is the most portable language in the world are just old greybeards. Ignore them. C is just old and krufty and C coders are just butthurt that they don't know Python & PHP. Yeah, that's the ticket.

    You can totally just learn "security" and not learn how things work. Just listen to the folks who got their CISSP recently, they can tell you. It's all about certs and the public perception of what languages you code in. Once you learn how to run a few metasploit hacks, you're set to get an elite job at a pen-test firm were the other cool kids hang out.

    Let my life be a cautionary tale. I spent all that time learning C and a few dialects of ASM, alas, just to be surpassed by script kiddies. I'm now broke, friendless, bitchmade, and homeless. It's terrible. All because I learned C instead of the cool languages.

  98. Re:A damn good reason to learn security best pract by Anonymous Coward · · Score: 0

    Been writing security focused C code for over 10 years. We do code reviews and use tools to find problems in the code. I hardly ever see a buffer overflow. You really are either a poor programmer or a really poor company if you let buffer overflows into your code in this day and age.

    Having said that, there are several other problems with using C, but the other option is C++ and C++ has overlap with some of the issues C has and has some of its own problems as well.

    Having said that, sometimes I really wish C had length checking on arrays built in, even though I understand why it doesn't...

  99. C is the reason to learn C by Anonymous Coward · · Score: 0

    C is the reason to learn C. If you don't understand this, you need to go back and get better at C.

  100. Re:A damn good reason to learn security best pract by fisted · · Score: 2

    You've got it backwards. Yes, I do know x86 and the pertinent C implementations rather well. But no, since C abstracts those concepts away, there is a) no need to and b) it actually makes things less portable if you have implicit assumptions about what the machine has and does WHEN C ALLOWS YOU TO NOT CARE ABOUT IT.

    So please tell me, given the code
    int a, *b = malloc(sizeof *b);

    What exactly is the advantage of thinking about `a` and `b` as "on the stack" and `*b` "on the heap"? I truly don't get it.
    What is the problem with thinking about `a` and `b` as having automatic storage duration+block scope, and `*b` having allocated storage duration? It's THOSE TERMS that have well-defined semantics that EVERY C implementation (including those that put things "on the stack"/"on the heap") *has* to comply with. (That is apart from the fact that something you think is "on the stack" might well be NOT on the stack because it's "in a register", or got opimized out entirely, rendering your stack/heap categorization as a heuristic at best).

    Learn some C. Make your programs more portable. You'll end up a better C programmer.

  101. all stacks are c/c++ by Anonymous Coward · · Score: 0

    I program on ST micro's Cube, Silicon Lab's Simplicity Studio, NXP's Kinesis and ARM's mbed-os.

    The first three are C, the last is C++.

    It is all very very simple C syntax (compared to advanced techniques used in the GNU source).

    The language is not the barrier. The insane complexity of the stacks is the barrier. I've been programming in C since 1986, but understanding how to code the subtle issues of the BLE implementations for all four stacks took fucking FOREVER.

  102. Re:A damn good reason to learn security best pract by bug1 · · Score: 1

    If the programmer is willing to compromise on usability and quality because there are better things to do, then how do you maintain quality control ?

    Its just a matter of time until that 'better thing' he has to do is add another feature rather the bug check existing features.

  103. Re:A damn good reason to learn security best pract by lucasnate1 · · Score: 1

    Right now I am playing a game called OpenRA. The game crashes for me sometimes when on the main menu and never crashes during gameplay. The game also suffers from a gameplay imbalance. Currently more effort is invested in adding these new balance feautres than in main menu ui stability. The balance is, imho, the "better thing". If the bug was fixed then we'd have a slightly more stable program on account of a crucial feature.

    Ideally both things (ui bug + balance) should be fixed. Practically, time is limited.

  104. No by Anonymous Coward · · Score: 0

    C is arguably the most important programming language in history. If you don't already have some working knowledge of C you're not a serious programmer to begin with and will reap little benefit from some IoT boom.

  105. Re:A damn good reason to learn security best pract by Anonymous Coward · · Score: 0

    For the users, not the programmers.

  106. If using a framework, then its not up to you by theDerek · · Score: 1

    I own a company that does hardware and firmware, mostly for projects in the IoT space. We've had clients hire us to connect all sorts of dumb stuff to the internet. Many times you're using a chip that has a framework or stack that already exists; be it BLE, or Wi-Fi, or even Sub-1GHz (my personal favorite, it's the Denny's of wireless protocols). These frameworks are usually written in C. So while it's possible to incorporate them into a C++ project, usually it's just not worth the time or risk; it's easier just to leave it in C. The key to writing in C is to make it as human readable as possible. Code is written once, but read many times. So don't just use shitty variable names like "count"; use something that makes sense like associatedDevicesCount. That being said, for tight loops, i is just fine. It's also interesting how little customers care about security, even when our team brings it up. We're always trying to strike a balance. More security generally means more time during manufacturing (loading keys, etc.) or making the product harder to use. With manufacturing time going for (in US) about $1 per minute, we want to keep things moving. And clients hate dealing with customer support calls because the user can't get his miniblind controller to talk to his iPhone. C is also very popular for lonely devices - things that have to sit out there and just transmit information periodically, and are difficult to reset if the firmware goes haywire. I'd bet that 99% of iBeacons are implemented in C. Certainly the ones we've made are in C. All that being said, I'd like to try C++ on a new project; if nothing else for fun.

  107. Re: A damn good reason to learn security best prac by Anonymous Coward · · Score: 0

    DSPs are usually Harvard architecture, not von Neumann.

  108. Re:A damn good reason to learn security best pract by Anonymous Coward · · Score: 0

    It's really easy to right things quickly in scripting languages but the bloat there is phenomenal. I needed a little minimal command line script to call a glibc function and output the result. It's easier in a scripting language unless it doesn't give access to the underlying calls needed.

    Anyway this is only one example case but point is that if I do it the easiest way in each, C gives me a few KB program that runs quickly, takes only a few KB of memory where as achieving the same in a scripting language means reading MBs of libs, engine from the HDD,. big engine bootstrap, loading into memory, etc and basically makes a big nasty memory spike to get something really simple.

    Modern embedded hardware is still often beefy enough to now run a lot of stuff on interpreted but despite that there's still a benefit to using an amount of C and will be for a long time.

  109. Re:A damn good reason to learn security best pract by Anonymous Coward · · Score: 0

    > I have to prevent buffer overflows myself at the present time

    You should have to even in a high level language. When you get an out of range exception because the language caught it for you, that's not a mechanism you're meant to rely on, instead it's a safety net. There might also be some higher level conveniences for such checks which isn't quite the same as a safety net.

    If you're a seasoned programmer you should find yourself saying instead that C doesn't have your back as much as it could because ultimately no one is flawless, even seasoned developers and it's better the compiler reminds them of this if they can rather than a hacker. Word of warning as we can get back into the dependency trap with that. Ultimately when programming, you have to program which means staying alert as to what you're doing.

  110. Re:A damn good reason to learn security best pract by Anonymous Coward · · Score: 0

    This why when I write with Python I call it a script. I'm a scripter, not a programmer. Not sure about the use of "coder" though?

  111. Re:A damn good reason to learn security best pract by Anonymous Coward · · Score: 0

    Python can be used as a scripting language (i.e. a language that targets other programs), but it is a full-fledged "real" programming language.

    I don't know where people get the idea that any interpreted language must be a scripting language?

  112. Re:A damn good reason to learn security best pract by Anonymous Coward · · Score: 0

    > how a stack overflow happens

    Ooh! Ooh! I know this one! How it happens is, first you log in, then you create a question and paste in the code from your assignment. (Be sure to paste in only a little snippet, leaving out silly things like import statements and function signatures, and change variable names to things like "a" for anonymity). Then you wait a while until some grumpy old-timer posts a link to an identical three-year-old Stack Overflow question. Then you click on that link, copy the code from the highest-rated answer, and paste it back into your assignment. When it compiles, you're all set! Simple!