Slashdot Mirror


Ask Slashdot: Is it Practical To Replace C With Rust?

interval1066 writes: I've heard of rust from various sources around the net for a few years and never paid it much mind, there are so many new languages out now since my early days doing C programming, which what I've stuck to and made me my career. Now I'm heading a project that uses a RoR application to control a large series of sensors and controls in a manufacturing process. Naturally I want to talk to the hardware using a GEM extension written in C, as I've done before.

But another engineer who is not a fan of C (seems few younger engineers are) said he could write the extensions needed easily in Rust. Seems like this is a thing. I took a closer look at rust and it looks to me like another attempt at "C" without pointers, except rust does have a kind of pointer, it appears. I like its ranking on a list of fastest languages, and it seems pretty simple with an initial tool footprint that is quite small.

But what are the trade offs? Another language, and one that few engineers know (much like Vala, which I like very much but has the same small user base). What if I need another engineer to work on the code? I pretty much know what I can expect from C/C++, rust is a huge unknown, what if I run onto a roadblock? The engineer pushing for rust is emphatic, should I bulldoze him or take the plunge?

287 of 437 comments (clear)

  1. You know the old saying... by __aaclcg7560 · · Score: 5, Insightful

    No one ever got fired for using C.

    1. Re:You know the old saying... by cruff · · Score: 5, Funny

      No one ever got fired for using C.

      Someone at Volkswagen might.

    2. Re:You know the old saying... by transfire · · Score: 2

      There is always risk with embracing new tech, but I would be willing to bet you won't be disappointed with Rust.

    3. Re:You know the old saying... by Tablizer · · Score: 1

      No one ever got fired for using C.

      That phrase has also been used for heyday IBM and Microsoft. But both sucked.

      Sometimes you have to choose between money and sanity.

    4. Re:You know the old saying... by __aaclcg7560 · · Score: 2

      I don't think you can blame the programming language for that one.

    5. Re:You know the old saying... by Mirar · · Score: 2

      I thought Bosch wrote that code and told WV not to use it like that. Anyway, it's probably written in Simulink.

    6. Re:You know the old saying... by hawguy · · Score: 4, Insightful

      No one ever got fired for using C.

      That phrase has also been used for heyday IBM and Microsoft. But both sucked.

      Sometimes you have to choose between money and sanity.

      It used to be true of IBM -- as long as you were willing to pay, you could get near perfect uptime and nearly unlimited scalability. But you definitely had to pay for it -- we had a dedicated IBM service rep with an office in our data center, that sort of service doesn't come cheap. But we had no significant downtime in my 4 years there. Sure we had some jobs fail here or there due to DASD failures, but the core mainframe never had a hiccup and we completed several online hardware upgrades with no downtime.

      Of course, I can get even better scalability and uptime with a distributed system (geographically distributed) on commodity hardware today, but that wasn't always a viable option.

    7. Re:You know the old saying... by shaitand · · Score: 5, Insightful

      C has it's ups and downs but sucking isn't one of its properties.

    8. Re:You know the old saying... by DutchUncle · · Score: 5, Insightful

      No one ever got fired for using C.

      That phrase has also been used for heyday IBM and Microsoft. But both sucked.

      Heydey IBM didn't suck. You whippersnappers just don't appreciate what we had to do on mainframes to lay the groundwork for distributed computing. A lot of the ultra-modern pipelining in processors can be traced directly to Cray and Amdahl and other designers from the golden age, and if they could have had as much spare hardware and memory as a modern system-on-chip without blowing up both a bank and the power grid, who knows how much further we'd already be.

    9. Re:You know the old saying... by Tablizer · · Score: 1

      IBM hardware was indeed reliable. However, from a software developer's perspective, it was known to have awkward tools. JCL alone drove some insane.

    10. Re:You know the old saying... by willworkforbeer · · Score: 3, Funny

      Heydey IBM didn't suck. You whippersnappers just don't appreciate what we had to do on mainframes to lay the groundwork for distributed computing.

      And in those day, laying groundwork was uphill. Both ways.

      --
      Pretending this is my office full of bitter coworkers..
    11. Re:You know the old saying... by Beck_Neard · · Score: 2

      I know that's a joke, but it's of course nonsense. Plenty of people have gotten fired for using C, especially when their code had dangerous security vulnerabilities (which it ALWAYS does).

      --
      A fool and his hard drive are soon parted.
    12. Re:You know the old saying... by BigMattyC · · Score: 1

      I thought Bosch wrote that code and told WV not to use it like that. Anyway, it's probably written in Simulink.

      "written"

    13. Re:You know the old saying... by DickBreath · · Score: 1

      Was modern mental health treatment unable to help those individuals who suffered from having used JCL?

      --

      I'll see your senator, and I'll raise you two judges.
    14. Re:You know the old saying... by Beck_Neard · · Score: 1

      I'm going to invent a gun that 1/10 of the time shoots the bullet out from the back, towards the user's face. I will call anyone who can't use my gun safely a bad gun user.

      --
      A fool and his hard drive are soon parted.
    15. Re:You know the old saying... by Anonymous Coward · · Score: 1

      BS. I got fired for not being a C++ Uber-Alles weenie.
      Dumb, but as I was not a Tel-Aviv-based-developer@AMD working on the OpenCL debugger, and being intolerant of Mho-Rhons who (seem to persist to this day) that "pretty" is better than "correct" at AMD, I got let go in the great software purge of 201x. Yes, the same one when Ben Bar-Haim got rewarded for his ineptitude.

    16. Re:You know the old saying... by iplayfast · · Score: 1

      point the end where the bullets come out away from you!

    17. Re:You know the old saying... by Megane · · Score: 1

      They were given training in MUMPS to help them recover from the effects of JCL.

      --
      #naabhaprzrag, #sverubfr-000, #agi-fcbafberq, negvpyr[pynff*=' negvpyr-ary-'] { qvfcynl: abar !vzcbegnag; }
    18. Re:You know the old saying... by TapeCutter · · Score: 1

      The phrase came from an IBM marketing campaign.

      --
      And did you exchange a walk on part in the war for a lead role in a cage? - Pink Floyd.
    19. Re:You know the old saying... by vtcodger · · Score: 1

      JCL -- described by one early user as the world's first syntax free language. See https://en.wikipedia.org/wiki/...

      --
      You can't see ANYTHING from a car, You've got to get out of the goddamned contraption and walk...Edward Abbey
    20. Re:You know the old saying... by pdxtabs · · Score: 2

      This is very true, but...

      I am a Senior Embedded Software Engineer at a Fortune 500 company. I work on a code-base of millions of lines of C with 300 of my closest development buddies who are located all over the world. The distribution of abilities is as you would expect with this statistically significant sample of developers. I spend a lot of my time tracking down tricky memory corruption bugs in C by hand that would have been caught by the Rust compiler. What's more, dangling pointers and buffer overflows are the worst kinds of bugs because they often lead to security vulnerabilities.

      An excellent engineer can write excellent C, but a poor engineer can overflow buffers and leave dangling pointers hanging around... but not in Rust.

    21. Re:You know the old saying... by pdxtabs · · Score: 1

      It takes work to write safe code in C. Your worst developers will use uninitialized variables, pointers to previously freed memory, and overflow buffers. But not in Rust.

    22. Re:You know the old saying... by maharvey · · Score: 1

      Obviously you should just hold the gun sideways, or over your shoulder. So yeah, bad gun user.

    23. Re: You know the old saying... by Demena · · Score: 1

      Sarcasm is invisible to you? Ok, so why do YOU think the remark was made?

    24. Re:You know the old saying... by Tablizer · · Score: 3, Insightful

      It think it's safe to say that C as a language is optimized for speed, size, and hardware issues instead of software engineering issues.

    25. Re:You know the old saying... by gweihir · · Score: 2

      On the minus side, a poor engineer will not even be able to do Rust at this time, so Rust benefits form that you likely get better people as you either have to get one of the very few people that can do Rust or get one that can learn it fast.

      That said, do not mix languages on a large project unless you have to. And of you really go Rust, make sure you have more than one engineer who can work with it. Also counting against Rust is that it is too new.

      I would also say that the person insisting on Rust is acting hugely unprofessional and trying to push his personal agenda on the project. That alone would be a valid reason to "bulldoze" him.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    26. Re:You know the old saying... by ziggystarsky · · Score: 1

      It takes as much work to write safe code in Rust.

      The upside is that the unsafe code will not compile under Rust.

    27. Re:You know the old saying... by michelcolman · · Score: 1

      I can imagine what that e-mail was like. "Here's the code to cheat on emissions tests, only for 'testing' purposes, don't use it in production cars, wink wink..."

      "O, and how many millions of licenses did you want?"

    28. Re:You know the old saying... by TheRaven64 · · Score: 3, Interesting

      It's optimised for speed, as long as your target is basically a fast PDP-11. C does not allow the compiler to rearrange data layouts, which makes it hard to take advantage of SIMD or to avoid false sharing. C makes it very hard to statically reason about memory ownership, requiring a defensive programming style with redundant operations when writing multithreaded code. C only recently had a memory model for concurrent accesses at all and so most multithreaded C programs contain undefined behaviour.

      --
      I am TheRaven on Soylent News
    29. Re:You know the old saying... by TheRaven64 · · Score: 2

      An excellent engineer can write excellent C, but a poor engineer can overflow buffers and leave dangling pointers hanging around... but not in Rust.

      A poor developer will write C code that doesn't work at all. A mediocre developer will write C code that works, but is rife with security vulnerabilities. An excellent developer will write C code that needs an excellent attacker to exploit. Unfortunately, the world has quite a lot of excellent attackers in it.

      --
      I am TheRaven on Soylent News
    30. Re:You know the old saying... by T.E.D. · · Score: 1

      C has it's ups and downs but sucking isn't one of its properties.

      This is true only in the case where you are writing the code for a vacuum cleaner.

    31. Re:You know the old saying... by __aaclcg7560 · · Score: 1

      Pity the fool who has to write C for an appliance that truly sucks.

    32. Re:You know the old saying... by luis_a_espinal · · Score: 4, Informative

      It takes work to write safe code in C.

      Same with Java and even Ruby - Null refs, running out of mem, not closing database connections, etc - things that also characteristics of unsafe code. I've done the lot of it, C, C++, Assembly, Java, Python, what have you. For e-commerce as well as low level stuff.

      And I've seen unsafe code written in all of them. Treating pointers as ohhh-chupacabara! is just ridiculous. People who program with discipline avoid those problems, whether they program in C or Python or what have you.

      Your worst developers will use uninitialized variables, pointers to previously freed memory, and overflow buffers. But not in Rust.

      Don't worry. Your worst developers will find ways to create unsafe code in Rust in one way or another.

    33. Re:You know the old saying... by TemporalBeing · · Score: 3, Insightful

      I know that's a joke, but it's of course nonsense. Plenty of people have gotten fired for using C, especially when their code had dangerous security vulnerabilities (which it ALWAYS does).

      Wrong.

      Yes, people have been fired for being bad programmers. I doubt many have been fired over security vulnerabilities, most likely because either (a) the vulnerability was discovered after the programmer already voluntarily left or (b) was rooted in standard operating procedures (e.g you just don't do that) - most due to people not realizing the consequences of network computers. (Prior to networking, security didn't really matter too much outside of specialized environments.)

      Further more, C-based software probably runs about 99+% of devices out there - most notably everyone's favorite OS kernel - Linux - is entirely written in C, as is the Windows NT Kernel, the BSD Kernels, etc. Most all operating systems use it at the core, and many applications use it - IOW, the world runs on C; aside from Assembly is it probably the most used programming language out there when you look at all aspects of software (even C++ doesn't compare). It only bites you if, like with any tool (including Java), you mis-use it. Best practices will save you from 99.99% of issues.

      Oh, and the OS's that don't use C in their kernel? They're all research or hobby stuff that more or less proves you could do it, but the performance is so abysmal (compared to the same thing in C) that no one would really use it, or they use C to bootstrap and load into their alternative language - typical of C++ OS Kernels. (Yes, there have been Java-based Operating Systems; they also relied on specialized hardware-based JVMs and no one uses them outside of small research projects.)

      --
      Truth is like the sun. You can shut it out for a time, but it ain't goin' away. - Elvis Presley (source: imdb.com)
    34. Re:You know the old saying... by Mike+Van+Pelt · · Score: 1

      Well, let's put it this way... using JCL is sort of like reading The Necronomicon.... until you understand it

    35. Re:You know the old saying... by Tablizer · · Score: 1

      What's an existing language that can and does (practically) take advantage of the tricks you mention? And if so, how come it's not replacing C in any noteworthy quantity for hardware-centric uses?

    36. Re:You know the old saying... by pohl · · Score: 1

      Rust. Because it's relatively new.

      --

      The "cue the foo posts in 3, 2, 1..." posts will commence with no subsequent foo posts in 3, 2, 1...

    37. Re:You know the old saying... by Nubbywubwub · · Score: 1

      Rust has pointers. Rust has pointers all over the place. What sets Rust apart is that the compiler checks code for improper pointer usage and disallows it unless you explicitly tell it to chill out using the "unsafe" keyword. It trivializes code auditing by making it so you just need to grep for the word "unsafe" to know where the source of any segfault (or any other memory error) must lie. So no, it's not a silver bullet (nothing is), but it's a hell of a lot easier to write low-level memory-safe code in Rust than it is in C.

    38. Re:You know the old saying... by TheRaven64 · · Score: 1

      In 2012, around 80% of all security vulnerabilities exploited in the wild came from some memory safety error. If you use Java, or you use C++ with strict discipline about the use of shared_ptr / unique_ptr, then you immediately remove the possibility of these kinds of vulnerability. You may still fail to sanitise inputs and allow other kinds of high-level vulnerability, but at least eliminating 80% of vulnerabilities would be a nice start.

      --
      I am TheRaven on Soylent News
    39. Re:You know the old saying... by TheRaven64 · · Score: 1

      Java can take advantage of some, though most existing JVMs don't. A few research projects do. If we're talking about the language, rather than the language implementation (on the basis that the latter can improve without changing the source), then any language that makes field order undefined can take advantage of these things. If the language has primitive integer types, then exploiting SIMD in its equivalent of structs is much easier.

      For concurrency, you want a language that either has garbage collection, or one that strictly enforces the shared xor mutable rule. Garbage collection means that you can have concurrent mutation with no synchronisation, though you pay a penalty when it comes to actually running the collection. Pony takes the latter route (as does Erlang, though via a degenerate case of having no mutable state other than the process dictionary).

      A modern language should be designed from the ground up with three primary concerns:

      • Security and, in particular, compartmentalisation. It should be easy to take a program and split a part of it into a separate process with limited rights (i.e. all communication between parts of the program must be explicit). Erlang meets this requirement, few other languages do.
      • Error handling must be easy. This is really hard to get right. Common Lisp had some nice models for error handling, but most later languages have been fairly horrible. Maybe types are one mechanism for this, but they're only part of the solution. It should be obvious when reading code in the language that error handling has been omitted and the error-handing paths should be easy to test (because a huge number of bugs end up there if they're not).
      • Concurrency. With modern systems (even cache-coherent SMP systems), this means minimising sharing of mutable data and providing primitives for explicit communication. A few languages (Erlang, Go, and even Rust) manage this to a degree.

      I look forward to someone developing a modern language (I have some sketches of a design, but nothing concrete - hopefully someone with more free time than me will get to it before I do). Aside from these goals, the language should be designed for modern tools (e.g. static analysis should be part of the normal development cycle), should have some form of static elaboration (more in the Bluespec style than C++ templates) and should interface cleanly with legacy code in C/C++ (though should have the option of running this code in a separate process, for security).

      --
      I am TheRaven on Soylent News
    40. Re:You know the old saying... by Tablizer · · Score: 1

      But you seem to be talking about changes in developer behavior and design approach. That complicates the hardware-centric comparison. As far as existing and typical programs (as currently done), C-compiled programs usually beat their competitors.

  2. Cant we just talk directly instead? by Anonymous Coward · · Score: 5, Funny

    Im just 2 cubicles away from you, sad i read about it here

    1. Re:Cant we just talk directly instead? by __aaclcg7560 · · Score: 1

      Don't feel bad. On the day I was appointed as an assistant lead for a video game title, management decided to kill the title. I didn't find out until I saw a news item posted on an industry gossip website a month later. The QA manager didn't know. No wonder the new build was late.

  3. Is it practical to keep developing in C? by Anonymous Coward · · Score: 5, Informative

    You should definitely investigate rust. It's very well designed. It has great support to call into C code and C libraries. It compiles fast. The standard library is much more convenient than C/C++. You have complete memory safety by default, without garbage collection. It has great support for safe multithreading. Over time, your speed will increase because you won't be spending weeks tracking a heisenbug due to memory corruption. There is some learning overhead, but it's worth it.

    The biggest issue is that you won't have as big of an ecosystem around rust. You won't find good support for all of the libraries that you might want to use. But those problems aren't insurmountable.

    1. Re:Is it practical to keep developing in C? by D.McG. · · Score: 1

      You, my friend, need to learn about precompiled headers. If your modules have more than one include statement, you're doing it wrong. Large projects can compile quickly if set up correctly. Also, modern compilers can compile 8 files from a single project in parallel on an I7. I don't know if it's still true, but Visual Studio is / was terrible at this; only compiling single files from multiple projects in parallel. This caused bloat in the solution with multiple projects to get any kind of speed improvement in build times, at the cost of complexity.

    2. Re: Is it practical to keep developing in C? by TekPolitik · · Score: 1

      This strikes me as a complete answer. If it has good support for calling out to (native) C ( and you have the skills to do that when needed) and does not have the memory blowout of Java, you are losing nothing by basing the project on Rust instead of C.

    3. Re:Is it practical to keep developing in C? by jellomizer · · Score: 1

      It depends, I don't see Rust replacing C any time soon. And if you are trying to do applications of any particular depth, it may not be the best choice. A lot of the extra libraries/crates vie Cargo are not so mature yet, and finding the best one for you needs is really a crapshoot, as well some of them that is available seem rather questionable.
      I expect over time there will be some weeding out the junk and building on and expanding the core libraries.

      Yes you can go alone without using extra libraries, but other than learning how to do it yourself, you are just duplicating work that some one else has done, and probably put a little more time to fix many of its issues.

      --
      If something is so important that you feel the need to post it on the internet... It probably isn't that important.
    4. Re:Is it practical to keep developing in C? by david_thornley · · Score: 1

      The standard library is much more convenient than C/C++.

      C and C++ are two different languages. I was going to ignore it, but you mentioned the standard libraries. Those aren't really similar, except that C90 library facilities are in the C++ standard library.

      How does the Rust standard library compare with the C++ standard library?

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    5. Re:Is it practical to keep developing in C? by TapeCutter · · Score: 1

      compiling single files from multiple projects in parallel

      Yes it still does that, recent versions of visual studio (2013 in my case) run two or more compile/link threads, one sub-project per thread. We had been stuck on 2008 for a long time (due to itanium support) so it confused the hell out of me until I realised what it was doing.I have not noticed any significant speed increase using the threaded compiler, disc speed still appears to be the main determinant of build time.

      I did find I had to explicitly state every sub-project's build order dependencies after visual studio upgraded the project files. With a single thread you can build your libraries first and simply ignore the build order dependencies. I don't understand why the user has to specify build order dependencies in the first place, surely the tool could work it out from the linker dependencies that the user has already defined? Also when opening a large project to make a small change, 'intellisense' is working its arse off in the background and slowing down the GUI response time, so much so that I now prefer notepad for minor changes to the project/solution files.

      Having said that, I still think VS is the best (free and proprietary) IDE for developing C/C++ code on windows. Eclipse is comparable to the free version of VS but you are very likely to find VS is already mandated in a commercial setting. In most places this is simply inertia, ie: there is nothing about Eclipse that is worth the migration/integration effort.

      --
      And did you exchange a walk on part in the war for a lead role in a cage? - Pink Floyd.
    6. Re: Is it practical to keep developing in C? by D.McG. · · Score: 1

      Not true, the same header can be compiled on multiple platforms. We're doing it on Mac, iOS, and Android. Our full build time from clean on Mac for our very large project is 90 seconds.

    7. Re:Is it practical to keep developing in C? by TapeCutter · · Score: 1

      [On] a c++ project that compiles on multiple operating systems, it's really hard to continue using precompiled headers

      In practice, not so much...

      #ifdef OS_WINDOWS
      This is where you specify windows eccentricities
      #else
      This is where you specify *nix eccentricities.
      #endif

      --
      And did you exchange a walk on part in the war for a lead role in a cage? - Pink Floyd.
    8. Re:Is it practical to keep developing in C? by NotInHere · · Score: 1

      This. The two biggest rust projects rustc and servo don't even compile with stable rust. And both get developed by those who really know rust. Yes, it makes sense to have unstable intrinsics for a compiler, but not even a slower compat mode??

      And the language itself may be guaranteed to be stable, but many many libraries aren't, and lots of the language's features are only available as unstable. It happens that crates break their API, because their devs don't care or don't know.

    9. Re:Is it practical to keep developing in C? by balajeerc · · Score: 1

      You'll never have to wait 15 minutes for a large code base to compile because you touched a header file.

      Then that large code base was written by incompetent people. Using forward declarations wherever possible greatly cuts down compilation time due to touching a header. Or using good design practices such as programming to an interface (where the implementation header won't be included directly in client code and the implementation header is where most of the changes will be happening most of the time).

    10. Re:Is it practical to keep developing in C? by interval1066 · · Score: 1

      I still think VS is the best (free and proprietary) IDE for developing C/C++ code on windows.

      It was written by the same beast that created Windows. Small wonder.

      --
      Python: 'And then suddenly you have a language which says "we're all stuck with whatever the whiniest coder wants".'
    11. Re:Is it practical to keep developing in C? by gweihir · · Score: 1

      The biggest issues are actually that it is immature and that it is yet another language attempting to fix bad coders, which is something a language cannot do. Hence it was created for all the wrong reasons and it shows.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    12. Re:Is it practical to keep developing in C? by jannewmarch · · Score: 1

      The Go programming language was invented partly to get rid of hour-long compile times of C/C++ programs. Rob Pile and co know what they are doing - naive solutions don't work with million line programs made up of thousands of files

    13. Re:Is it practical to keep developing in C? by TheRaven64 · · Score: 1
      The total time to parse about 5-10MB of C includes, on a modern machine, is a few tens of milliseconds. It has almost no impact on a modern C program - if you're compiling with optimisation, you'll spend far longer in the optimisers than in the parser.

      C++ is different, because it's not just the parsing, it's also the template instantiation. This is where you burn time. You also lose a lot if you have definitions in the headers where you have generate code, then you'll spend time parsing, more time generating your compiler's intermediate representation, more time optimising it, more time generating code, and then even more time in the linker throwing it away.

      --
      I am TheRaven on Soylent News
    14. Re:Is it practical to keep developing in C? by TemporalBeing · · Score: 1

      You, my friend, need to learn about precompiled headers. If your modules have more than one include statement, you're doing it wrong. Large projects can compile quickly if set up correctly. Also, modern compilers can compile 8 files from a single project in parallel on an I7. I don't know if it's still true, but Visual Studio is / was terrible at this; only compiling single files from multiple projects in parallel. This caused bloat in the solution with multiple projects to get any kind of speed improvement in build times, at the cost of complexity.

      I avoid pre-compiled headers at all cost. They only cause problems with builds, and typically don't save me anything since to correct those problems you have to blow away the pre-compiled headers any way.

      There are different methods of being able to manage the header bloat you mentioned. On method (in C++) is forward declarations - e.g. you don't include any classes, etc; you just forward declare them, which works wonderfully when you keep the implementation out of the headers. The other big method (my favorite) is keeping you headers clean and well separated - including only what you have to and not everything under the sun (e.g no "#include " type stuff).

      --
      Truth is like the sun. You can shut it out for a time, but it ain't goin' away. - Elvis Presley (source: imdb.com)
    15. Re:Is it practical to keep developing in C? by luis_a_espinal · · Score: 1

      Yeah. precompiled headers are great when you're working on a project in Visual Studio. But as soon as your large team goes off and creates a large complex build systems for a c++ project that compiles on multiple operating systems, it's really hard to continue using precompiled headers. Gcc has support for precompiled headers but it appears almost no one uses it.

      C++ is supposed to have real module support one day. It was going to be in C++14 but it was delayed. Maybe that'll be nice. But knowing C++, it'll end up being a hugely complex beast.

      This tells me your experience with C/C++ is rather shallow.

    16. Re:Is it practical to keep developing in C? by Nubbywubwub · · Score: 1

      yet another language attempting to fix bad coders, which is something a language cannot do

      Phew, glad to hear it! I'll inform the telcos that they can rewrite their infra from Erlang to PHP, since you've handily disproven the notion of safety benefits that are intrinsic to a language.

    17. Re:Is it practical to keep developing in C? by gweihir · · Score: 1

      In case you do not know it already: You are of these with a far bigger opinion of themselves than they can support by any actual skill and insight.

      Maybe read up on what Erlang is? And why it was created? Here is a hint: You do not have bad coders working on telephone-switch software or your infrastructure comes crashing down on you. What you do, for example, is patching it at run-time without stopping the software. That is what Erlang makes possible. Of course this is orders of magnitude more complicated and risky than normal software-engineering and hence Erlang supports all the domain-specific help it can. But it most decidedly does not attempt to be a language for the incompetent like Rust.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  4. pointers & C by Skewray · · Score: 4, Insightful

    The whole point of C is to be close to the hardware. The hardware has pointers. Why obfuscate?

    1. Re:pointers & C by serviscope_minor · · Score: 4, Informative

      Sigh.

      Rust does have pointers and it is close to the hardware. It has a very similar machine model to C and of course C++. It also has an advanced, modern type system that disappears during compilation which makes large classes of error which are easy in C flat out impossible.

      It's not obfuscation. You're telling the compiler what your intent is and the compiler checks that you're doing what you say.

      To the OP: it might not be a bad idea. Though if you're considering C and Rust, you really ought to have C++ on the table. It's got the same resource footprint as the other two. You can be much less foot-shooty in C++ than C if you use modern style (no loss of efficiency either), and the tooling is much more mature than Rust.

      There's really no reason ever to use C over C++ if you have a C++ compiler available.

      --
      SJW n. One who posts facts.
    2. Re:pointers & C by Anonymous Coward · · Score: 2, Informative

      Obviously C has abstraction to some degree from the hardware, or you'd just use assembly. So you're basically arguing "C has what C has, so why wouldn't you use C?"

      The answer is because there are problems with C, including pointers. If you pass a pointer to a child thread in C, what happens when you write through that pointer in the main thread? You're not required to use locks, and you're not required to remember that you don't own the pointer any more, so it's very easy to make a mistake and use a pointer when you're not supposed to. That's not so in Rust.

      Just like static typing eliminates an entire class of error that you find in dynamic typing, Rust's borrow checker eliminates an entire class of error that you find in other languages. To pretend that there's no reason to look for an alternative to C is pretty ridiculous.

    3. Re:pointers & C by lgw · · Score: 1

      To the OP: it might not be a bad idea. Though if you're considering C and Rust, you really ought to have C++ on the table. It's got the same resource footprint as the other two. You can be much less foot-shooty in C++ than C if you use modern style (no loss of efficiency either), and the tooling is much more mature than Rust.

      There's really no reason ever to use C over C++ if you have a C++ compiler available.

      So many bad books on C++ make this very hard for people to learn. I haven't yet found a good site for explaining why and how to have empty destructors for all but a few carefully-reviewed library classes (this is more than just RAII, or perhaps it's the golden version of it). Heck, it'd be nice to find a good guide to the latest standard, with a bunch of new anti-foot-shooting tools, plus "concepts" to allow much more sane templating for performance.

      Heck, even explaining how to use std::strings and vectors with no performance loss vs C would be a wonderful thing in a "learn C" website or book. 9plus a nudge to switch to hashmaps instead of the old maps) This stuff isn't complicated in practice, and it belongs in introductory works.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    4. Re:pointers & C by Anonymous Coward · · Score: 1

      Rust basically has pointers, but it's modeled in a nicer and safer way. There is a lot to be desired from raw pointers. Memory safety is a huge problem for stability and security. So are dangling pointers and dereferencing null pointers. These are huge maintainability headaches for large C and C++ code bases like Firefox. If they could be modeled in a nice way with zero overhead, it would be a huge win. This is exactly what rust does. It has "Optional" support for nullable pointers, references for non-null pointers, and fat pointers and slices to handle bounds checking. The ownership model on top of it provides excellent protection against dangling pointers and the ability to use multithreading in a fearless and safe way. Rust is a huge win for maintainability and security.

    5. Re:pointers & C by Darinbob · · Score: 1

      I wish I could have C++, but stuck with C. I don't want the ugly parts of C++, but the simple stuff like slightly better typing, simple non-virtual classes, etc. Most of the people who objected to it are gone now though, so...

    6. Re:pointers & C by Beck_Neard · · Score: 1

      The whole point of assembly is to be close to the hardware. The hardware has registers. Why obfuscate?

      --
      A fool and his hard drive are soon parted.
    7. Re:pointers & C by Anonymous Coward · · Score: 1

      C is much less foot-shooty if you use "modern styles", too.

      The only benefit C++ arguably has over C in terms of avoiding common pitfalls is the STL and automatic destructors. But BSD's queue.h and tree.h provide robust, type-safe implementations of lists and balanced trees. Anything more sophisticated and you usually want to implement it yourself so it integrates closely with your data model--if context-specific optimization didn't matter you'd just stick with a red-black tree and queues. And if you follow a strict RAII pattern in C code, the lack of automatic destructors is much less of a burden.

      What you get with C instead of C++ is priceless--simplicity. Once you go beyond toy programs, C++ projects become very difficult to reason about because of C++'s complex syntax, semantics, infrastructure, and dependencies.

      Actually, the #1 reason not to use C++ is because if using C seems too tedious, then you should really consider using a higher level language altogether. Even if C++ were better than C, there are so many widely available, popular, and easily integrated languages out there with immensely more powerful language constructs that you're missing the forest for the trees by justifying using C++ over C. Use Python or Lua or Scheme and implement any specialized, performance-critical data structures in C (or C++ if you must).

    8. Re:pointers & C by angel'o'sphere · · Score: 1

      Your classes don't need empty constructors, especially if they have nothing to destroy.
      However in most cases a 'base class' should have a virtual destructor!
      If that one is empty depends on the class.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    9. Re:pointers & C by mwvdlee · · Score: 1

      Seems you just want to get rid of the C++ library, which is pretty easy; simply don't use it.

      --
      Slashdot social media options: AIM, ICQ, Yahoo, Jabber and Mobile Text. Why no MySpace?
    10. Re:pointers & C by ADRA · · Score: 1

      Hardware has registers / stacks and jumps. Pointers are just too high level...

      --
      Bye!
    11. Re:pointers & C by lgw · · Score: 5, Interesting

      The reason for empty destructors is that destructors that actually clean up resources are usually a bad idea. (Debugging-related stuff in destructors is different.) The "allocate in the constructor, clean up in the destructor" pattern was a natural evolution from well-written C code. If you were used to "allocate at the top of the function, clean up at the bottom", it was the obvious better approach. But it's still just as error-prone (just fewer places for errors), and the fact that the destructor doesn't get called if the constructor throws isn't broadly internalized by coders (and is my least-favorite intermittent resource leak to run down).

      Having very small resource-specific classes, similar in functionality to auto_ptr or unique_ptr (just managing a file handle or whatever instead of memory allocation) is the better answer. Only clean up a resource in a class whose only purpose is to clean up a resource. Using those primitives as members in other classes, or as local variables, is as idiot-proof as C++ gets.

      The resource-leak headaches saved by difference in approach is amazing when junior coders are involved, it's really a difference in kind. And it's dead easy to police in code-reviews. The last time I did C++ we had a single, templated class in library code, and nowhere else in the code base was a non-trivial destructor allowed. (Odd cases like adding an object to a global list, and removing it on destruction could be managed within this system.)

      --
      Socialism: a lie told by totalitarians and believed by fools.
    12. Re:pointers & C by Darinbob · · Score: 1

      I just want the better-C-than-C. The problem is people are worried that once you make a switch to C++ that you're on the slippery slope to bloatware. Which is why C++ is much less common in the embedded systems world.

    13. Re:pointers & C by serviscope_minor · · Score: 3, Informative

      The only benefit C++ arguably has over C in terms of avoiding common pitfalls is the STL and automatic destructors.

      That's like saying the only thing we have better than the 1500s is electricity and internal combustion engines.

      And if you follow a strict RAII pattern in C code, the lack of automatic destructors is much less of a burden.

      But why bother? Do it in C++ and you get the same resource usage but with 1/10 of the typing and 1/10 of the bugs.

      Every line of code you write is a potential bug. In C++ you can program the compiler to write them automatically for you bug free every single time.

      Actually, the #1 reason not to use C++ is because if using C seems too tedious, then you should really consider using a higher level language altogether.

      The lack of resource management makes C very tedious. C++ does it better than many other languages.

      --
      SJW n. One who posts facts.
    14. Re:pointers & C by serviscope_minor · · Score: 1

      The last time I did C++ we had a single, templated class in library code, and nowhere else in the code base was a non-trivial destructor allowed.

      Are you sure? If you aggregate (say) an int with a string in a simple struct, the struct will have an automatically generated non trivial destructor, since it needs it to clean up the string. But you don't, of course, have to write a single line of code to make it work properly.

      --
      SJW n. One who posts facts.
    15. Re:pointers & C by DickBreath · · Score: 1

      Ah, but assembly uses labels as targets of jump and subroutine instructions. And data memory references.

      You should do it like the hardware does. Use numeric memory addresses as targets of instructions that address memory.

      --

      I'll see your senator, and I'll raise you two judges.
    16. Re:pointers & C by lgw · · Score: 1

      To many, the phrase "non-trivial destructor" informally means "no interesting code written in the destructor definition", not the formal meaning in the standard, which is I think what you're talking about? In any case, I was talking about the former.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    17. Re:pointers & C by Win0ver · · Score: 1

      There's really no reason ever to use C over C++ if you have a C++ compiler available.

      Hehehe. Tell that to Linus. ;)

    18. Re:pointers & C by angel'o'sphere · · Score: 1

      The reason for empty destructors is that destructors that actually clean up resources are usually a bad idea.
      There is absolutely no reason for an empty destructor at all, except as I mentioned before as an virtual destructor in the base class of an hierarchy.
      Reason: those destructors are generated by the compiler!

      The reason for empty destructors is that destructors that actually clean up resources are usually a bad idea.
      At some point someone has to write a destructor that actually does some cleaning up: e.g. as in all the library classes you are so fond of using. If the "file abstraction" class there had not a a hand written non trivial destructor, the file handle would not be released, the file not closed ...
      So yes: there are plenty of reasons to have a hand written destructor that actually does something.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    19. Re:pointers & C by HiThere · · Score: 2

      I'd settle for something good on how to use unicode with C OR C++. Saying "use ICU" doesn't help when there's no decent documentation on using ICU. After looking over the C++11 standard carefully, it looks as if it *is* possible to use unicode with C++, but it's still not clear how. Were I already an experienced C++ programmer, perhaps the discussion of facets would make sense. As it is...no. And there don't even seem to be any decent examples.

      Most of the libraries for using unicode aren't sufficient for my needs. I need to be able to determine the general character class of each codepoint. (Actually, I only need the first letter of the general character class.) Every library seems to do this differently, and none do it intelligibly. This was easy in python, and feasible in Java (there were other reasons why those weren't preferred) but doing it in C++ *seems* not to be supported. The documentation says that it actually *is* suported, but how to do it is not obvious.

      In Rust getting the character code is fairly easy, but walking a file directory seems to be unsupported. (Well, I think they supply all the pieces needed to build a directory path walker, but I'm not real sure. I keep ending up on paged marked "experimental" or "deprecated".)

      That said, and if I can work my way past a few problems, Rust looks better than C because it allows owned data to be moved between threads. (Well, I think it does, and does it relatively simply.) C and C++ don't even have the concept of data dynamically becoming immutable. Thread local isn't the concept I'm after, though I need for all mutable data to be thread local...which is easy in Rust and difficult in C and C++. (Yes, I know you can do it. But you need to keep careful track of what needs to be marked thread local.)

      OTOH, I haven't written anything original in Rust yet. I'm still studying to be sure that all the pieces I need are actually present. I haven't yet checked database access, or whether I can actually transfer immutable structs between threads easily, or whether I'll need to Box them, etc. And I'm certainly making no comment on either its compilation speed or its execution speed. (I've only run small test programs that I copied.)

      This got a bit too long, and I'm not THAT experienced with C++, much less Rust, but my current evaluation is that for certain classes of programs Rust is a superior choice, and for other classes C++ is superior.

      P.S.: Rust has just been released at 1.0, and I think prematurely. The absence of a directory walker program (that isn't marked either experimental or deprecated) is on reason why. But it still looks like a very good language for certain classes of program, even though it needs considerable development.

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
    20. Re:pointers & C by caseih · · Score: 1

      Certainly in the hobby embedded space, dominated by Arduino, C++ is exclusively used. Sometimes it's just C compiled with a C++ compiler, but often basic classes are used. Never the C++ standard library though.

      There are certainly reasons why people eschew C++, some are better than others. The bloat argument is probably one of the poorer arguments.

      Personally I avoid C++ primarily because it's so hard to access C++ classes from other languages without fairly complicated thunk layers.

    21. Re:pointers & C by david_thornley · · Score: 1

      In modern C++, ownership is typically expressed by unique_ptr and shared_ptr. shared_ptr can be a performance issue, but unique_ptr is a raw pointer with functions attached.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    22. Re:pointers & C by lgw · · Score: 1

      so yes: there are plenty of reasons to have a hand written destructor that actually does something

      Yes, but my point is, only do it in a narrow set of carefully-reviewed library primitives. You don't really need very many - various OS "handles" and anything specific to the code base that needs unique handling (can't be built from other primitives, e.g., you're doing slab allocation and have a special "free" action).

      For example, if you have a rich "file" class with many methods, it should have an empty destructor. But it should have as a member a primitive that wraps a FILE or Windows HANDLE object that only knows how to call fclose or CloseHandle.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    23. Re:pointers & C by lgw · · Score: 1

      Oh, I agree completely: Unidoce isn't made easy by C++, and it damn well should be. Especially, I want extremely optimized library code for getting Unicode meta-data about codepoints, and for validation. I'm sure ICU is good and all, but this deserves to be part of the language (with fully-baked support for std::algorithms working codepoint-wise, since std::algorithms has some great stuff hidden inside).

      --
      Socialism: a lie told by totalitarians and believed by fools.
    24. Re:pointers & C by garethjrowlands · · Score: 1

      Congratulations on learning pointers! Welcome to the inner circle of people-who-know-pointers.

      You suggested the following as if it's an either-or:

      > learn pointers rather than develop ways to avoid them.

      But it's not: one can learn pointers *and* develop ways to avoid them - pointers are a bit like GOTO in this respect. On the subject of learning things, have you learned Rust yet? Do you know why you should?

    25. Re:pointers & C by interval1066 · · Score: 1

      C++ adds gives the writer the ability to use virtual methods very easily, you're kind of tying one hand behind your back if you don't use polymorphism, so then you start getting bloat with your virtual tables, which can become quite massive. I don't think C++ is appropriate in many embedded applications.

      --
      Python: 'And then suddenly you have a language which says "we're all stuck with whatever the whiniest coder wants".'
    26. Re:pointers & C by Ateocinico · · Score: 3, Informative

      Since C++11 the destructor invocation in case of an exception is guaranteed. http://www.stroustrup.com/bs_f...

    27. Re:pointers & C by As_I_Please · · Score: 1

      The "allocate in the constructor, clean up in the destructor" pattern ... is still just as error-prone (just fewer places for errors), and the fact that the destructor doesn't get called if the constructor throws isn't broadly internalized by coders (and is my least-favorite intermittent resource leak to run down).

      I've come up with my own pattern (probably not original) for dealing with throwing constructors and I've been wondering if it's effective. Basically, write a separate cleanup() method that gets called by the destructor and the catch() block of a constructor:

      Foo::Foo()
      {
          try
          { // ... do stuff and acquire resources
          }
          catch(...)
          {
              cleanup();
              throw; // to prevent Foo instance from being used
          }
      }

      Foo::~Foo()
      {
          cleanup()
      }

      Foo::cleanup()
      { // release any acquired resources
      }

    28. Re:pointers & C by ZeroConcept · · Score: 1

      That is entirely correct, in Windows OS resources need to be wrapped in classes that are guaranteed to properly release an acquired resource at time of destruction regardless of context (stack or heap).
      Otherwise you leak OS resources and WILL freeze the box after you exceed the maximum handle limit.

    29. Re:pointers & C by Spazmania · · Score: 1

      ought to have C++ on the table. It's got the same resource footprint as the other two.

      If you think C++, when used for more than "C with classes," has the same resource footprint as C, you don't understand either language very well.

      --
      Moderating "-1, Disagree" is simple censorship. Have the guts to post your opinion.
    30. Re:pointers & C by gweihir · · Score: 1

      There's really no reason ever to use C over C++ if you have a C++ compiler available.

      You must be one of these "modern" coders that never have heard of simplicity or all the problems still C++ has. I do not think taking advice from you is wise.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    31. Re:pointers & C by serviscope_minor · · Score: 1

      Er, yes, I was referring to the formal meaning. That's excellent, of course. I'm a fan of getting the compiler to write all the boilerplate for me. I tend to write code like that: it has the feel of simple code with lots of structs, but the compiler takes care of all the annoying bits.

      --
      SJW n. One who posts facts.
    32. Re:pointers & C by serviscope_minor · · Score: 2

      C++ adds gives the writer the ability to use virtual methods very easily, you're kind of tying one hand behind your back if you don't use polymorphism

      That's one of the easier things in C: just put a function pointer in the class, one function pointer for each method. Of course then you need a whole vTable per class, where as C++ has a single pointer to the vTable and then one copy of the vtable. The idiomatic C way is much more bloated.

      so then you start getting bloat with your virtual tables, which can become quite massive.

      Not a problem I've ever had, but I'm not a fan of deriving everything from everything else as was popular at one time. My code has very few virtual methods.

      I don't think C++ is appropriate in many embedded applications.

      Name one. It runs just fine on an ATTiny. Doesn't get much smaller than that.

      --
      SJW n. One who posts facts.
    33. Re:pointers & C by serviscope_minor · · Score: 1

      You must be one of these "modern" coders that never have heard of simplicity or all the problems still C++ has. I do not think taking advice from you is wise.

      I'd prefer that the C++ compiler developers cram all the complexity into one place (the compiler) rather than me having to spread it out over every single program I write. With my way, the very smart compiler writers do the complex stuff, and I get to write nice, simple clear code.

      But good ad-hom.

      The stuff I write on now has less RAM than the BBC micro I grew up with.

      --
      SJW n. One who posts facts.
    34. Re:pointers & C by serviscope_minor · · Score: 1

      If you think C++, when used for more than "C with classes," has the same resource footprint as C, you don't understand either language very well.

      Clearly I understand them better than you because I know you're talking out of your arse.

      If you think templates hog more resources than macros, you don't understand templates.

      If you thing operator overloading hogs resources, you don't understand operator overloading.

      If you think virtual functions hog more resoures than function pointers, you don't understand virtual functions.

      If you think lambdas hog more resources than a simple struct, then you don't understand lambdas.

      If you think std::sort is worse than qsort() then you are blatantly ignoring almost every behcnmark on the subject matter.

      If you thing you can beat std::priority queue backed by a static array, then either you're a guru level expert or you don't understand the STL at all.

      And so on and so forth.

      --
      SJW n. One who posts facts.
    35. Re:pointers & C by serviscope_minor · · Score: 1

      Code inspection is a very good reason. What exactly does this do in C++?

      Oh, not this idiotic comment again.

      Tell me, what does the following do in C:

      do_copy(foo_a, foo_b);

      In order to know what it does you have to comb through the header files and hope that the original programmer commented all the side-effects of the function. You might even have to read the implementation, browsing up the file hierarchy until you find the function.

      = in C++ means operator=(A, B).

      That's all. It's just a function with a funny name. If you don't know that then you don't know C++. No language prevents you from creating deceptively named functions where do_copy() does something stupid, e.g. modifies some global state and switches the computer off.

      --
      SJW n. One who posts facts.
    36. Re:pointers & C by TemporalBeing · · Score: 1

      There's really no reason ever to use C over C++ if you have a C++ compiler available

      Well, unless your bootstrapping an OS. C is the easiest language to move to from Assembly as there are zero things to setup to move into C. You can move into C++, but then you have to be extremely careful of new/delete support - which has to get setup almost immediately if you did not before you moved into C++ land. This is why most embedded and kernel stuff only uses C as even C++ adds enough bloat due to those supports that when every byte counts it's just not useful. I expect Rust would be more like C++ in that respect.

      So as always, it's depends on what you do. In most cases, it probably won't make a difference. But there are some vital cases out there - especially in the embedded world - that the small differences have huge impacts.

      --
      Truth is like the sun. You can shut it out for a time, but it ain't goin' away. - Elvis Presley (source: imdb.com)
    37. Re:pointers & C by TemporalBeing · · Score: 1

      But it's still just as error-prone (just fewer places for errors), and the fact that the destructor doesn't get called if the constructor throws isn't broadly internalized by coders (and is my least-favorite intermittent resource leak to run down).

      Well, there is another (better) solution - stop using Exceptions! They cause more headaches than anything else, including leaving programs in unrecoverable states.

      I know, I know - everyone loves Exceptions. But in all honestly, they should never be used. Functions/ClassMethods/etc should all be explicit in their error handling, and errors should always be handled as close to what generated the error as possible. This one little thing saves all of the headaches of trying to track down bad pointers, incorrect states, etc - e.g 99% of what people complain about in C and C++ code.

      --
      Truth is like the sun. You can shut it out for a time, but it ain't goin' away. - Elvis Presley (source: imdb.com)
    38. Re:pointers & C by TemporalBeing · · Score: 2

      The only benefit C++ arguably has over C in terms of avoiding common pitfalls is the STL and automatic destructors.

      I probably do more C and than C++ when writing C++ code. I typically use C++ classes (abstract, etc), namespaces, and (now) STL. This just helps with segregating the code into their logical parts so structure X doesn't get used on functions only meant to manage structure Y or data type Z.

      new/delete? Well, I'll use them for classes only. Structures get allocated with malloc/free. Yes, a class is only use for data+functions and structures are only used for pure data; allocation patterns follow this same methodology which enables easy transition between pure C and C/C++ code when necessary. If a class allocates data, then I also provide an API in the class (typically instance agnostic) to clean it up to ensure that there is one-place that cleans it up, ensuring that the same allocator/destructor methods are used.

      I also stay away from streams when I have a choice, and prefer C-style printf/scanf processing.

      So there are useful bits in C++; you just have to find the right balance. Doing so makes for very easy to maintain code.

      --
      Truth is like the sun. You can shut it out for a time, but it ain't goin' away. - Elvis Presley (source: imdb.com)
    39. Re:pointers & C by JesseMcDonald · · Score: 1

      The difference is overloading—not operator overloading, just overloading in general. In C there can only be one function named do_copy() in the entire program. In C++, whether we're talking about do_copy() or operator=(), there can be many, and you can't know which one will be called without knowing the types involved, and in many cases the conversion rules which the compiler will apply; some of these rules can even be user-defined.

      In some ways the do_copy() case is worse, since there are at least some semi-formal conventions regarding the implementation of operator=(). Your program could link against two libraries which both provide an implementation of do_copy(), with little in common besides the name.

      Other languages (e.g. Haskell) tend to solve this by requiring names to be unique within a given scope. Overloading is handled by making the name part of a polymorphic interface, with one of many available implementations is selected according to the type parameter(s). The interface represents a contract which the implementers are expected to follow, so that users of the interface can reason about the parameters, results, and side-effects in a generic way without worrying about the implementation details for whichever specific type is in use.

      --
      "The state is that great fiction by which everyone tries to live at the expense of everyone else." - Bastiat
    40. Re:pointers & C by Grishnakh · · Score: 1

      Use the Qt toolkit (with C++); it handles Unicode just fine.

    41. Re:pointers & C by serviscope_minor · · Score: 1

      You can move into C++, but then you have to be extremely careful of new/delete support

      How much more careful do you have to be of new/delete support than malloc/free support?

      Not much I'll wager.

      And it's not like you have to support it. None of my Atmel code uses new or delete. Static allocation all the way.

      This is why most embedded and kernel stuff only uses C as even C++ adds enough bloat due to those supports that when every byte counts it's just not useful.

      C++ does not add bloat. That's an old, false meme which needs to die.

      --
      SJW n. One who posts facts.
    42. Re:pointers & C by Grishnakh · · Score: 1

      It's always wrong to use gotos. So if the hardware is using gotos, you just shouldn't use the hardware....

    43. Re:pointers & C by HiThere · · Score: 1

      We've got a different definition of "just fine", but I admit that Qt handling of unicode is much better documented, and can be made to do the job.

      Of course unicode inherently has a problem because this idea of a single character doesn't map to codepoint...but Java, Python, Ruby (with a library), and D, at least, can handle the job. The language that I actually prefer is D, but it's lacking support for most libraries. E.g., to use SQLite one needs to use a very thin wrapper around the C header files. Java, Python, and Ruby lack even the concept of structs, however, and I want to directly read/write a struct to a binary file. In all of them there are ways to do this, but those ways are nearly as clumsy as the way unicode is handled in C. Rust appears to have the potential to handle all of this gracefully, and a large enough support team to quickly bring libraries on board. I just don't feel it's there yet, despite the current release being labeled 1.0. (They did say, however, as a part of the release announcement that what this meant was that now the language interface was stabilized I can sort of see why a language designer might designate that as 1.0, but as someone who is a user rather than a designer of languages that seems premature before the standard libraries are stabilized.)

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
    44. Re:pointers & C by angel'o'sphere · · Score: 1

      Sigh, now for the third time: no, you do not need an empty destructor!
      Either you write a non empty destructor you write none at all, the compiler generates one automatically for you!

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    45. Re:pointers & C by lgw · · Score: 1

      You've seem to have missed my point.

      My point is that non-empty destructors are an error-prone, repetitive, boilerplate process that you can just stop doing (aside from a small bit of library code). Your code will, as a result, be shorter and more clear, and stop leaking resources, even when junior coders are involved.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    46. Re:pointers & C by TemporalBeing · · Score: 1

      You can move into C++, but then you have to be extremely careful of new/delete support

      How much more careful do you have to be of new/delete support than malloc/free support?

      Not much I'll wager.

      You actually have to completely avoid it until you setup the functions necessary to support it. It's been a while since I've looked at doing it, but it's non-trivial, as is much functionality at that early boot stage.

      And it's not like you have to support it. None of my Atmel code uses new or delete. Static allocation all the way.

      This is why most embedded and kernel stuff only uses C as even C++ adds enough bloat due to those supports that when every byte counts it's just not useful.

      C++ does not add bloat. That's an old, false meme which needs to die.

      True, you can avoid stuff by following best practices for embedded and using pure stack allocation. But that only goes so far. You can also run into issues with Exceptions. For instance http://wiki.osdev.org/Bare_Bon... documents several issues.

      --
      Truth is like the sun. You can shut it out for a time, but it ain't goin' away. - Elvis Presley (source: imdb.com)
    47. Re:pointers & C by flargleblarg · · Score: 1

      In C there can only be one function named do_copy() in the entire program.

      Obviously you don't know C.

      If you declare do_copy() as static, you can have as many as you like -- one per compilation unit.

    48. Re:pointers & C by khellendros1984 · · Score: 1

      Loop constructs and jump tables are just syntactic sugar on top of gotos. Function calls are just gotos with side effects (and we all know, if there's one thing worse than goto, it's unrelated side effects!). Clearly we just need to ditch the whole operational model and start over from scratch with CPUs that natively support modern programming practices.

      --
      It is pitch black. You are likely to be eaten by a grue.
    49. Re:pointers & C by Chibi+Merrow · · Score: 1

      In C there can only be one function named do_copy() in the entire program.

      And that is objectively awful.

      --
      Maxim: People cannot follow directions.
      Increases in truth directly with the length of time spent explaining them
    50. Re:pointers & C by angel'o'sphere · · Score: 1

      No, I did not miss your point.

      Our small discussion started 3 or 4 posts back, with your words "I wished one would explain clearly, for what empty destructors are needed".

      I explained now three times: not at all.

      That you as an "application developer" like to use libraries that free you from the burdon to have "non empty" destructors is another topic and clearly understandable :D

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    51. Re:pointers & C by JesseMcDonald · · Score: 1

      Actually, I write C code every day for my job (embedded software for avionics) and have for the last ten years. My overall experience with C is roughly twice that. But obviously I "don't know C". Or perhaps I just abused the term "program" as shorthand for "compilation unit". In any case there is never more than one function of a given name in scope, which is the important part.

      --
      "The state is that great fiction by which everyone tries to live at the expense of everyone else." - Bastiat
    52. Re:pointers & C by JesseMcDonald · · Score: 1

      In C there can only be one function named do_copy() in the entire program.

      And that is objectively awful.

      It causes problems, sure. Either your names become unreasonably long or you risk link errors (or worse) due to name conflicts. I'm not holding C up as some kind of perfect language here, just pointing out that C++'s approach to overloading creates ambiguity. I mentioned Haskell, which has a reasonable module system. Even C++ supports namespaces, and "C with namespaces" would be fine (provided one omitted C++'s "argument-dependent lookup" rules). The problem is the ability to define multiple unrelated functions with the same name in the same scope, distinguished only by the argument type(s).

      --
      "The state is that great fiction by which everyone tries to live at the expense of everyone else." - Bastiat
    53. Re:pointers & C by Nubbywubwub · · Score: 1

      walking a file directory seems to be unsupported

      Here's a lovely lib for that that has a good chance of appearing in the standard lib someday: https://crates.io/crates/walkd...

    54. Re:pointers & C by Spazmania · · Score: 1

      About half of that is correct. That you don't know which half makes my point for me.

      --
      Moderating "-1, Disagree" is simple censorship. Have the guts to post your opinion.
  5. It's not already rusted? by bluefoxlucid · · Score: 3, Funny

    C is pretty rusty.

    1. Re:It's not already rusted? by gstoddart · · Score: 5, Funny

      One might say 'crusty'.

      --
      Lost at C:>. Found at C.
    2. Re:It's not already rusted? by YellowElf · · Score: 1

      I wish I could upvote you.

      --
      Insert witty saying or aphorism here.
    3. Re:It's not already rusted? by Dog-Cow · · Score: 1

      Or busty. Wait, that would be D(D?).

  6. No. by Anonymous Coward · · Score: 2, Informative

    No.

    1. Re:No. by phantomfive · · Score: 2, Insightful

      Rust has been developed by Mozilla for a specific problem they have, and their specific coding style. As far as I can tell it, works well for them and is a fine language.

      Unfortunately, it's still in the "growing" stage of languages, and may never make it out of Mozilla world, and Mozilla themselves might even drop support, which means you're in trouble.

      When you're choosing a language, you have to look at the entire ecosystem surrounding the language. It's not enough to look only at the language itself.

      --
      "First they came for the slanderers and i said nothing."
    2. Re:No. by DuckDodgers · · Score: 1

      With that attitude, we'd all be using Fortran, Cobol, Lisp (okay, I like that idea) and Pascal instead of the newfangled stuff.

      If you have to sell some relatively obscure language to a big team, or to a corporation or whatever, then yes I agree with you - go with the tried and true (even if it's also painful and tedious) unless you have a hell of a specific killer feature as a reason for using the new tool instead of the old one.

      But for smaller side projects, personal projects, experimenting - why not?

    3. Re:No. by ClickOnThis · · Score: 2, Interesting

      No one expects an obscure new language to gain mind-share without a good reason.

      There is one crucial element to a new language gaining support: expressive power. Does it let you to express the solution to a problem in a better way than others?

      Actually, there are two elements: expressive power and viable cross-platform support. Compilers and/or interpreters must perform well and be available for all platforms that matter.

      Well, really there are three elements ... uh ...

      I'll come in again.

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

      With that attitude, we'd all be using Fortran, Cobol, Lisp (okay, I like that idea) and Pascal instead of the newfangled stuff.

      There are some big projects already using Rust. If it works out for them, then great. Otherwise, I don't want to rewrite all my stuff when language support is dropped.

      --
      "First they came for the slanderers and i said nothing."
    5. Re:No. by NotInHere · · Score: 1

      Rust does have search results, but rust had a really unstable past, if a search result is before stabilisation with 1.0, its usually deprecated. And most results are from that time. But since stabilisation things got better, at least I hope, and everybody says. Just ask your question anew, people are usually very helpful.

    6. Re:No. by DuckDodgers · · Score: 1

      Thanks for the laugh. I do think Rust has those features.

    7. Re:No. by DuckDodgers · · Score: 1

      It's open source under the MPL license, so unless there's some serious bitrot you should be safe to keep using the last stable release for a very long time.

    8. Re:No. by phantomfive · · Score: 1

      bitrot happens.

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

      Rust is dual-licensed under Apache 2/MIT, not MPL.

  7. kids these days... by Anonymous Coward · · Score: 4, Insightful

    They don't like C because they haven't been taught it properly and instead go for things that are just trying to re-invent the wheel. Tell this guy to STFU, read a copy of the K&R book, and then get back to work using the native language of *nix.

    1. Re:kids these days... by fahrbot-bot · · Score: 4, Insightful

      They don't like C because they haven't been taught it properly and instead go for things that are just trying to re-invent the wheel.

      ... and C is hard and makes you have to think and stuff.

      --
      It must have been something you assimilated. . . .
    2. Re:kids these days... by superwiz · · Score: 1

      K&R leaves a lot to imagination when it comes to describing C. Even if you are living back in the 90's, you won't be proficient in C until you've read "C: A Reference Manual" by Harrison & Steele.

      --
      Any guest worker system is indistinguishable from indentured servitude.
    3. Re:kids these days... by phantomfive · · Score: 1

      Specifically, K&R doesn't really teach you how to deal with memory leaks. It's good for learning the language, and one of my favorite programming books, but it's also an introduction, not a complete tutorial.

      --
      "First they came for the slanderers and i said nothing."
    4. Re:kids these days... by Austerity+Empowers · · Score: 1

      You're probably someone who considers themselves and 'old school hacker' and have been out of a programming job for twenty years

      Or he's doing a different job than you. I've got a pile of C code I'm staring at now, which is going in to active products that ship in the tens of millions. I have both never been unemployed longer than I wanted to be, nor had any issues selling my "dinosaur" C skills. I've never worked anywhere that C skills aren't a job requirement, nor that replacing C would get you anything but a funny look, it's solving a problem we don't have.

      C isn't going anywhere, it's a perfectly safe choice. It may not be the optimal choice for all situations. Smart people don't put one tool in their toolbox and call themselves an expert, they learn how to use a small but complementary set of tools really well, and then experiment with some new ones here and there but leave them on the wall for that niche situation that needs them. C is a hammer, you should always have a hammer in your toolbox. Most problems can be made to look like nails, with the proper combination of desperation and alcohol.

    5. Re:kids these days... by Beck_Neard · · Score: 1

      More power to you, but AC's tone was quite different.

      --
      A fool and his hard drive are soon parted.
    6. Re:kids these days... by fahrbot-bot · · Score: 1

      It's hard and makes you think and literally no one gets it right and the internet is a roiling vortex of shit because of that fact. But go on believing that you're the special one who doesn't fuck it up, just "the kids" who don't want to work hard.

      Right, because no piece of software can ever be changed once delivered and/or in service.

      --
      It must have been something you assimilated. . . .
    7. Re:kids these days... by pr0nbot · · Score: 1

      Why do you draw the line at C rather than at assembler, or at Rust?

      I'm quite happy programming in C, but to declare that some moment in the 1970s was the pinnacle of programming language design seems somewhat... Amish.

    8. Re:kids these days... by Eythian · · Score: 1

      "We can fix it later" is no excuse for delivering shit to start with.

    9. Re:kids these days... by Eythian · · Score: 2

      Rust is probably harder to get to grips with then C. The difference is that when you screw up in rust, it usually yells at you. When you screw up in C, it blithely goes on doing what it thinks you want.

    10. Re:kids these days... by Eythian · · Score: 1

      Attitudes like this is a large part of what causes us to need a security industry.

      You are part of the problem.

    11. Re:kids these days... by TapeCutter · · Score: 1

      You're probably someone who considers themselves and 'old school hacker' and have been out of a programming job for twenty years. Things have changed, dude.

      I'm not the GP but I have been coding in C/C++ for a living for the past 25yrs, I even spent a couple of years teaching it to CS undergrads. IMO K&R is every bit as elegant an informative as Knuth, with the added advantage that the examples are in a real code rather than pseudo-code, the shell sort example is still one of the best examples of beautifully simple code I have ever seen. Swallow your pride, retrieve the book from the trash and take another look, virtually every example has all the good bits of modern OO design, before the term "OO design" was even invented.

      In short you sound like a freshly minted "hacker" that has never seen the inside of a commercial software house.

      --
      And did you exchange a walk on part in the war for a lead role in a cage? - Pink Floyd.
    12. Re:kids these days... by T.E.D. · · Score: 1

      Tell this guy to STFU, read a copy of the K&R book

      In what universe is that a good idea? It has been about 20 years since I last encountered a C compiler that used the K&R variety of the language. Even C fans realized early on that version of the language was utterly shitty.

      This must be from someone who feels like you haven't lived until you've tracked down a runtime bug due to a routine spec not being available when used, thus silently assumed to be returning int with all parameters int, and then silently casting the float parameters in and out of int accordingly (but treated as float inside the implementation of the routine).

      The various versions of ANSI C were created for a reason. They were attempts to bash into some reasonable kind of shape a language that, even its own designers admitted (when asked by the DoD as part of the Tinman effort), was unsuitable for serious software development.

    13. Re:kids these days... by TemporalBeing · · Score: 1

      K&R tells you to match a free() with every malloc(). Do so - no memory leaks. Yes, K&R doesn't teach you how to debug your code - it teaches you how to avoid the bug in the first place.

      Mod parent up.

      One of my first programmer reads was Elements of C by Morton H. Lewin (1986) which covered K&R C. I read it in 2004. It made me realize just how much C I actually do (I learned C/C++). even when doing C++. And yes, simple things like matching every malloc() call with an equivalent free() call is some of the essentials of programming without memory leaks.

      Though in the C++ world if you're using a parenting model like Qt does, then the delete matching the new is usually (except in special well documented and obvious cases) handled by the parenting model - e.g. all objects have a parent; on destruction of an object, it automatically cleans up all its children; you have to clean up the ones that don't have parents, most of which can be managed by allocating them on the stack. While I'm sure you can figure out a similar approach in C, I'm not sure their is really any framework that does that in C.

      --
      Truth is like the sun. You can shut it out for a time, but it ain't goin' away. - Elvis Presley (source: imdb.com)
  8. Community Support by freak0fnature · · Score: 5, Insightful

    Where I am they chose SpineJS a few years ago, looked like a great language, easy, etc. After a few years, one thing we noticed was the lack of online help when you run into issues. It's just not that widely used. Rust is ranked 49th on Tiobe. Maybe it will be the next best thing, but if it isn't, you'll be stuck with something that has little community support.

    1. Re:Community Support by shaitand · · Score: 1

      The problem he is pointing out isn't js specific.

      If languages have poor adoption and support you have to reinvent every wheel.

    2. Re:Community Support by RelaxedTension · · Score: 1

      Actually you're the idiot for completely missing the context of what he was referring to. He is drawing an analogy to the situation, not making a suggestion for that language.

    3. Re:Community Support by dmoen · · Score: 4, Informative

      The SpineJS repository has 4 contributors. The Rust/Lang repository has 1,188 contributors. (on github)

      --
      I have written a truly remarkable program which this sig is too small to contain.
  9. It's not the language itself... by DrTJ · · Score: 5, Insightful

    ... that determines its success or not in a non-nieche segment.

    It's the mass of developers that already know it, it's the accumulated code base (both locally and globally) and most importantly: the eco system of tools surrounding it: the compilers, the IDEs, the debuggers, the static/dynamic code analysis, build systems, code generators, mock tools, coverage tools etc.

    The new kids on the block have a lot of catching up to do in areas which are not directly language related.

  10. New by ardmhacha · · Score: 1

    According to wikipedia
    https://en.wikipedia.org/wiki/...
    "Rust 1.0, the first stable release, was released on May 15, 2015."

    So it's five months old.

    1. Re:New by Anonymous Coward · · Score: 1

      That's not promising - all my cars have gone far longer than that before the first signs of rust appeared.

      Before you recommend Lisp, how far have your cdrs gone?

    2. Re:New by HiThere · · Score: 1

      As languages go, that's right out of the door. And I think they rushed the 1.0 release, because the standard libraries have some unpleasant holes...and not entirely in the documentation.

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
  11. Portability by Locke2005 · · Score: 3, Interesting

    If you're ever going to be porting it to another platform, then do it in C; there are C compilers available for almost every piece of hardware out there. If you're certain it only needs to run on a single, unchanging platform for the lifetime of the code, then using Rust might be a good idea.

    --
    I've abandoned my search for truth; now I'm just looking for some useful delusions.
    1. Re:Portability by Trepidity · · Score: 2

      Yeah, for now this is one of the bigger drawbacks. The officially supported platforms are:

      Windows (7, 8, Server 2008 R2)

      Linux (2.6.18 or later, various distributions), x86 and x86-64

      OSX 10.7 (Lion) or greater, x86 and x86-64

      There is supposed to be ARM support in the works.

    2. Re:Portability by ras · · Score: 1

      there are C compilers available for almost every piece of hardware out there.

      There are. But most of those CPU arches targeted by LLVM, which is what the current Rust compiler uses as it's back end. And then there are some targeted by LLVM, but not but C - like asm.js.

      You were right, once. If you were targeting some random arch the only thing you could rely on was a C compiler being available for some definition of "C". If you were lucking they might even provide something that looked vaguely like the POSIX library. But LLVM has broken that rule of thumb. The odds are very good that LLVM will also target your machine, and if it does all compilers and languages that use LLVM can produce code for it. And this isn't for some random implementation of the language like you got with C, it is typically the reference implementation of the language, and you get all this bits of it standard library that are written in itself as well.

      After 40 so years, they world has finally moved on.

    3. Re:Portability by garethjrowlands · · Score: 5, Informative

      What you say was true of early releases of Rust. But they removed all traces of any kind of runtime for exactly this reason. It was a breaking change but it happened quite a long time before the 1.0 release. Here's the documentation for the change: https://github.com/rust-lang/r...

      Here's a blog entry on using Rust for embedded. It dates from February and uses 1.0-alpha but of course 1.0 is out now:

      http://spin.atomicobject.com/2...

      In these days of LLVM, the portability story is good, even relative to C. No C portability gotchas.

    4. Re:Portability by nateman1352 · · Score: 1

      What you say was true of early releases of Rust. But they removed all traces of any kind of runtime for exactly this reason.

      Oh cool. I'll have to give Rust a second look then!

    5. Re:Portability by Nubbywubwub · · Score: 1

      Rust already has a whole lot of ARM support, not all of it official. Lots of tentative embedded work being done with Rust at the moment. Here's a more updated version of the page you linked with much more detailed support information: https://github.com/alexcrichto...

  12. Consider more than just the implementation by quietwalker · · Score: 4, Insightful

    How many other engineers are going to be expected to know and maintain this? Ones you have on staff? Are you making sure to hire for folks who know Rust? If you have one, is your ops team up to supporting applications written in Rust, familiar with the errors and can handle it? What's the life expectancy of the app? Ever going to need to port it in the future?

    Don't forget to factor in the bus factor, when you lose a whole engineer.

    Lots of folks end up missing these and you end up with mysterious legacy code the business completely depends on for day to day ops that no one knows or understands. Heck, the other day, I was asked to unlock a windows NT laptop because it was the only known repository of source code for an app that was written over a decade ago - hopefully.

    1. Re:Consider more than just the implementation by Anonymous Coward · · Score: 1

      It is shit like this that makes my field worse every year and has ruined /.

      Any decently educated programmer can pick up any language quickly and easily.

      Hire polyglots not language end-users.

      Shit, I wouldn't hire a Java programmer if he was not competent in multiple languages, for a Java-only project.

      Fuck API monkeys and the retards that hire them.

    2. Re:Consider more than just the implementation by Anonymous Coward · · Score: 1

      It's not picking up a language that's important. It's being expert in it that really matters. And becoming an expert in a language, and being able to hack something in it is not the same thing.
      Sure, I can pick up any language fast. I've programmed in Haskell and brainfuck for fun. I've picked up C, and LISPs, I know AWK and Python, I've hacked Perl, and played with clojurescript and even some vimscript. I think that if You woke me up at night I'd be capable to write in any of these languages at a minutes notice. But my code will be shit. And I dare say, even if I pickup the language of COBOL, java or C# fast, I won't get the nuances. The code that I will write will be broken by edgecases that are known only through thorough experience. It won't be optimal to deal with the inputs that I have to support.
      If You don't mind paying me for not earning You money for at least 6 months while I work to become an expert on a language I don't know, sure. Go ahead, hire me. If not, then go ahead and fuck off.

      Oh, and by the way, hire 50 polyglots to write tests.
      For the same money.

    3. Re:Consider more than just the implementation by Austerity+Empowers · · Score: 3, Insightful

      Any decently educated programmer can pick up any language quickly and easily.

      Hire polyglots not language end-users.

      I'm torn on this one. On one hand, yes, anyone with a CS background who didn't cheat through school can learn a new language quickly.

      The issue is whether they can learn to write idiomatically correct code in that language, and whether they "think" in terms of how that language was designed. That usually requires a bit of time, not to mention some patience. Python is my usual example for this, it breaks a lot of (in my opinion) sensible conventions that people over 10 are used to: no need for semicolons (sneered at if you use them), mandatory white space, duck-typing, etc. Yes, you can learn python in a few hours, but to write "good" python that other python people can/want to support, and generally don't waste time fighting the language, you need to spend some time.

      Generally when I see a language like this I want to barf, but it's hard not to run in to something like this a few times in life, and if you're on the hiring side and you have a pile of (say) Python, you probably want to hire someone that can do it properly, versus someone from say, C, who is going to be very upset with almost everything.

    4. Re:Consider more than just the implementation by garethjrowlands · · Score: 1

      Looks like GP touched a nerve.

    5. Re:Consider more than just the implementation by gweihir · · Score: 1

      Becoming a language expert is a huge wast of time. If a language is so difficult that you have to become an expert in it to use it efficiently, stay away from it. If it does not, then picking it up is quite enough. Sure, you have to understand things like algorithms and datastructures (a thing most coders already fail at), the machine, etc. But these do not really change from language to language. You also have to understand the main language paradigms. But a need to "get nuances" just means you are using a bad tool.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  13. wouldn't hold my breath by NostalgiaForInfinity · · Score: 1

    The problem with languages like Rust is that, in addition to addressing important issues in the languages they intend to replace, their designers also go off on an ego-trip, introducing numerous gratuitous syntactic changes, overlooking important features in their predecessor language they didn't understand, and adding features few people actually need. It's possible that a language like Rust will eventually replace C, but I wouldn't put my money on any particular one.

    More likely, ideas from Rust will simply make it into a future C release. For example, C may end up having both "safe" and "unsafe" modules, with "safe" modules having more Rust-like semantics and restrictions, and "unsafe" modules supporting full traditional C. Fortran managed such a transition from Fortran-77 to Fortran-90 pretty successfully.

    Of course, the other threat to Rust-like languages (as well as future extensions to C) is that whatever they come up with can probably be emulated fairly well in C++ anyway. In fact, looking down the list of Rust features, they are pretty much identical to what C++ offers people already today, and C++ has tons more libraries and compilers, interoperates better with C, and has a huge community of programmers.

    1. Re:wouldn't hold my breath by dmoen · · Score: 4, Informative

      1st paragraph is false, due to the rather extraordinary design process that Rust went through.

      designers also go off on an ego-trip, introducing numerous gratuitous syntactic changes, overlooking important features in their predecessor language they didn't understand

      The Rust community is quite large, including many skilled language designers. The Rust github repository has ~1200 contributers. With that pool of talent,
      there are no features of C/C++ that the designers don't understand. With this kind of community, and a formal change review/feature addition process, there's not much danger of a single ego-tripping designer messing up the language.

      adding features few people actually need

      The project transitioned from a hobby project to an official Mozilla project in 2009. During the 6 years from 2009 to 2015 (when the Rust 1.0 design was stabilized and released), a lot of Rust code was written. Features that seemed like a good idea at the time, but which had little practical use, were removed before 1.0.

      3rd paragraph is also incorrect. The main feature of Rust is guaranteed memory safety, without a garbage collector, enforced by compile time type checking rather than by introducing run-time overhead. This memory safety includes a guarantee that shared global data can't be corrupted by simultaneous writes from different threads, something that no other language offers. C++ doesn't offer this today, no other language does.

      I agree that Rust will influence future languages, but I don't think it will have much effect on C. The C++ community is already looking at Rust and trying to figure out how to compete with what it offers.

      --
      I have written a truly remarkable program which this sig is too small to contain.
    2. Re:wouldn't hold my breath by istartedi · · Score: 2

      This. C can be fixed. It takes time, and compilers are usually ahead of the standard. How long did it take for C to get the restrict keyword? That allows us to control pointer aliasing in a portable way. The impetus for that was that FORTRAN could outperform C because, AFAIK, it assumes no aliasing.

      There are already a lot of static checkers for C. I'm willing to wager they can catch just as many bugs at compile-time as Rust. Having such tools is almost as good as having checks integrated into a standard implementation. If you go ahead in C, the standard may catch up to you without you having to worry about the risk of a new language.

      --
      For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
    3. Re:wouldn't hold my breath by TheDarkMaster · · Score: 1

      This. I would not have said it better

      --
      Religion: The greatest weapon of mass destruction of all time
    4. Re:wouldn't hold my breath by NotInHere · · Score: 2

      Even if templates are already present in C++, they are a PITA to use. Rust is really really easy to use for those.

    5. Re:wouldn't hold my breath by DuckDodgers · · Score: 2

      The interesting feature of new programming languages is often not what they make possible - you can write any program in the world in assembler, after all - it's what they make default.

      Rust doesn't allow null values or null pointers. The Rust compiler automatically frees memory when the last reference to it goes out of scope. Variables are immutable by default. You can't use pointer arithmetic by default. Only one mutable reference to any piece of memory is permitted to exist at any one time by the compiler.

      You don't need a new programming language for those features, you can write code in any existing language that follows those conventions. But by making good software development practices the default and having the developer jump through extra hurdles to do things in a way that might be dangerous, the general level of code quality is improved. C or C++ might evolve to the same defaults in 20 or 30 years - but if you want to write low defect systems code quickly today, Rust deserves a look.

      Also, the language designers list most of the features they listed and what they drew them from, and some features in the 0.x releases were dropped when they found few practical uses for them.

    6. Re:wouldn't hold my breath by NostalgiaForInfinity · · Score: 1

      But by making good software development practices the default and having the developer jump through extra hurdles to do things in a way that might be dangerous, the general level of code quality is improved

      Rust attempts to strike a particular compromise between safety, complexity, and performance, and it's not clear that the particular compromise it makes is something anybody really needs. That is, when I want language support for good software development practices and huge software systems, there are better, higher-level languages than Rust. On the other hand, for embedded and real time systems and other low-level programming, C++ is more flexible and far better supported without being much worse than Rust. Rust to me seems like building a dump truck with a luxury car interior.

    7. Re:wouldn't hold my breath by gweihir · · Score: 1

      This seems very likely. Of course the Rust fanatics (in themselves a valid reason to stay away from that language) will claim differently on all points, but that is just propaganda.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    8. Re:wouldn't hold my breath by gweihir · · Score: 1

      Sounds very much like Rust is a huge pain for those of us that actually know what we are doing. Suddenly we need to work around an authoritarian compiler that thinks we are children and it knows best. Not desirable unless your coders are monkeys because you pay peanuts.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    9. Re:wouldn't hold my breath by Tailhook · · Score: 2

      The C++ community is already looking at Rust and trying to figure out how to compete with what it offers.

      Like what?

      Here is Stroustrup talking for over and hour and a half just three weeks ago about how to both narrow and enhance C++ to achieve, among other things, a degree of memory safety, pervasive ownership semantics (std::owner<>) and enabling the compiler do a better job of detecting faulty code. The parallels with Rust are impossible to miss.

      It has been a long time since anything challenged the C/C++ paradigm. In that time a large number of non-"systems" languages have emerged, leaving the low-level stuff to C/C++, and a smaller number of systems languages (Objective C, D, etc.) have also emerged, but nothing so far has provided enough value to motivate broad adoption. I think Rust is a language that does bring sufficient value. I am certain it is inspiring people to use and advocate it, as evidenced by this story.

      It's disappointing to see the sheer number of Rust haters emerging from among C/C++ programmers. You can pan around the comments in this story yourself and read an abundant supply of irrational, ignorant and petulant comments. If Rust disappeared tomorrow it wouldn't cause a ripple, yet it's hated like Java or SQL. Sad.

      --
      Maw! Fire up the karma burner!
    10. Re:wouldn't hold my breath by ziggystarsky · · Score: 1

      Sounds very much like Rust is a huge pain for those of us that actually know what we are doing.

      Honestly, I hope I will never have to work together with someone who "actually knows what he is doing".

    11. Re:wouldn't hold my breath by gweihir · · Score: 1

      The feeling is mutual. Unfortunately, working with nil-whits can usually not be avoided, there are just too many of them.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    12. Re:wouldn't hold my breath by angel'o'sphere · · Score: 1

      I guess that is because you rarely have to write your own templates, as the libraries provide already so many.

      Using existing templates should be easy, best habit is to use typedefs to hide them.

      I usually simply do stuff like:
      typedef list[Person] PersonList; // brakets should be pointed brackets ofc

      However to really learn how simple templates are and how powerfull they are you need to start writing your own ones!

      I loved writing templates, the only things I hate about Java is the lack of multiple inheritence and the missing templates (generics are not very close to templates).

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    13. Re:wouldn't hold my breath by DuckDodgers · · Score: 1

      Every language is a particular compromise between safety, complexity, and performance. Rust clearly puts safety first, performance second, and complexity third but the result isn't that complex and the performance is - no hyperbole - on the level with well written C or C++. Considering the volume of disclosed security vulnerabilities even coming from high profile projects with brilliant teams like the OpenSSL project or the Linux kernel, I think that's a useful target.

    14. Re:wouldn't hold my breath by NostalgiaForInfinity · · Score: 1

      Considering the volume of disclosed security vulnerabilities even coming from high profile projects with brilliant teams like the OpenSSL project or the Linux kernel, I think that's a useful target.

      Neither the Linux kernel nor OpenSSL are written in C++, let alone modern C++, so their bug count tells you nothing about how modern C++ compares to Rust. And I don't think you have thought through what replacing OpenSSL or the Linux kernel in Rust actually would mean.

      but the result isn't that complex

      In fact, my concern is the opposite: Rust looks too simple; that is, it looks like it hasn't come to terms with many of the real-world issues that other languages have had to address.

    15. Re:wouldn't hold my breath by DuckDodgers · · Score: 1

      I know those projects aren't written in C++. I'm not suggesting they be rewritten in Rust, either. I'm just saying that you have some developers highly skilled at writing secure code working on both projects, and mistakes are still made. Even superb developers benefit from improved tools.

      If you feel like going into it, what is Rust lacking?

    16. Re:wouldn't hold my breath by DuckDodgers · · Score: 1

      You're right, of course. Sorry for the incorrect statement.

    17. Re:wouldn't hold my breath by NostalgiaForInfinity · · Score: 1

      I'm just saying that you have some developers highly skilled at writing secure code working on both projects, and mistakes are still made.

      Of course they make mistakes; those projects are written in C, which lacks pretty much all features needed to create safe abstractions. But that's why "Rust is better than C" is not particularly interest. The interesting question is: is Rust substantially better than C++14, and that seems doubtful. Rust is cleaner and simpler, but not by enough to make up for the huge practical advantages C++ has.

      My second point is that if you view those as examples of the application areas where Rust would be good, well, they aren't good examples. There are so few kernels being written that a new language for it doesn't make sense. And OpenSSL is primarily a library to be used inside other runtimes, something Rust doesn't seem designed for and isn't particularly good at.

      If you feel like going into it, what is Rust lacking?

      Many carefully analyzed use cases.

      Many examples of large and successful applications.

      About half a dozen independent implementations, including a Rust-to-C compiler.

      A lot more tools and tool support.

      Far better C integration, including automatic C header file generation for Rust-implemented libraries, so that Rust code can be used as a drop-in replacement for C libraries with essentially no effort on the part of the programmer.

      (There are probably also language features that are problematic, but that's secondary to these other issues.)

    18. Re:wouldn't hold my breath by DuckDodgers · · Score: 1

      Thanks for taking the time to answer. I do appreciate it.

      I think the carefully analyzed use case and maybe someday successful application is the Mozilla Servo project. Otherwise I agree with your points. I was more curious whether you thought the language design itself was flawed, and if so, how. I'm not a language design expert, this is just curiosity.

    19. Re:wouldn't hold my breath by NostalgiaForInfinity · · Score: 1

      I was more curious whether you thought the language design itself was flawed

      I don't think there is such a thing as "the language design itself" without reference to use cases. That's why I think the Rust designers first need to be clear about what use cases they are designing for.

    20. Re:wouldn't hold my breath by strikethree · · Score: 1

      I was starting to become interested in Rust but then you said this:

      The project transitioned from a hobby project to an official Mozilla project in 2009.

      After seeing what they did to Firefox, I can only shudder to think what Rust version 42.3 will look like.

      --
      "Someone needs to talk to the tree of liberty about its ghoulish drinking problem." by ohnocitizen
    21. Re:wouldn't hold my breath by DuckDodgers · · Score: 1

      It seems to me that Servo is the use case. They wanted to start a Firefox redesign from the very beginning, and built a tool that they thought could give them the development experience and software results in a way better than just plain C++11 (since I think Servo was envisioned before the C++14 spec existed).

    22. Re:wouldn't hold my breath by NostalgiaForInfinity · · Score: 1

      Servo source code doesn't look all that different to me from C++11 source code: it's lots of messy functions over a jumble of data structures. The lack of pointers and the increased safety would seem to be pretty easy to accomplish in C++.

      In my view, C++'s biggest problem is with template metaprogramming. Template metaprogramming has turned out to be extremely useful, but the way it is done in C++ is a mess. A C++ successor should replace C++'s combination of overlading, templates, special case methods, and multiple inheritance with better explicit metaprogramming support, limited AOP, and a module system with type parameters; none of those have any runtime overhead. Such facilities might also be used to enforce the use of, say, safe programming styles.

      (Another area where C++ is lacking functionality is reflection; but it looks like that's going to be addressed with the addition of static reflection.)

    23. Re:wouldn't hold my breath by DuckDodgers · · Score: 1

      As I've said elsewhere, I think the interesting and - to my knowledge, unique - feature of Rust is that you get compile time errors if you try to use a pointer after it would have been freed or maintain more than one mutable reference to an object at any time in one thread or across threads. Also variable declarations are immutable by default and must be explicitly marked mutable. I haven't worked with C++ since 2005 and I haven't followed the standard changes, but as far as I know, C++11 and C++14 don't have an equivalent mechanism. So while you can write equally safe and stable C++ code, it requires a lot more careful concentration by the developer.

    24. Re:wouldn't hold my breath by NostalgiaForInfinity · · Score: 1

      I think the interesting and - to my knowledge, unique - feature of Rust is that you get compile time errors if you...

      There are lots of ways of doing compile time checking for memory and concurrency issues. If you impose certain restrictions on how variables are used, you can check at compile time for memory and data races, that's been known for decades. Baking those sorts of restrictions into the type system of a language, however, has never worked well (and people have tried before) because there is really no right answer, only lots of compromises. That's one of the reason the Rust type system keeps changing and why they have dropped a lot of those checks.

      I haven't worked with C++ since 2005 and I haven't followed the standard changes, but as far as I know, C++11 and C++14 don't have an equivalent mechanism. So while you can write equally safe and stable C++ code, it requires a lot more careful concentration by the developer.

      C++'s smart pointers are a superset of what Rust offers. C++ also has excellent static and dynamic analysis and testing tools available. Writing safe and stable C++ just doesn't seem to be a problem in practice, and I see little difference between Rust and modern C++ in practice.

      The only claim to fame for Rust is that it avoid garbage collection, like C++. Once you drop that requirement, there are plenty of excellent languages for general purpose programming (Scala, C#, Java, Swift, Clojure, D, Go, etc.) that offer runtime safety and (often) better concurrency primitives than either Rust or C++.

    25. Re:wouldn't hold my breath by Tailhook · · Score: 1

      ideas that have been on the drawing board for many years

      Letting these ideas languish on the C++ drawing board isn't acceptable to the creators and users of Rust.

      A paper with an in-depth analysis comparing Rust, C#, Go, and modern C++ would be a good start. Case studies and comparisons on large, real-world software systems in areas like gaming, 3D computer graphics, artificial intelligence, neural networks, protein dynamics, astrophysics, distributed computation, GPU programming, kernels, embedded hardware, etc. would also be good.

      Neither C nor C++ started that way. Why must its competitors? Where is that written?

      Rust will not succeed by convincing the haters to love it. It will succeed through those who use it in the real world for gaming, 3D computer graphics, artificial intelligence, neural networks, protein dynamics, astrophysics, distributed computation, GPU programming, kernels, embedded hardware, etc.

      And the haters will go on hating regardless.

      --
      Maw! Fire up the karma burner!
    26. Re:wouldn't hold my breath by Tailhook · · Score: 1

      They haven't been "languishing", most of them have been implemented in C++.

      Apparently Stroustrup doesn't agree, which is why he is proposing sweeping changes to the language. His actions are more compelling than your claims.

      These days, Rust is competing with C++ and a lot of other new languages. So you better make a compelling argument if you want people to invest time in it.

      The arguments have been made, and many have found it compelling. You're free to think otherwise. The compelled do not care.

      So asking for more information makes me a "hater" according to you?

      You didn't ask any questions. Not one question mark. You argued about the meaning of Stroustrup's proposals and falsely accused me of insulting someone. Anyhow, there is ample information publicly available to you about the rational, design, implementation and flaws of Rust, published by the Rust creators, including why they did not choose to try and adapt C++, if you're actually interested. If you have not bothered to examine this — as I suspect — then I'm left to conclude you're just another irrational hater.

      --
      Maw! Fire up the karma burner!
    27. Re:wouldn't hold my breath by DuckDodgers · · Score: 1

      Thanks. I really should give C++ itself another look. The last time I used the language professionally the people were nice and they had the best of intent but the code was a mess. It was spaghetti when I arrived, and as a fresh graduate (fifteen years ago) my best efforts made the problem worse. The whole experience left me sour on the language. I've always known the problem was more the team - especially me, I'm not trying to pass the blame - but I haven't given the language a serious look since.

      I appreciate the discussion.

    28. Re:wouldn't hold my breath by NostalgiaForInfinity · · Score: 1

      Yeah, I know where you're coming from. Other problems were that compilers used to be quite buggy, there weren't a lot of tools, and libraries were a mess. Besides language improvements, new tools like clang and the Boost libraries have made a big difference. C++ is still not my favorite language, but it's become a usable and fairly mature systems programming language.

  14. Use C by menkhaura · · Score: 3, Insightful

    Show him this story to indicate your attention to him and use C instead of this new-fangled and still-evolving language anyway.

    You'll get better debugging tools, more productivity (since you know C better) and a wider pool of replacement developers should the need arise.

    --
    Stupidity is an equal opportunity striker.
    Fellow slashdotter Bill Dog
    1. Re:Use C by ras · · Score: 1

      You'll get better debugging tools

      Rust targets LLVM, and LLVM outputs the same debugging info as the GNU compilers. So gdb, for example, works as well with Rust as it does with C.

      more productivity (since you know C better)

      For a short while. (OK, maybe not so sort in Rust's case as borrow checker is a bitch.) But in the end no, a Rust programmer will beat C with the same inevitability a newbie C programmer will eventually beat an experienced assembly programmer. The reason is the same too. You need far less lines of Rust to do the same thing. Programmers tend to produce the same number of lines of code per day, regardless of language.

    2. Re:Use C by NotInHere · · Score: 1

      Its very simple to get a backtrace for a panic in rust. Just set the RUST_BACKTRACE environment variable to 1 before executing the program. This is something far more easier to explain to your users than to explain the long process how to download a version with debug symbols of the program and use gdb.

    3. Re:Use C by pdxtabs · · Score: 1

      I'm one of those widely available replacement developers that spends a lot of time tracking down bugs in C that would have been caught at compile time in Rust.

    4. Re:Use C by menkhaura · · Score: 1

      This too :) C language helps good developers to keep their jobs.

      --
      Stupidity is an equal opportunity striker.
      Fellow slashdotter Bill Dog
    5. Re:Use C by ras · · Score: 1

      Lines of code is not the measure of productivity

      I didn't say lines of code is good way to measure productivity. Using it as such a measure is counter productive because programmers find ways to bloat the code. Not only doesn't it increase real productivity, it creates a maintenance nightmare.

      What I said was programmers produce the similar lines of code per day, regardless of language. If you are doubt this, you need to go study some more. It's been demonstrated over and over again. There are many things that do effect lines of code delivered of course - the biggest one being project size. Most programmers can deliver a 200 line debugged, working program in a day. Put the same programmer in a large project, and that can drop to 10 lines of code per day, which is far larger effect than language.

      You are right in that lines produced per day by a programmer is effected by language - but It's nothing like 20 to 1. This page shows 4 to 1 at the extreme; Smalltalk vs Assembler, with the assembler programmer producing 4 times as many lines of code as the smalltalk programmer. I guess that's to be expected give how much a meaning a smalltalk programmer can put into one line vs an assembler programmer. If you look at languages that are more similar - eg curly brace languages, you see a difference of only 2 to 1.

      If you look closely, you notice another odd thing. The less lines the programmers write, the more productive they are in delivering function points in general. Now if I had of said because the C programmer writes code faster than Rust productive, he will be less productive I'm sure you would have jumped on me from an even greater height and you would have managed to be more wrong than you are now. I don't know whether it's true for C and Rust, but "the more code a language lets you write in a day, the less productive you will be in it" is definitely a good rule of thumb. In the smalltalk vs assembler case, the smalltalk programmer delivers 3 times as many function points as the assembler program per unit time, while writing 1/4 of the amount of code! If it is true for C and Rust, it annihilates your suggestion that over the life of a project C would be more productive that a Rust.

      Lines of code is not the measure of productivity when two thirds of them require debugging or rewriting because the idiot didn't know what they were doing and used a hammer to drive a screw.

      True. Which is why it isn't measured that way. The usual measure is the total non comment lines delivered over the total time it took to deliver the project, divided by the number of people employed to do it - and that doesn't just include programmers. Here "delivered" means debugged and in production. Which is how a large project ends with with abysmal figures like 10 lines per day. If a language encourages buggy code, which is thrown away that counts against it, not for it.

  15. C like languages by angel'o'sphere · · Score: 1

    What if I need another engineer to work on the code?
    If we are talking about 'C-like' languages, Rust, D, Java, C# ...mI would guess such an engeneer is in the wrong profession, no? Implying he can not cope with Rust, as I understood you.

    --
    Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  16. Being a Pioneer by JustChapman · · Score: 1

    It might be exciting to be a pioneer. But just remember, pioneers sometimes got their wagons burned.

  17. Is Rust written in Rust? by Mirar · · Score: 1

    If Rust, the compiler and everything is written in Rust, then I would trust it.

    It looks like it's written in big parts in C and C++.

    Don't know if it's glue to the rest of the system or that Rust wasn't good enough.
    Maybe someone can elaborate?

    1. Re:Is Rust written in Rust? by angel'o'sphere · · Score: 1

      I'm not aware of a 'compiler compiler' aka parser and scanner generator, that generates Rust code.
      So bootstrapping the language with itself requires a parser generator that emits Rust ...

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    2. Re:Is Rust written in Rust? by UnknownSoldier · · Score: 1

      * https://github.com/rust-lang/r...

      Building from Source

      Make sure you have installed the dependencies:

      * g++ 4.7 or clang++ 3.x

      Notes:

      Since the Rust compiler is written in Rust, it must be built by a precompiled "snapshot" version of itself (made in an earlier state of development). As such, source builds require a connection to the Internet, to fetch snapshots, and an OS that can execute the available snapshot binaries.

    3. Re:Is Rust written in Rust? by dmoen · · Score: 1

      The Rust compiler and runtime system are written in Rust.

      The compiler uses the LLVM library for code generation, which is a C++ library, so there is a bit of C++ glue code to interface the compiler to LLVM.

      The runtime uses parts of the C library to make system calls, so there is a bit of C glue code to interface the runtime to the C library.

      --
      I have written a truly remarkable program which this sig is too small to contain.
  18. Talk to hardware? by selectspec · · Score: 1

    A lot depends on where and how you want to talk to the hardware. Last time I checked, the kernel (or kernel driver) is the only thing directly writing to memory space mapped to actual hardware and the kernel is the only space where you are catching CPU interrupts. Depending on your platform, the kernel is very likely going to be written in C.

    If you are making calls to the kernel drivers from userspace via kernel file interface, ioctls, or some other user-to-kernel API, then you can do that in just about any language that you want.

    Maybe I am missing something here.

    --

    Someone you trust is one of us.

  19. Newer is rarely better by Anonymous Coward · · Score: 1, Insightful

    C may be old, but it's a known entity, you can get plenty of help, it will around in 10 years whereas Rust may not be in use then. The level of C knowledge out there is very high, and should you need help with anything, you can get that help. Not so with Rust.

    I constantly fight the "newer is better" crowd at work, and I refuse to budge. If it works, it doesn't need fixing. I dislike change for the sake of change. I refuse, for example, to ever use Windows Server when my Linux machines work. I refuse to use IIS for anything. Compared to nginx, it sucks, and there is nothing to gain by my going there. DItto Python over Perl, when I have stuff that is working under Perl, there is little point in writing it in Python just because it's more modern.

    C has warts, but its track record is impressive. I refuse to use something that doesn't have years of a good track record. I need to be able to see the mistakes others have made, their fixes, their ideas, what worked for them. Talk with them if possible. Cannot do this with new stuff.

    1. Re: Newer is rarely better by garethjrowlands · · Score: 1

      GP didn't say nginx wasn't good, merely that it was newer than IIS.

      You're right that apache is slow and nginx is much faster. But did you know lots of web servers are as fast as nginx? Notably, that includes IIS (no, I'm not saying you should use IIS).

  20. Use the right tool for the job by krazdon · · Score: 1

    Most problems you need to solve already have libraries to make it easy. So figure out what your specific problem is, find the right library and language combination that best supports you. If you really care about performance, or some other specific metric, then you might need to use another language, but in general, I'd say use the your favorite language that supports the library you need to achieve your goal. I am currently using C#, javascript, java, C++, shellscript, and a couple other languages. And for each additional feature, I ask myself what is the best tool for the job. There are many ways for different languages to inter-operate, so don't feel that you are confined for just one language. If you think that rust is the best language for a particular task, use it and integrate it with the rest of your code. And if later you decide that another language is better at doing that task, someone can port that one task without having to rewrite your whole stack.

  21. Long-term support by Anonymous Coward · · Score: 1

    You're writing software for the embedded/industrial market. Someone will have to deal with your pile of poo in 10 years. Will Rust be around in 10 years?

    1. Re:Long-term support by dmoen · · Score: 1

      Rust has already been around for 10 years. The project started in 2006 as a hobby project, and "went big" in 2009 when people could play with a working Rust compiler, and Mozilla sponsored it. There are currently 1200 contributers to the Rust project. Given all the momentum, it will likely be around 10 years from now.

      --
      I have written a truly remarkable program which this sig is too small to contain.
  22. Re:Rust is nice, but rough around the edges by zAPPzAPP · · Score: 1

    I am struggling to understand how the 'listen backlog size for a TCP socket' could be a feature of a 'C like' language.
    Are TCP sockets a fundamental variable type in Rust?

  23. It depends... by JustAnotherOldGuy · · Score: 1

    Now I'm heading a project that uses a RoR application...

    To quote an old Irishman I knew once, "Oh boy, now yez' inna helluva fix!" :)

    But seriously, as for what language to use, that would be one that you know and are familiar with that can do what you need it to do.

    In other words, I have no idea because there wasn't really enough specific info in your post for me to take a good guess. Sometimes it's best to work backwards and figure out what tools or languages won't work or aren't suited to the task. That can often help narrow down the list of possible choices, of which there are many.

    --
    Just cruising through this digital world at 33 1/3 rpm...
  24. He could by DarkOx · · Score: 1

    said he could write the extensions needed easily in Rust.

    This is probably true but its also aggressively stupid. Ruby, Matz Ruby anyway, is a C program, Rubinius is a C++ program, JRuby is Java. The point of writing Ruby extensions obviously is so that you can leverage the expressive power of the high level interpreted language to get stuff done fast and safely while interfacing whatever it is you need to interface.

    Your extensions should not be complex. They really should allocate a little memory to store what needs to be stored, and do some type conversions from Ruby's more primitive types to whatever you interface needs to see and not much more. The thinking should happen in Ruby. If you are writing all kinds of smarts and logic into extension itself you are probably doing it wrong.

    So why would you introduce a third language technology to the stack? A C extension should be quick to audit and verify. There are also lots and lots of people familiar with writing ruby extensions in C, few in Rust.

    I think Rust is cool but this isn't a Job for Rust. Now implementing RRuby might be!

    --
    Repeal the 17th Amendment TODAY! Also Please Read http://www.gnu.org/philosophy/right-to-read.html
  25. Re:Why not to use Rust by jedidiah · · Score: 1

    You can't.

    I believe that point 3 is what humans call humor.

    --
    A Pirate and a Puritan look the same on a balance sheet.
  26. Rust is cool by radish · · Score: 3, Insightful

    But it's still immature. I wouldn't personally use it for anything important.

    --

    ---- Den ene knappen er powerknapp, den andre er Bender voice knapp "Bite My Shiny Metal Ass"

  27. Maybe? by jandrese · · Score: 1

    I've heard Rust mentioned a few times so I decided to give the manual a once over to see what it is all about. First impression is that it is a very C like language, except that the memory model is highly regulated. This is good in some ways, it should be nearly impossible to screw up your memory handling with normal code making it safer by default. However, in my brief glance over I can't see any way to allocate a block of memory at runtime, which seems like a significant drawback. The language appears to have "C Programmers Disease" baked into the specification. There is a brief mention in the vector section that they are growable and live on the heap, but doesn't give the syntax for this (nor the syntax to shrink them later!). The docs also make a huge dance around "borrowing" that smells a lot like someone avoiding the dreaded "P word".

    It looks like a neat language and I'm willing to give it a shot but I don't see this exploding in popularity anytime soon. There is always the chicken and egg problem with new languages that people don't want to learn it until it has a decent ecosystem, but it won't grow an ecosystem until people start using it.

    --

    I read the internet for the articles.
    1. Re:Maybe? by ras · · Score: 1

      However, in my brief glance over I can't see any way to allocate a block of memory at runtime

      Jeezze, you weren't kidding when you said brief. An Overview of Memory Management in Rust.

    2. Re:Maybe? by NotInHere · · Score: 1

      Some things rust guarantees, others it doesn't:
      https://doc.rust-lang.org/nigh...

      Rust considers it "safe" to:
              Deadlock
              Have a race condition (https://doc.rust-lang.org/nightly/nomicon/races.html)
              Leak memory
              Fail to call destructors
              Overflow integers
              Abort the program
              Delete the production database

    3. Re:Maybe? by jandrese · · Score: 1

      Would have been nice if the official manual mentioned some of this...

      It also doesn't mention the one thing I wasn't clear on. Can you go:
      let size :u32 = readbytes(protocolStream, 4);
      if makes_sense(size)
      let data :protocolstruct = readbytes(protocolStream, size);


      I know I made a total hash of the syntax there, but you get the idea I hope.

      --

      I read the internet for the articles.
    4. Re:Maybe? by jandrese · · Score: 1

      Well, I guess we can't be too hard on the Rust developers for not solving the halting problem.

      --

      I read the internet for the articles.
    5. Re:Maybe? by ras · · Score: 1

      Can you go:

      Of course you can, syntax notwithstanding. But asking questions here is an awful way to learn the capabilities of Rust given they have published a free online book to teach you just that. It would only take you a day to work through the entire thing. It being open source and all, once you have done that next step would be to look up the code for the standard libraries for that that does something like you want. There is nothing like studying the work of an expert in the field to get you up to speed fast. They even give an example that looks like yours in the standard library doco.

    6. Re:Maybe? by jandrese · · Score: 1

      That book is what I was reading (and linked to in my post).

      --

      I read the internet for the articles.
  28. Not if you need to suspend code by sconeu · · Score: 1

    If your code has to suspend itself for a specified period of time, then I would not recommend using Rust. Remember...

    Rust never sleeps.

    --
    General Relativity: Space-time tells matter where to go; Matter tells space-time what shape to be.
    1. Re:Not if you need to suspend code by mmmmbeer · · Score: 1

      I should've seen that coming, but it was out of the blue.

  29. Another Option by Feneric · · Score: 1

    Alternatively you could try using a modern language like Nim that'll give you the same sorts of benefits as Rust, but allows compilation into C so you have the same expectations and performance as you would with C.

  30. Concentrate on the Employee by TechyImmigrant · · Score: 4, Insightful

    The engineer pushing for rust is emphatic, should I bulldoze him or take the plunge?

    Take yourself out of the loop. Give it to the engineer. He/she wants to push it. Let him/her. Make the engineer responsible for pushing it, training people, documenting the procedures. Provide room to enable it to happen.

    This is how the engineer grows and an engineer and how you grow as a manager, learning to trust the technical opinion of those doing to technical work.

    --
    I should use this sig to advertise my book ISBN-13 : 978-1501515132.
  31. Re:Rust Lacks OOM Handling by 0123456 · · Score: 1

    If your embedded system can't be allowed to crash, you shouldn't be calling malloc(). At least, not once you've booted up and started running the main code.

    The embedded software I work with typically has fixed-size arrays allocated at startup, and explicitly handles cases where it doesn't have enough space in the array.

  32. Re:It's just a gem by dargaud · · Score: 1

    I'm a C hardware programmer and I have no idea what a GEM extension is. I tried to look it up, but it seems to be a term relevant to the Ruby world. So, I'm interested in this thread, but I have no idea what Rust or Gem are.

    --
    Non-Linux Penguins ?
  33. Re:Why not to use Rust by Fwipp · · Score: 2

    Isn't humor supposed to be funny?

  34. Good software engineers can learn new languages. by bezenek · · Score: 1

    A good software engineer should be able to learn a new language in a week or so. If there is something inherent in the language which makes this not possible, e.g. pointers, generics, functional v. procedural, etc., then the software engineer has a gaping hole in his/her knowledge and may need some additional training.

    That point aside, I think the discussion here makes the decision C, mostly because of unknown future support for Rust--it is too new to know.

    Unless C has an easily describable deficiency which will be covered by a different language, there is no argument here.

    An engineer not being willing/able to learn C does not count as a deficiency in C. The same is true for Rust.

    Also, if one particular engineer has a strong preference for Rust, for the preference to be an informed decision, the engineer must already be familiar with C, so there should be no problem for that engineer to work in C if the decision goes that way.

    --
    Omne ignotum pro magnifico.
  35. Re:Rust is nice, but rough around the edges by fnj · · Score: 1

    Are TCP sockets a fundamental variable type in Rust?

    No. But std::net in the standard library implements socket support. Presumably it is assumed that the user who needs a socket is going to use this, although of course calls to a C socket libraries could be made if std::net is not sufficiently flexible.

  36. C does not need replacement by flarflue · · Score: 1

    it is not the C language that is the problem, it is the programmers who are using it that are the problem. they are not educated in good programming practices. most people who want to be programmers should never be allowed to become programmers. unfortunately right now lots of narcissistic nerds want to become programmers because they think it's glamorous somehow.

    1. Re: C does not need replacement by rrr00bb5454 · · Score: 1

      Actually, the environment has changed since C was created. C is still wonderful for programs that are small. It's perfect for an environment of static allocation. It gets its speed *precisely* from assuming that undefined behavior does not happen. This alone makes it terrible a terrible choice for large programs that must stand up to malicious input (let alone bad coding - and even sabotage that slips past code review). The world's cryptography libraries are a fantastic case in point, where the best developers in the world are constantly having their security broken The input that modern programs must consume generally requires Turing Complete recognition. It asks the code to solve NP-complete problems and Undecidable problems at the time the code is written, and at runtime. On Windows systems, more CPU time is wasted running Virus scanners and ad-hoc security checkers than would be consumed by simply having applications just be written in more verifiable languages. This mostly boils down to having type systems which can be verified. https://web.eecs.umich.edu/~pr... Rust has issues in embedded settings, but it's not a fat and lazy language. You can run Valgrind on Rust binaries, as its output is essentially the same as C. There is a lot wrong with C from the point of verification. At the moment, you can't simply assert to the compiler (in C) that if there are type system violations that you don't even want the binary to be produced. Not even for small programs. The software industry needs to grow the hell up and start making systems that can be certified for safety.

    2. Re: C does not need replacement by rrr00bb5454 · · Score: 1

      I would also add other things that changed since Unix/C came out: 1) The whole Unix design is the bottleneck in large servers. Read about "Data Planes" and the 10MillionConnection problem. 2) Physical memory protection and Kernel/Userspace split impose horrible costs. There is a reason that extremely high end server systems essentially run as userspace processes that binds some cores and some ethernets together and basically disables the kernel -- which puts every single thing into one gigantic process. 3) If something needs to be produced, there is a dollar amount that can be sunk into it. If it requires a large group of the most expensive developers, it will simply never be built for economic reasons. Therefore, we see a lot of half-baked stuff get built instead.

    3. Re: C does not need replacement by hey! · · Score: 1

      Well, you have to work with the programmers that there are; not the programmers you wish there were.

      I learned C in 1980; it was a thing of beauty, a work of genius that transformed the industry. That doesn't mean it has to be all things to all people. In fact that's C's great strength; it's just enough of the very most useful things to enough people to make important systems programs like interpreters for other languages portable across many environments. The flip side of that is that for certain scenarios there's bound to be languages that are a better fit than C.

      So if C's reliance on pointers or programmer managed memory allocation creates problems with the pool of programmers you have ready access to, the answer isn't to stamp your foot and wish all programmers were like they were back into the good old days of Unix 7; it's to use something else.

      --
      Post may contain irony: discontinue use if experiencing mood swings, nausea or elevated blood pressure.
    4. Re: C does not need replacement by flarflue · · Score: 1

      This is an industry that knowingly and liberally discriminates against older workers who use the C language more wisely. Could it be that you've been involved in downsizing older workers?

    5. Re: C does not need replacement by Grishnakh · · Score: 1

      Exactly. So if your programming team aren't all experts in C, you need to just fire them all, and hire ones who are. Expert-level C programmers are everywhere these days, and can be hired cheaply. Your company's upper management will have no problem with you taking extra time to find enough expert-level C programmers and get them hired and started in the company.

    6. Re: C does not need replacement by flarflue · · Score: 1

      Unless of course
      (1) if upper management is evangelical about outsourcing, in which case they utterly refuse to hire local citizens, [ this happens in the USA but I have also seen it in the Netherlands] or
      (2) if hiring managers are of one certain ethnicity and refuse to hire anyone outside that one narrow ethnicity, like you might see at Samsung, Oracle, Cisco, Infosys, Tata, Ebay, etc.. [ speaking from experience ] or
      (3) the hiring managers are all 20- somethings who view older workers as being like primitive cave dwellers because they use the command line on occasion instead of Xcode.

  37. Re:Rust Lacks OOM Handling by fnj · · Score: 1

    If your embedded system can't be allowed to crash, you shouldn't be calling malloc().

    That's more dogmatic than I would accept. I worked on a highly successful system that was full of malloc and free calls, which had to work autonomously for greater than one month submerged in the ocean with only brief surfacings with very low bandwidth RF connection. We had a lot of discipline and applied a lot of care and testing. There were times that in-service instances did crash, reboot, and continue operating, but these were rare. We did forensics to identify what happened and correct the error. I was highly impressed by the operation.

  38. Re:Rust is nice, but rough around the edges by mwvdlee · · Score: 1

    Sounds more like a library issue to me. It is a hallmark of a badly designed library though. Making common things easy is good, making common things easy while making uncommon things impossible is bad.

    The default TCP settings may be perfect for 99% of the time. For the remaining 1%, this library is useless.
    If you think this may be fine, let me ask you this; have you ever created a program which didn't have atleast one uncommon "1%" thing in it?

    A programmer who believes there is no possible way some particular feature would ever need to be used, is a programmer who is too unexperienced and entirely unqualified for his job.

    --
    Slashdot social media options: AIM, ICQ, Yahoo, Jabber and Mobile Text. Why no MySpace?
  39. What is that project for? by janoc · · Score: 1

    If it is just for fun, go ahead and play with Rust. You can write C-compatible libraries with it no problem.

    If it is for work, however ... Stay with your C.

    Rust is nice and everything, but the ecosystem is incredibly small. There are few libraries for it, many are already unmaintained and/or not working. Also the tooling (IDEs, compiler, the cargo build tool, etc.) are fairly immature. I have been looking at it recently with the goal of writing some extension modules for Node.js & .NET, but I went back to regular C for this reason.

  40. I don't know about replacing C by morgauxo · · Score: 1

    I don't know about replacing C but my car certainly seems to think that replacing Fe with rust is a practical thing to do!

  41. No. by cowtamer · · Score: 1

    C has probably been around longer than you have. Rust probably isn't even a blip on the radar.

    Be very wary of embracing immature technology for anything that matters. There are good reasons to do it, but they have to be EXTREMELY good reasons.

    Otherwise, even if the tech succeeds, you will be stuck with a code base with immature and deprecated idioms. (Note the very old Java applets you sometimes see on the web that modern versions of Java make nearly impossible to run. So much for "write once run anywhere". There are no such programs written in ANSI C -- unless they involve 3rd party libraries).

    You will also have to deal with buggy and immature developer tools and will spend weeks debugging problems that might be resolved with a simple Google search in C.

    I have learned this the hard way, unfortunately..

  42. Re:Embedded by serviscope_minor · · Score: 1

    Unless you might want to switch architectures in 2 years, and you don't want to only choose from architectures with good C++ compilers.,

    At this point, it's segmented PICs (? maybe) and obscure DSPs without C++ compilers. Just about everything else is supported by GCC a or IAR, both of which compile C++, though IAR is about 5 years out of date in that regard.

    In any case if you're that deep embedded, porting is basically a rewrite anyway.

    --
    SJW n. One who posts facts.
  43. Obvious solution... by LynnwoodRooster · · Score: 1

    Let the new engineer write in Rust, and you write a Rust interpreter in C! Both sides win, right?

    --
    Browsing at +1 - no ACs, I ignore their posts. So refreshing!
  44. Re:Rust Lacks OOM Handling by 0123456 · · Score: 1

    There were times that in-service instances did crash, reboot, and continue operating, but these were rare.

    Like I said... if your embedded system can't be allowed to crash.

    Clearly, yours could. For other systems, people die when they crash.

  45. Re:Why not to use Rust by dmoen · · Score: 2

    1) The Rust project is not controlled by Mozilla. Just look at the copyrights on the rust source code. It's permissive open source, with copyright shared by ~1200 individuals, and Mozilla is not on that list. So this is like spreading FUD by warning people that Linux is controlled by the Linux Foundation (Linus's employer)--hint, it isn't.

    2) Mozilla and Oracle are quite different. The Mozilla Foundation is a non-profit, open source organization that exists to provide a public benefit through the creation of open source software. The Mozilla Corporation (employer of some of the Rust developers) is a wholly owned subsidiary that donates all of its profit to the foundation. By contrast, Oracle is known for being one of the most rapaciously greedy software organizations in existence: just consider the Oracle article on Slashdot right now, about how Oracle rips off customers via "traps" in the opaque licencing terms.

    3) How can you be sure that Rachael Craig and Nicolette Verlinden are cisgender males? They have female names and photos.

    So yeah, I'm pretty sure the parent is a troll, and I fell for the bait.

    --
    I have written a truly remarkable program which this sig is too small to contain.
  46. Rust may actually be a safer choice by raboofje · · Score: 1

    Rust's type system provides protections against some problems that can be quite hard to debug in C.

    Between having a programmer that is inexperienced in C writing C code and having a programmer inexperienced in Rust writing Rust code, arguably you might be better off with the latter.

    This sounds like a reasonably small component, so what is the worst that could happen? That you would have to rewrite it some day? I'd say go for it.

  47. Heading a project? by wnfJv8eC · · Score: 1

    OK. The answer is very simple. Does Rust buy you something, timing, memory space, cheaper architecture, that C doesn't. What the language buys is critical.

    You are producing code for a business that must maintain it going forward, after you are gone and your young enthusiastic engineer has gone off to find a better job. He will.

    Realtime control has limits that must be observed. After that the choice of languages is all about long term support. So check the hire boards and see how easy it will be to replace your young enthusiastic engineer. If easy, make sure the next hire or two has Rust under their belt. Or go with C. The next hire will know that language.

    What I 'like' is not relevant. I liked bash for most system level scripting, but often python is a better choice. So I use python.

    Last. Talk your choice out with the young engineer. Let him know you took him seriously, did your homework. He's follow your lead easier with that example.

  48. "What if I need someone to work on the code?" by Applehu+Akbar · · Score: 1

    No problem. Just tell HR to advertise for someone with ten years of Rust experience.

  49. I Reckon What You Have There by Greyfox · · Score: 1

    Looks like you have an engineer that wants to play with Rust on your dime. I've seen a lot of projects try to shoehorn a lot of shitty code in a lot of shitty languages into working because some jackass thought he could be more clever in that language. A few months later he's gone and you're stuck trying to maintain some abomination that tries to do asynchronous IO using threads in Ruby or some other goddamn shit. If you have an elevator shaft on hand, I suggest you acquaint him with the bottom of it, and then get on with your project.

    --

    I'm trying to teach myself to set people on fire with my mind... Is it hot in here?

  50. Depends on a lot of things, including workplace. by MouseTheLuckyDog · · Score: 1

    First is it really an engineer or is it you?
    If it is you then should have done enough independent rust projects to be able justify it to management without going on slashdot.

    If there is another engineer, ask to see his rust projects. Make sure they are complete and run them under valgrind or similar tool to make sure it's clean.

    Keep in mind he may want to do this project in Rust to put it on his resume and find a job where he does Rust full time.

    Finally keep this in mind. It's always the young engineers that hate C/C++. It was that way twenty years ago. Why?

    Because the young engineers go running to alternatives, and then wind up getting out of programming. Leaving us old timers who don't mind C/C++.

  51. Re:It's just a gem by NotInHere · · Score: 1

    I think this is somebody trolling. FFI and gem are common fanboy words.

  52. So my story is... by Anonymous Coward · · Score: 1

    We had a similar situation. I won't bring up the language for fear of derailing the conversion but a new engineer had a favorite language and pushed for its use in a new project. Even though no one else on the team knew the language, we believed his tales of faster development time and unicorns and rainbows. Sadly, he left the company a few months and we ended up having to rewrite the stupid thing since once we started looking at what he had done, we realized it would be faster to just rewrite it so it ended up being 6 weeks of wasted time. My recommendation is that if you don't know the language, don't put yourself in the position of having to support it. Bulldoze away!

  53. Oblig. Shakespeare by Capt.Albatross · · Score: 1

    Glendower:
    I can call spirits from the vasty deep.

    Hotspur:
    Why, so can I, or so can any man;
    But will they come when you do call for them?

    - Henry IV, Part 1

  54. Assembly? by meburke · · Score: 1

    I suppose that if you want to be close to the hardware and you don't know assembly, C is OK.

    --
    "The mind works quicker than you think!"
  55. Re:Rust Lacks OOM Handling by ras · · Score: 1

    Rust should add rudimentary support for exceptions

    It does have exactly that, rudimentary being the operative word. It has panic(), which doesn't kill the program but does kill a much larger unit of it (a thread actually) then try/except/finally normally controls. Still, it's enough to recover from things like out of memory, because it guarantees the memory will be freed.

    The reason it has only rudimentary exceptions is because it can do the by combining it's type inference engine with it's spectacularly powerful macroing system. The type system allows you return arbitrary stuff with the caller really having to know or care (because it has an implicit type generation), and they have provided a "try!" macro in the standard library. So it's all there, just not done in the conventional way.

    And in case you are wondering why force you to learn this newfangled way when the old way worked perfectly well - it's because the old way imposed run time over heads on everything. The new way handles it in the type system so overheads disappear at compile time.

    It's just a repeat of Rust's memory handling solution, really. In C you handle memory allocation and exceptions manually, with all sorts of nasty consequences like dangling pointers and people dereferencing NULL. Java/C#/YouNameIt eliminates the nasty consequences using run time solutions like gc and exceptions - but they impose a runtime overhead. Rust brings something totally new to the table - the programmer handles it, but the language eliminates all the nasty consequences. So it's fast like C, and safe like Java/C#/YouNameIt. But there is nothing free in this world. Rust's extracts it's pound of programmer flesh with it's borrow checker.

  56. Failures with IBM Computers by billstewart · · Score: 1

    The mainframe failed significantly twice that I knew about when I was in college. IIRC, it was a 370/168. Once was because the water-cooling plumbing leaked all over the motherboard. Another time was because it really didn't like it when they added the fourth megabyte.

    The System/34 minicomputer I used for a summer job failed because we were a steel fabricating company, and somebody in the shop was looking for the circuit breaker for his welder, and turned off our power instead. That would be fine, but our data entry clerk had been typing in a list of parts for a bid for six hours, and while the OS had saved where the file started on the disk when she opened it, it wouldn't save where the file ended until she closed it. So I spent about 5 hours on the phone with tech support, walking through the equivalent of fsdb to find all the blocks of the file, store their locations in the inode-equivalent, and write the end-of-file marker on the disk.

    --

    Bill Stewart
    New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
    1. Re:Failures with IBM Computers by stridebird · · Score: 3, Insightful

      So you spent 5 hours of your time, and 5 hours of tech support time, to avoid the data entry clerk spending 6 hours simply rekeying the data? Why? Doesn't sound like the right choice, unless the clerk had gone home already or something.

    2. Re:Failures with IBM Computers by towermac · · Score: 2

      Reminds me of the time the owner and his wannabe tech friend were poking around the IT closet one night, and mysteriously, our payments database crashed, corrupted, and unrecoverable. I spent all night trying to restore the previous days receipts. Hell, I even tried a hex editor to get something, anything. The file was complete garbage. Probably $100K unaccounted for, I was thinking the bank and investors are not going to like that, the company may be toast.

      The next morning, I told the accounting boss (owner's daughter) I had to use the backup, and all the payment records from the previous day were lost. She got the four accounting clerks to re-enter the previous days payments in about 30 minutes. Dang, no big deal.

      I learned a valuable lesson that day, and hopefully, so did the boss.

    3. Re:Failures with IBM Computers by billstewart · · Score: 1

      This was a summer job in college at a small company, and the data entry clerk probably got paid more than I did, and I was on a later shift than she was (since only one of us could use the computer at a time anyway.) I don't care what it cost IBM to pay their tech support people. And we didn't know it would take 5 hours to fix the thing when we started, or we would have talked about whether to just have her retype it.

      --

      Bill Stewart
      New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
  57. Learning pointers is easy - being careful isn't. by billstewart · · Score: 1

    Ok, I'm from a different era, but learning pointers wasn't that hard, though it was pretty much the key to C programming. It took a bit of reading library source code to really understand what K&R was saying about them, by seeing how other people used them, but they were amazingly simple and powerful.

    The problems with pointers were that you always had to be careful that they were pointing to something appropriate, and that you had to know how big the things they pointed to were (in case they were passed to you from somewhere else or you were passing them _to_ somewhere else), so you still had to always always ALWAYS be careful to either do bounds checking, or put sentinels into the data, as well as checking that a pointer that some function handed you wasn't NULL or some other evil value.

    And reading library source code included looking at things like strcpy() doing
      while(*feet++ = *bullets++);
    and noticing that it was much more efficient not to bother checking that "*bullets" would hit a zero before "*feet" ran out of places to store it, because obviously the person doing the function call would have checked that, so you didn't have to worry about shooting anybody else's feet. And then you have to learn not to do that yourself, which way too many people haven't learned over the last 35 years, which is why almost nobody should be allowed to program in C, even though it's my favorite programming language.

    --

    Bill Stewart
    New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
  58. Go C++ instead. by Chalnoth · · Score: 1

    C++, especially C++14, provides a lot of the nice features of a language like Rust, but will interact well with all of your existing C code. Far, far more engineers understand C++ well, so having somebody else pick up the project will be much less of a burden.

    The main drawback of C++ is that it can be a bit of a tricky language to use properly. There are some unfortunate caveats that require some level of expertise to write code that doesn't blow up once it goes beyond moderate complexity (I highly recommend Effective C++ as a good book to read on the subject).

  59. Learning curve by neoedmund · · Score: 1

    Rust is a language I feel I want to learn it when I saw it the first time after learned C,Java,Python. But as I go on, I found I must "Think in rust" and "Write code in rusty ways" to master it. Then I gave up.

  60. Re:It's just a gem by phantomfive · · Score: 1

    A gem extension is a way to call into C from Ruby. I think that's what the GP is referring to.

    --
    "First they came for the slanderers and i said nothing."
  61. Re:Rust Lacks OOM Handling by garethjrowlands · · Score: 1

    Looks to me like the problem with OOM is the standard library. You probably want to avoid the Rust standard library when doing safety critical embedded.

    https://users.rust-lang.org/t/...

  62. what about OS's or small footprint? by Chirs · · Score: 1

    There's really no reason ever to use C over C++ if you have a C++ compiler available.

    What about for something like an OS? Or for tiny little embedded stuff where memory is an issue? (Honestly curious, I'm not current with the latest C++ developments.)

    1. Re:what about OS's or small footprint? by serviscope_minor · · Score: 2

      What about for something like an OS?

      The only coherent argument I've seen for writing an os C rather than C++ is the annoyance of setting up the C++ runtime (it can be done though). The only other arguments I've seen basically assume that the world of computing has not advanced since about 1995. What were valid points then are simply wrong now.

      Or for tiny little embedded stuff where memory is an issue? (Honestly curious, I'm not current with the latest C++ developments.)

      C++ doesn't use more memory than C. In fact because the language is more advanced, idiomatic code is often more efficient and less consuming of memory than C. C++ runs just fine on an ATtiny MCU and things don't get much smaller than that.

      Bear in mind C++ is almost a strict superset of C. Everything you can do in C, you can do in C++. But C++ is a more powerful language and it gives you the power without compromising on size or speed.

      --
      SJW n. One who posts facts.
    2. Re:what about OS's or small footprint? by Chibi+Merrow · · Score: 1

      Bjarne Stroustrup has always maintained that the ability to do systems programming is an essential feature of C++. It was designed that you should be able to write very resource-constrained, performant code when necessary.

      Not too long ago he wrote a very good essay on the benefits of languages like C++ for infrastructure programming, and how it can save memory (and electrical power, even).

      --
      Maxim: People cannot follow directions.
      Increases in truth directly with the length of time spent explaining them
  63. is it simpler for the case or not though. by gl4ss · · Score: 1

    that's actually not that big or long time to been around.

    the question I would pose would be.. would it be the same trouble to do it in C. it's just an interface that they're building so the rust code and C code are likely to be the same size and same complexity, heck they will be c externing the stuff for ruby anyways.

    so go with C. unless you want a pilot project in the company done with rust..

    --
    world was created 5 seconds before this post as it is.
  64. after the hype by Tom · · Score: 1

    There's a reason we still use C after all these years and one million attempts to replace it with something else. Most of the over-hyped C replacements have gone the way of the Dodo bird. Those who are still around bring something new to the table instead of trying to outdo C in its own domain.

    Unless you understand why this is so, don't even think about doing something else.

    --
    Assorted stuff I do sometimes: Lemuria.org
  65. I think this is actually coder incompetence by gweihir · · Score: 1

    There is this large number of younger coders that got into IT not because they love it, but because they thought it was a sure meal-ticket. These people are scared by things like pointer-handling or memory management, because they do not actually understand it. Then they jump on every new thing that comes around just because they hope it will make them appear less incompetent.

    The rabid pro-Rust crowd is an excellent example, because the benefits of Rust are not actually that remarkable and, in addition, both language and libraries are immature and hence should never be used in any production project at this time. Yes, they _can_ be used, but that would be hugely unprofessional and bring more problems with it than the language can solve. The one exception is the Rust developers themselves as they have to accept that drawback in order to get experience with their language. Nobody else has to and nobody else should.

    --
    Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  66. Re:Embedded by serviscope_minor · · Score: 1

    That is simply not true.

    I was referring to the tiny micros, not the DSPs, though that's not clear. When fiddling with those tiny micros, the majority of the code is register tweaking to set up the peripherals correctly. None of that's portable to a different manufacturer.

    --
    SJW n. One who posts facts.
  67. Let him rip! by business_kid · · Score: 1

    Ypu're a C programmer, but I gather ypu have stagnated somewhat and have a management function. He is still a programmer at the coal face. Let me hazard a guess that you have stopped working days and studying at night.

    You need to be a programmer OR a manager. If you're a programmer, get up to date( a huge job) and name 6 languages he could do the task in and learn at least three of them. Then stay up to date. If you're a manager, He is the professional. Do you trust his choice? Empower him.

    My son is a Swift (=Apple OS & IOS) programmer. He programs phones, watches, Apple TVs He can program in about 20 languages. He wrote a multitouch project in Chuck. Ever heard of that?

  68. Re:No by gnupun · · Score: 1

    Yes, the junior devs should beta test compilers/languages on their own time. After 3 to 5 years of free labor by thousands of programmers, most companies will be able to determine if Rust is worthy of production. It's called free testing.

  69. Rust: It has great support to call into C code ?? by fygment · · Score: 1

    .. and so does C ...

    If you're going to call in to C libraries, then why use another language?

    --
    "Consensus" in science is _always_ a political construct.
  70. Probably by Elbows · · Score: 1

    Rust can give you precise control of memory layout, and supports inline assembly as well as calling C functions. So it ought to have everything you need for controlling hardware.

    Rust the language is young but stable (code you write now should continue to work in newer releases). And it sounds like this is a relatively small project that shouldn't need a ton of 3rd-party libraries, so the maturity of the library ecosystem isn't as big a concern.

    My experience was that Rust took a little getting used to but it's a pretty nice language. In addition to the safety guarantees, it gives you a lot of expressiveness compared to C++ and (especially) C -- algebraic datatypes, very nice iterators, lambdas, generics, etc. And I expect that any well-rounded developer with a good grasp of C could learn Rust pretty quickly.

  71. Re:Good software engineers can learn new languages by SpeedBump0619 · · Score: 1

    Right. In my career I've been taught one language (Pascal) and been tossed face-first into 4 other languages: C/C++, C#, Lisp, and Python. Language learning happens in phases:
    - I can learn the syntax, reserved words, flow control, and basic structure of a language in 3-4 days. At that point I'd be able to take a small block of simple code and figure out what it's doing. I could write very simple programs to do pretty pointless things.
    - Given another week or so I could learn enough of the support libraries to have some exposure to basic things like file access, network APIs, thread and process creation, database access, etc to understand what more general code is supposed to be doing. So about two weeks in I could start contributing to real work by finding and patching certain types of bugs, adding simple feature extensions, or building useful test cases.
    - Given another 2-4 weeks of work I might be knowledgeable enough to create moderately complex subsystems, debug most single factor bugs, or begin commenting on any architectural problems.
    - I won't know enough to make architectural changes for another month or more.

    In the end, I wouldn't trust myself to make big changes on less than three months familiarity with a language. With some projects I'd want that much time just on that project's codebase, *after* the three months getting familiar with the language. At that point I've probably learned enough to know what it is I don't yet understand.

  72. By all means - YES by Progman3K · · Score: 1

    because we WANT our programmers to eventually not understand how a microprocessor works.

    We need to breed a dumber programmer so s/he can write buggy code, fast.

    Make it idiot-proof because eventually the bar will be so low, only idiots will be needed to do the job.

    If we're lucky, this will cause a resurgence in VisualBasic.

    --
    I don't know the meaning of the word 'don't' - J
  73. C to Rust by maclark88 · · Score: 1

    My C got wet and it turned to Rust.

  74. Re:Why not to use Rust by tigersha · · Score: 1

    I would be more worried about the fact that the team also has one gorilla, a werewolf, something that looks like a walking dildo, a female hentai character that seems to be getting some action from behind off-screen, a kitten, a cat and a penguin.

    On the other hand, Yehuda Katz is there. He is a very major Ruby on Rails contributor. As a dedicated RoR fan that worries me because if he jumped ship RoR lost a very valuable contributor.

    --
    The dangers of excessive individualism are nothing compared to the oppressiveness of excessive collectivism
  75. Re:Why not to use Rust by Grishnakh · · Score: 1

    Sounds like a micro-aggression to me.

  76. Re:Rust Lacks OOM Handling by Grishnakh · · Score: 1

    That's more dogmatic than I would accept.

    Then you're completely unqualified to work on avionics code under DO-178B. Freeing memory is strictly forbidden. If you have to free memory, you're doing something wrong.

  77. Re:Depends on a lot of things, including workplace by Grishnakh · · Score: 1

    It's always the young engineers that hate C/C++. It was that way twenty years ago. Why?

    WTF are you talking about? 20 years ago I was still in school, and everything was C or C++ (or assembly). We didn't have any alternatives back then, except Java, which at the time was still very new. Of course, there were a bunch of academic languages and older languages: FORTRAN, COBOL, Lisp, Forth, Pascal etc., but most of those are older than C; in fact, in 1995, C++ was a relatively new language.

  78. Re:Depends on a lot of things, including workplace by MouseTheLuckyDog · · Score: 1

    You know what?

    It helps if you know what you are talking about.

    1995 C++ was not "relatively new". The ARM was published in 1990. Meyers and Cope were both published in 1992. I don't know about your potentially inferior schools, but I saw tons of C++ programmers around.

    And there were very many alternatives around. Start with the two you mentioned. Lisp and Pascal. There were three commercial Lisps ( which cost a lot ) out there: Allegro CL, Corman Lisp ( Ok Windows only and very cheap ), I can't remember the name of the third. Pascal-- ever heard of TurboPascal or Delphi? Ok not portable but no one cared. And guess what? A lot of the young engineers were screaming "Let's do it in Lisp" or "Let's do it in Delphi".

    If you were doing, GUI's there was PowerBuilder and VB. Again I heard a lot of engineers say "Let's do it in PowerBuider or VB."

    There were also Smalltalk (at least two commercial compilers ), Eiffel ( again at least two commercial compilers ), Dylan ( ditto ) and Self. Finally there was Ada which was mandated for all military applications without special dispensation.

    What's more Java at that time was more mature then Rust is now.
    So there were plenty of choices and the young engineers were always choosing them. Maybe if you had paid attention to the real world when you were a student.

  79. Re:Rust: It has great support to call into C code by Nubbywubwub · · Score: 1

    Every language under the sun has a foreign function interface for the purpose of calling into C libraries. Does the existence of an FFI from Python obviate the need for Python? Does JNI obviate the need for Java?