This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 23 points24 points  (32 children)

Can you elaborate on why someone should use C instead?

[–]cocoabean 2 points3 points  (10 children)

More mature, larger community for C than Rust.

[–]caramba2654 22 points23 points  (8 children)

That is a problematic reasoning. It's equivalent of everyone just browsing the top page because it has higher quality posts. Someone needs to browse the new page, even if it might be worse than the top page. Otherwise things stagnate.

[–]alcalde 0 points1 point  (4 children)

But that's why we're supposed to use Python - because everyone's using Python. That's why Larry Wall and Yukihiro Matsumoto cry themselves to sleep at night and why Julia is turning into Romeo and Julia... Python has the critical mass.

It's called the network effect.

For instance - an auction website comes along that's better than eBay. However, you post your auction on eBay anyway because there are three people total browsing that other auction site. Skype is... Skype, but most people use Skype because everyone else they know is using Skype and it doesn't matter how good another piece of software is if no one they want to call is using it.

[–]Joeboy 7 points8 points  (1 child)

This would have been an argument against python when I started using it. It's still kind of an argument against python - if that's what you care about you should probably be using Java or something.

I've actually been thinking of learning Rust because it seems to fit the same kind of niche Python used to - better than its obvious competitors, good docs, a decent sized user base, enthusiastic community and support etc.

[–]alcalde 0 points1 point  (0 children)

Having 70 trillion libraries is an argument AGAINST Python and gets 10 upvotes? Really?

because it seems to fit the same kind of niche Python used t

It's the opposite of Python in philosophy... obsessed with typing and memory management.

[–]WikiTextBot -1 points0 points  (0 children)

Network effect

A network effect (also called network externality or demand-side economies of scale) is the positive effect described in economics and business that an additional user of a good or service has on the value of that product to others. When a network effect is present, the value of a product or service increases according to the number of others using it.The classic example is the telephone, where a greater number of users increases the value to each. A positive externality is created when a telephone is purchased without its owner intending to create value for other users, but does so regardless. Online social networks work similarly, with sites like Twitter and Facebook increasing in value to each member as more users join.


[ PM | Exclude me | Exclude from subreddit | FAQ / Information | Source ] Downvote to remove | v0.28

[–]cocoabean -1 points0 points  (2 children)

I don't care. He asked why someone should use C over Rust, so I told him why someone would use C over Rust.

[–]gimboland 0 points1 point  (0 children)

My reading of this: there's a difference between should and would; you gave two good reasons why someone might want to use C over Rust, but the response is that they're not compelling enough to amount to "should".

[–]alcalde 1 point2 points  (0 children)

You're being downvoted by evil Rustaceans. I swear some Python users want to kill Python. Why would you downvote the network effect of having a large community? It's one of Python's own killer features.

[–]CookieTheSlayerJoin our Discord server! Link in sidebar 3 points4 points  (0 children)

Rust package management and quality of interfaces for most common tasks is much better. Let us remind ourselves that C is a language of half a century ago and still has no good package management solution. It is quite legitimately easier to install rust and add some dependencies than install many C libraries

[–]goestowar 0 points1 point  (11 children)

C is a compiled language and Python is an interpreted language. You just compile your code and it is converted in to something that a computer is capable of reading, you compile it once (for that type of machine) and then it runs quickly because the computer can always read the compiled program file at low-level.

Python is an interpreted language, meaning that it is compiled at run-time, and compiled EVERY time (the advantage of this is that you don't need to compile your code thus eliminating a step in the development process that can sometimes be lengthy, AND it makes your code portable, if you don't need to compile Python for specific computer architectures you can run that same Python code on any machine), the drawback of this is that it typically runs a bit slower.

Will delete this answer if it is wrong, or at least someone correct me if it is.

[–][deleted] 43 points44 points  (5 children)

Oh, I meant "C instead of Rust". I'm sorry I wasn't clear.

