Slashdot Mirror


How Rust Can Replace C In Python Libraries (infoworld.com)

An anonymous reader quotes InfoWorld: Proponents of Rust, the language engineered by Mozilla to give developers both speed and memory safety, are stumping for the language as a long-term replacement for C and C++. But replacing software written in these languages can be a difficult, long-term project. One place where Rust could supplant C in the short term is in the traditionally C libraries used in other languages... [A] new spate of projects are making it easier to develop Rust libraries with convenient bindings to Python -- and to deploy Python packages that have Rust binaries.
The article specifically highlights these four new projects:
  • Rust-CPython - a set of bindings in Rust for the CPython runtime
  • PyO3 - a basic way to write Rust software with bindings to Python in both directions.
  • Snaek - lets developers create Rust libraries that are loaded dynamically into Python as needed, but don't rely on being linked statically against Python's runtime.
  • Cookiecutter PyPackage Rust Cross-Platform Publish - simplifies the process of bundling Rust binaries with a Python library.

38 of 304 comments (clear)

  1. But why? by Anonymous Coward · · Score: 4, Insightful

    Why use the new language of the month when C has been around for decades, is welll understood and does exactly what we want?

    How long before I start replacing rust with decay? 6 months? A year?

    1. Re:But why? by squiggleslash · · Score: 2, Interesting

      Because C is awful? It always was pretty bad but we used it because when you're trying to manually render a 16 color 2.5D image on a bitplaned VGA screen using a 6MHz 80286 then you pretty much have to forget array bounds checking, be willing to assume endianess, and have an easy way to translate integers into pointers.

      These days there's pretty much no reason to do any of this, which means that the only times you're going to do it is by accident. ie when you put a bug in your application.

      We need to ditch C.

      --
      You are not alone. This is not normal. None of this is normal.
    2. Re:But why? by dlleigh · · Score: 3, Insightful

      Portability. Think of C as a portable assembler.

    3. Re:But why? by slashdice · · Score: 3, Interesting

      I can (and sometimes do) compile C code that was written in the 80s or 90s. And it often works with little or no modifications. (And there are people running awk scripts from the 70s, calling me a whippersnapper). With something like rust or go or swift, your code will not compile in 6 months. (which is hilarious in the case of go because it's more 70s than Disco)

      --
      Copyright (c) 1990 - 2014 Dice. All rights reserved. Use of this comment is subject to certain Terms and Conditions.
    4. Re:But why? by gweihir · · Score: 4, Informative

      We actually need to ditch people that cannot handle C. Go be a "business coder" but stay away from real programs.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    5. Re:But why? by Anonymous Coward · · Score: 4, Interesting
    6. Re:But why? by geoskd · · Score: 4, Insightful

      These days there's pretty much no reason to do any of this, which means that the only times you're going to do it is by accident. ie when you put a bug in your application.

      That has to be the most ignorant thing in these comments so far, and there are some pretty stupid things in the comments above...

      Ignoring the performance of your software is just plain dumb. Web companies tend to get away with it, because they are not paying for the compute power directly, but it still annoys their users. If Google or Bing ignored the performance of the software needed to perform search, they would need vastly more hardware to keep up with demand. It is no accident that the backend of Google Search is written in C++, and that this all runs on a customized linux based OS.

      Do you have an HDMI TV? Have you noticed that it takes many 10's of seconds to turn on? That is because some dumb F^@# thought it would be a good idea to implement the interface in Java and it takes *forever* to start up. 50+ years ago, Kernigan and Ritchie came up with C because assembler was not portable. decades later, Stroustrup came up with C++, and there has not been a language since that can match the performance of either.

      When you are selling 50M of a product, and you want to put a processor that costs $0.50 more in it because you are too incompetent to write efficient code, your ass will be fired and replaced with someone who can do their job. In the mean time I hope I never have to use a product that has any of your "work" product in it.

      --
      I wish I had a good sig, but all the good ones are copyrighted
    7. Re:But why? by geoskd · · Score: 2, Interesting

      Let them use Rust. Switch them to C++ for the real work.

      Unfortunately, these interpreted languages tend to ruin programmers. Most (not all, but most) of the programmer I have met who were taught using a "modern" language like python, Go, Rust, Eiffel, etc... just don't amount to much. When they do eventually find they can no longer ignore the performance implications of their code, they are woefully unprepared to deal with C or C++. They consider the error messages cryptic and arcane, and they try their almighty best to use C and C++ the way they have used these other languages. The result is code that is slow bloated and buggy as hell.

      Programmers need to face the memory management demons early in their education. The longer they wait, the less comfortable they will be tackling pointers and all of their implications when the time comes.

      --
      I wish I had a good sig, but all the good ones are copyrighted
    8. Re:But why? by ArchieBunker · · Score: 3, Informative

      You're part of the problem we face today. Computers are order of magnitude faster than 20 years ago and yet software still never runs any faster. Web pages still render as quick today as they did in 1997. Software still has loading screens and even with an SSD we have to wait for the operating system to boot up and settle down.

      --
      Only the State obtains its revenue by coercion. - Murray Rothbard
    9. Re:But why? by hord · · Score: 2

      I'd never work for your "company". A real program:

      x) Abstracts work into reusable components
      x) Abstracts interfaces into functional, communicable units
      x) Doesn't care what languages it is written in

      Everything you mention I have done multiple times in multiple languages. Modulo the brain damage of library authors and language run-times they are all the same. They all have bugs in all the libraries you mention. And the weird thing is that most of them eventually rely on the C runtime like virtually every other piece of software. It's almost like every one wanted to be a C programmer but couldn't figure out pointers.

      Me? I write in C.

    10. Re:But why? by Anonymous Coward · · Score: 3, Insightful

      C was never awful, It is and has always been a wonderful language. It is true that it is designed for people who know how a computer works... That might be a bit much to ask from "modern" "coders". If you have zero knowledge of what a computer actually does I can understand that you see it as awful.

    11. Re:But why? by hord · · Score: 2

      You mean like Rust? Which compiles to LLVM? Which is written in C++? Which uses the C runtime?

      $ ldd /lib/libstdc++.so
              linux-vdso.so.1 (0x00007ffe1ad6f000)
              libm.so.6 => /usr/lib/libm.so.6 (0x00007fce35da5000)
              libc.so.6 => /usr/lib/libc.so.6 (0x00007fce359fd000) /usr/lib64/ld-linux-x86-64.so.2 (0x000055f372126000)
              libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007fce357e5000)

      But I've never used C so what do I know?

    12. Re:But why? by dog77 · · Score: 2

      Are you sure the tv was not slow because it was running Linux? I have seen a number of Linux based products running on embedded hardware, that take longer than 10 seconds to boot up. Maybe because they were not optimized, under powered, or special hardware bring up but I do see it happen. On the other hand, I don't think using Java or even something slower like python for the user interface would actually make much of a difference for the boot time.

    13. Re:But why? by LightningBolt! · · Score: 2

      > Completely impossible in C as C has nothing that resembles interfaces.

      There are a couple reasons you are incorrect on this.

      First, an "interface" has a few meanings in software development. It can simply mean the boundary between functions. A function declaration in a header file is an interface by this terminology.

      Second, function pointers in C allow the type of interface definition I assume you are referring to (as in Go or Java for instance). The actual function called can be selected at runtime using this mechanism, and with a "self" struct pointer as a parameter, you can have all the functionality of an interface in other languages. Look at how COM objects can be called from and implemented in C for a good example of this (https://www.codeproject.com/Articles/13601/COM-in-plain-C). It's not quite as natural in C as in other languages, but it is certainly done.

      --
      Old people fall. Young people spring. Rich people summer and winter.
    14. Re:But why? by buzmeg · · Score: 2

      Are you daft, ignorant, or am I *completely* missing something. Rust is compiled. And memory management with the borrow checker is front and center even *moreso* than C and C++.

    15. Re:But why? by DrXym · · Score: 2
      Rust is not an interpreted language. It compiles to machine code. In fact it compiles to machine code using the same compiler as clang - LLVM. And if you're worried about people learning memory management then you would appreciate the Rust compiler because you won't be compiling anything until you do.

      Performance wise, the code runs about the same as the equivalent in C.

    16. Re:But why? by gweihir · · Score: 2

      Indeed. An interface is a concept on architecture level, not on language level. You can implement interfaces in _any_ language. But all those wannabe "coders" think it is the language that provides the interface. Classical case of not understanding abstraction and why it is important. No surprise there is so much badly structured code out there.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  2. Fuck off with Rust spam by Anonymous Coward · · Score: 3, Informative

    And wake me up when Rust stop being a cult and becomes an actually useful language.

  3. The future of rustlang is tied up with Mozilla by mnooning · · Score: 5, Insightful

    I've read a third of the Rust nightly book and watched many, many Rust videos on youtube. I like Rust very much. However, I believe Rust was invented by, is sponsored by, and gets it's major funding from the Mozilla foundation. There is essentially no more Mozilla Thunderbird, and the Mozilla Firefox browser is getting significantly less usage. We've had articles on such here on Slashdot. If the Mozilla browser itself falters any more, would Mozilla, and hence rust, stay alive?

    1. Re:The future of rustlang is tied up with Mozilla by loonycyborg · · Score: 2

      I don't think that existence of Mozilla will be the deciding factor of the success of the language. For example, no particular corporation was supporting C++ initially, and even now core C++ design is done by volunteers. Even if Mozilla goes bankrupt a community can still thrive around the language if it deserves it. If not then it'll eventually wither in any case, even if Mozilla ends up thriving.

    2. Re:The future of rustlang is tied up with Mozilla by Cyberax · · Score: 2

      At this point, probably yes. There's a critical mass of Rust-based projects, enough to continue maintenance and development of new features.

    3. Re:The future of rustlang is tied up with Mozilla by jma05 · · Score: 4, Informative

      Python and Perl would have never made it, if people filtered by that logic.

      Programming languages don't need a huge company backing them up, as long as there is enough of a community. If Rust folks are as zealous as the Ruby folks were during the Rails era, we will have a neat C++ replacement.

      I have not used Rust yet and have even been critical (as in, just add those semantics to C++ somehow and don't create a whole new replacement) of it. But the community does seem to be building momentum.

      A peek at module counts
      http://www.modulecounts.com/
      shows that the Rust community is quite active. They are not merely evangelizing it, but rapidly building value. It does not look like Mozilla is significantly driving it on the module front. It only has half the modules as Go (which is impressive for a zero-cost abstraction language compared to a language that is high level application language), but the modules seem to be accumulating at more than twice the speed now. Modules make the language.

      I wish Nim had that kind of momentum though. That is a language better aligned for my purposes.

  4. What happens to Rust when Mozilla is gone? by Anonymous Coward · · Score: 3, Insightful

    Rust is very tied to Mozilla. And Mozilla's only remaining "successful" product is Firefox. But Firefox's market share is dropping. It was only a few percent, last I saw, while Chrome is over 50%. Mozilla reportedly gets a lot of funding from Yahoo, due to a Firefox search deal. So here we have an organization with one major product, but this project is being rejected by consumers, and what might be this organization's most significant source of revenue comes from this failing product and is paid for by another company that isn't doing so well. I fear for Mozilla's future if, say, the Yahoo deal wasn't renewed and they couldn't find a replacement.

    If Mozilla goes the way of the dodo bird, then I can't see the Rust project really going anywhere. I don't think it has a robust independent community like C++ has, for example.

    I think it is too risky to adopt Rust, especially for important long term projects. The tech industry moves fast. Rust could plausibly be gone in 3 years, while languages like C, C++ and even PHP are far more likely to be going strong.

    1. Re:What happens to Rust when Mozilla is gone? by gweihir · · Score: 2, Informative

      As C has been constantly in the top 3 languages that coder positions are offered for and C does not tie you to a SJW infected cult, this is not even a valid comparison. Rust is a hype-du-jour, with its proponents blind to its shortcomings. They are retards that still think coding is all about the language you do it in (which is about as far from the truth as you can get, and which has been known to smart people for something like half a century) and Rust is their chosen deity that can do no wrong.

      When Mozilla collapses, Rust will be gone as well. It really has not many things to recommend it, but some major shortcomings including the rabid and insane Rust community.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    2. Re:What happens to Rust when Mozilla is gone? by ShanghaiBill · · Score: 5, Funny

      As C has been constantly in the top 3 languages that coder positions are offered for

      But those "coder positions" are for white males only. C was designed in the 1960s, when colonialism was still rampant, and that is reflected in the language design. C ignores array bounds just as the imperial powers ignored the boundaries of tribal societies. Rust can free us from syntactic oppression, and provides "safe spaces" for everyone's data regardless of their culture or previous gender.

    3. Re: What happens to Rust when Mozilla is gone? by theweatherelectric · · Score: 2

      Is Firefox developed in Rust?

      It's just now starting to be. Mozilla's research browser, Servo, is written in Rust and they have started to integrate Servo components into Firefox. Components like Servo's WebRender significantly outperform other browsers.

  5. Because of the cool acronyms by goombah99 · · Score: 2

    For example Py-CRust.

    --
    Some drink at the fountain of knowledge. Others just gargle.
  6. Rust and SJW Nonsense by Anonymous Coward · · Score: 4, Insightful

    I was interested in learning Rust and perhaps using it for some personal projects, but then I discovered how the community seems to care so much about social engineering.

    We're not allowed to use "Master" and "Slave". https://github.com/rust-lang/rust-buildbot/issues/2

    We're required to rephrase old texts to fit into "gender non-binary" language. https://github.com/rust-lang/rust/pull/25640

    I'm sure they don't have problems "killing child processes" though...

    etc., etc.

    I'm not interested in using a programming language as some kind of social engineering experiment.

  7. Why does Rust's community lack diversity? by Anonymous Coward · · Score: 3, Interesting

    What I don't get is why the Rust community lacks diversity, despite them putting so much emphasis on supposedly supporting diversity.

    Years ago, back when I was a Java developer, I would sometimes go to Java conferences. There would be men there. There would be women there. There were probably transsexuals there. There would be old adults and young adults. There would be people representing every possible skin color. There would be somebody from pretty much every major ethnicity. There would be practitioners of pretty much every major religion. There was true diversity, without anyone actually trying to impose it through Codes of Conducts and Moderation Teams and "initiatives" and "affirmative action".

    Yet here we have Rust, with its invasive Code of Conduct, and the Rust Moderation Team to force it on the community, and all of its focus on "diversity" and "social justice". But when we look at the profile pictures of Rust's contributors, they appear to mostly be mid-20s white males (I'm assuming "steveklabnik" is a male).

    Now don't get me wrong, there's nothing wrong with being a mid-20s white male programmer. This isn't about singling anyone out, or about claiming that some mythical "privilege" exists, or anything like that.

    The issue here is that it appears that the more that the Rust community intentionally pushes for "diversity", the less of that we actually see. Instead of seeing a naturally diverse community form on its own, like pretty much every other programming language has, we've seen Rust's community become extremely homogeneous.

    It's as if the Rust community's efforts to force diversity on their community has actually had the complete opposite effect! While trying to create the most diverse community, they've actually only managed to create the least diverse one I've ever seen!

  8. By now the propaganda alone is reason to stay away by gweihir · · Score: 4, Interesting

    Something that gets this much hype cannot be good, or the hype would not be needed. Seems to me some cretins are using Rust as a religion-surrogate.

    --
    Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  9. Wake me up... by maestroX · · Score: 3, Insightful

    .. when Linus decides the next major release is to be written in Rust.
    Or for argument's sake, Mozilla itself.
    Every language has it pitfalls, at least with ye olde C/C++ I know where to look and what to expect.
    ...
    Suddenly you start to respect and embrace the get-off-my-lawn attitude, you simply want things to work rather than be written in the next greatest language of the moment.
    I think I'm ready to deal with my dad now :)

  10. Rust: an example of Autism-Driven Development? by Anonymous Coward · · Score: 4, Interesting

    I don't intend this to be taken as a joke in any way, nor do I intend it to be unnecessarily mean, but I think that the Rust community inadvertently discovered a new paradigm of software development: Autism-Driven Development.

    When we look at what they've created, both from a technological standpoint and from a community standpoint, I can't help but notice the impact that Asperger Syndrome may have had on how things have developed.

    Let's start with the community. While the communities of languages like Perl, C++, Python, Java and C# developed organically over time, it is almost as if the Rust community has been manufactured instead. It's like the community's interactions have been scripted, to use a programming analogy. It seems to me that the Rust Code of Conduct may actually be there as a way to allow people who suffer from varying degrees of social ineptitude to interact in a way that mimics how they see other, naturally-formed programming language communities made of sociable individuals interacting. They wouldn't be able to manage this social interaction on their own. But if you give them a script or a checklist they can follow, they can at least engage in something that appears, on the surface, to be socializing. That's why I think their incorporation of social justice is quite interesting. In many ways the concepts of social justice are all about imposing a foreign order on what is naturally a very chaotic and perhaps unfair reality.

    The language and its standard library also reflect behavior that may be expected from those suffering from Asperger Syndrome. While creating the language, it is as if its developers haven't been able to make the normal trade-offs that other language developers have made with ease. We've seen this result in Rust, as a language, constantly change over time. It's like they're striving for some unattainable form of perfection that most normal people would realize could not be attained. While other people would accept some drawbacks to their creation and move on, the Rust community appears to waver back and forth, unable to really make up its mind about how to proceed. Even the supposedly stable Rust 1.x release branch has seen 19 minor releases!

    I think the complexity of the language also reflects the role that, I suspect, Asperger Syndrome has had on the development of Rust. It has become an immensely complex and convoluted language, even compared to a rather complex language like C++. It's like the language has been designed, perhaps unintentionally, to be cryptic and unwelcoming to normal people. By its very nature it is like it is trying to be self-isolating, to avoid having to interact with the world and the people around it. Programming languages like Java, Python, C++, Perl and PHP want to be used by normal people. Those languages evolved in ways that draw in new users. But Rust? It has evolved to become very difficult and awkward to use, especially for new, average users.

    From what I can see, the entire Rust ecosystem exhibits the traits that have come to be associated with Asperger Syndrome, or autism in general. Rust has a certain natural awkwardness to it; a inherent difference from every other programming language and programming language community that exists. It's like it wants to fit in, yet no matter how hard it tries it just can't. It's like, in my opinion, the entire Rust ecosystem lacks a natural understanding or ease of existence that other programming language ecosystems develop naturally.

    I am just speculating here, as I do not know any of the Rust developers on any personal level, but could it be that mild/moderate autism or some degree of Asperger Syndrome has influenced how the Rust programming language has developed? If the developers of a programming language exhibit autism or Asperger Syndrome, could they in turn pass this on, so to speak, to a programming language and a related community that they have created? Could Rust be an example of, for lack of a better term, Autism-Driven Development?

  11. Rust fans remiond me of Rush fans... by VAXcat · · Score: 3, Insightful

    They're really enthusiastic, mention that they think it's great at every opportunity, and can't understand when someone is underwhelmed by the object of their admiration....

    --
    There is no God, and Dirac is his prophet.
  12. GTFO Rust by FutureDomain · · Score: 2

    Rust can go and, well, rust. If you want to get safer C, than add Cyclone support to gcc and use that. No rewrites, no learning a new language, no hitching your project to a SJW converged organization that is slowly dying, no fanboys who pathetically spam puff pieces on Slashdot... Seriously, Cyclone or any of the other safe-C alternatives are better and less intrusive than a Rust rewrite.

    --
    Hydraulic pizza oven!! Guided missile! Herring sandwich! Styrofoam! Jayne Mansfield! Aluminum siding! Borax!
  13. Julia! by Anonymous Coward · · Score: 2, Interesting

    I make money doing embedded C. If I am going to replace C with something else it will be Julia. I get the speed of C, the coding efficiency of Python and real support for computational algorithms.

  14. Re:Give up by serviscope_minor · · Score: 2

    When people whine about how the stories aren't techy enough, thye get modded up. But apparently people who whine when stories realy are only for nerds (along with some gratuitous homophobic slurs) also get modded up.

    Seems like some people will never be happy.

    --
    SJW n. One who posts facts.
  15. Re:I'll never use anything from Mozilla. by angel'o'sphere · · Score: 2

    Since 5 years or so Firefox is autoupdating (you can not disable it) and causing problems over problems (failed updates etc. or UI changes). Why Mozzial.org thinks removing the menu bar and having a "hamburger menu" instead is a good thing is beyond me. Most people tried to revert but could not, then they deleted FF and went to other browsers.

    None of my friends is using FF anymore. I only use it when a software project demands FF compatibility and we have to use it for tests. Or for fancy GreeseMonkey scripts.

    I think I have no FF anymore n my Mac since 7 or 8 years ... and as long as they don't revert to a sane browser with a menu bar and no automatic forced update I won't try it again.

    --
    Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  16. This is What Happens When Developers Make Business by brian.stinar · · Score: 3, Informative

    This is what happens when developers make business decisions. Seriously, why is Mozilla focused on promoting/using/developing Rust, when they could be focused on making their browser suck less? Probably because they have no business concerns, at all, about making a viable product (or company.) I spent two weeks exclusively using Firefox, right when Google was found to be recording everything I said, in the event I happened to say "OK Google" without a way to turn this off. After two weeks, I realized I'd rather be bugged than use Firefox any longer.

    This is exactly what Joel Spolsky wrote about, when Netscape did a complete rewrite here, or in his awesome book Joel on Software . Netscape focused on a rewrite, instead of making their browser suck less.

    It sounds like Netscape made this mistake and then became Firefox. Now, it seems like Firefox is making the exact same mistake. This has to be the funniest business case study ever.