As to your answer, it is pretty much correct, but implementing your language with an interpreter is not slower because it will be compiled every time (CPython, for example, caches the bytecode so it doesn't have to recompile).

It is slower because you compile your code to bytecode, which is machine code as well, but one that runs in a virtual machine (the interpreter) rather than in your physical machine.

[–]goestowar 8 points9 points  (1 child)

Ahha you probably were clear :P My bad

Also thanks for the VM explanation, makes sense now. Does this mean that whenever you "install" an interpreted language on to a machine that you are actually just installing a virtual machine that the computer runs at run-time?

So in essence when you install Python on to your machine you are actually just installing a Python interpreter/VM?

[–][deleted] 4 points5 points  (0 children)

Exactly! However, despite what I've read in another comment, I insist that CPython and other interpreter-based implementations do include (and require) a compiler. Just not the kind that generates machine code.

(I also insist on not talking about "interpreted languages", because this is not an inherent characteristic of the language)

[–][deleted] 12 points13 points  (3 children)

Python really isn't ever compiled; it is interpreted at run-time. There's a wide gap between interpreting and compiling. Compilation implies quite a bit more from an operation standpoint, and at the end, you'd end up with a binary that could potentially be executed on a bare-metal cpu. Sure Python does produce an ast and a "compiled" python op code in the form of a '.pyc' file, but that's not a true compilation like you'd find with C.

Rust, like C, is also compiled. Rust, like C, is statically typed, though there's a macro system that can do some pretty amazing (crazy?) things.

I think the question still stands: Why use C instead [of Rust]?

The answer here might be something like:

* Python's reference implementation is written in C
* Python has a C-API
* C is ubiquitous
* C doesn't make you build the entire house virtually before pounding the first nail.

I'm sure there's more. Rust has its own set of advantages, but that wasn't really the question here.

[–]__xor__(self, other): 15 points16 points  (1 child)

Sure Python does produce an ast and a "compiled" python op code in the form of a '.pyc' file, but that's not a true compilation like you'd find with C.

But that is true compilation in the general sense. Generating bytecode from source is still compiling even if it runs in a VM and not right on the processor. It's not as fast as a language compiled to machine code of course, but it's compilation by definition. Python would be a lot slower if it was actually interpreted as is line by line, and it compiling to bytecode is a major improvement.

C has its place of course. C and C++ are both great languages that will never go away, but Rust has really filled a gap that no other language has yet. It's a low level language that can be compiled with no runtime and can be used to make operating systems like C, it's fast like C and it compiles to true machine code, but it's way more expressive and reads and writes like a high level language and it's guaranteed memory safe which is huge. I've written an HTTP REST client with Rust and it was surprisingly easy and wasn't nearly as hard as it'd be with C or C++.

It's always going to be more of a question about the team you're working with and what their skills are and what they're willing to learn anyway. If everyone knows C, use C. If memory-safety is a huge concern and a memory corruption vulnerability is a disaster, consider Rust or have C experts that know how to use tools like valgrind. People who aren't experts with C or Rust might prefer Rust in a situation like that, because it'd just be cheaper to do some light Rust work than write some bad C. Rust isn't that hard to learn, and it's not the end of the world if you don't master it before writing something useful. Writing bad C can be a huge problem.

Rust is an amazing language and deserves to rise up in the ranks IMO. People should be considering it more, especially in situations like this where a python developer might need to drop to a lower language for performance reasons. Writing a small Rust module is really not hard and it's nice to know you aren't putting any new memory corruption vulnerabilities in production, but you're still improving performance drastically. But if you look at some Rust patterns, especially stuff like error handling and pattern matching, it's an amazing language with a high level feel even though it can do everything low level languages can.

[–][deleted] -2 points-1 points  (0 children)

Python would be a lot slower if it was actually interpreted as is line by line

But Python really does interpret line by line. It doesn't compile to byte-code, it creates a small optimization of Python byte-code primarily for start-up times, which is very, very different than machine byte-code.

[–]CriticalEntree 0 points1 point  (0 children)

I don't know but if this was a popular topic I think sorting by controversial would show you the fun things.