Live data from Hacker News

How Rust Is Tilde’s Competitive Advantage [pdf]

rust-lang.org

121–127 of 127 posts

Re: How Rust Is Tilde’s Competitive Advantage [pdf]

#121
post #45
post #29

> Rust is much easier to teach than C or C++, Not sure about that. If you know C, which is easy to learn, you already know a lot about C++, or at least the parts that are used most of the time. Learning about the borrow checker, match enums don't seem very easy at first, although they surely seem elegant and much safer.

C appears easy to learn. C++ a bit harder, but learnable. What isn't easy to learn is all the horrible ways C is broken. Don't return addresses to local variables. Remember realloc can change the location pointer. Don't use the C string functions. C++ adds fun gotchas like using the c_str() of a temporary string object. Carelessly passing local objects by reference to a lambda thread function. All of the amusingly ho…

C is just some readable assembly. If you tell a computer to crash into a wall, it will crash into a wall. That is the best lesson you can teach a student.

It is great to have a language that teaches you to write better code. Failure is a good teacher too.

If you tell a student to follow some rules without telling him why those rules exist, it is not always a good idea.

It is an awesome idea to have the safest code, but not necessarily a good idea to teach programming using safety rules.

Re: How Rust Is Tilde’s Competitive Advantage [pdf]

#122
post #118
post #115

Earlier quoted context omitted.

No, continuations can be controlled similarly through effect polymorphism, which is what I was trying to describe. The difference is not that continuations allow anything at all, but that your effects are commutative rather than layered like a monad transformer stack.

> continuations can be controlled similarly through effect polymorphism, which is what I was trying to describe. Fair enough, but you're effectively talking about a secondary, novel type system, right? One of the things I like about monads is that they can be just plain old values of plain old datatypes. > The difference is not that continuations allow anything at all, but that your effects are commutative rather tha…

> you're effectively talking about a secondary, novel type system, right?

Yes, exactly.

The main reason I prefer language-level effects rather than monads is for composability with normal imperative control flow. Monads are written in terms of higher order functions passing closures around, and that gets really messy in a language where you not only have early return and loops with break and continue, but you also have destructors that need to run as you enter and leave scopes.

You can add that kind of stuff as monads but it gets really messy, and is basically completely untenable in a language like Rust that also cares about memory management. Even if Rust did have HKT, it would still be impossible to write a Monad trait that supports them all, for example.

This article makes some great points on the subject: http://blog.paralleluniverse.co/2015/08/07/scoped-continuati...

Re: How Rust Is Tilde’s Competitive Advantage [pdf]

#123
post #121
post #45

Earlier quoted context omitted.

C appears easy to learn. C++ a bit harder, but learnable. What isn't easy to learn is all the horrible ways C is broken. Don't return addresses to local variables. Remember realloc can change the location pointer. Don't use the C string functions. C++ adds fun gotchas like using the c_str() of a temporary string object. Carelessly passing local objects by reference to a lambda thread function. All of the amusingly ho…

C is just some readable assembly. If you tell a computer to crash into a wall, it will crash into a wall. That is the best lesson you can teach a student. It is great to have a language that teaches you to write better code. Failure is a good teacher too. If you tell a student to follow some rules without telling him why those rules exist, it is not always a good idea. It is an awesome idea to have the safest code, b…

> C is just some readable assembly.

Here's one article that argues the other side. I like this part a lot, though the wording is a maybe a little bit argumentative :)

"Be knowledgeable about what’s actually in the C and C++ standards since these are what compiler writers are going by. Avoid repeating tired maxims like “C is a portable assembly language” and “trust the programmer.” Unfortunately, C and C++ are mostly taught the old way, as if programming in them isn’t like walking in a minefield. Nor have the books about C and C++ caught up with the current reality. These things must change."

https://blog.regehr.org/archives/1520

Re: How Rust Is Tilde’s Competitive Advantage [pdf]

#124
post #121

Earlier quoted context omitted.

C is just some readable assembly. If you tell a computer to crash into a wall, it will crash into a wall. That is the best lesson you can teach a student. It is great to have a language that teaches you to write better code. Failure is a good teacher too. If you tell a student to follow some rules without telling him why those rules exist, it is not always a good idea. It is an awesome idea to have the safest code, b…

> C is just some readable assembly. Here's one article that argues the other side. I like this part a lot, though the wording is a maybe a little bit argumentative :) "Be knowledgeable about what’s actually in the C and C++ standards since these are what compiler writers are going by. Avoid repeating tired maxims like “C is a portable assembly language” and “trust the programmer.” Unfortunately, C and C++ are mostly…

I said it's readable, but it's just some simple translation. C still has all the issues of having to write assembly, so a C programmer should have to check if its C code is not doing anything unsafe, like an ASM developer would.

Programming is not easy, and it always has been a minefield. You cannot write good code quickly. Even learning rust will have a cost, although it's a worthy cost. Writing unsafe code is cheap and was often a good enough solution.

Re: How Rust Is Tilde’s Competitive Advantage [pdf]

#125
post #109

Earlier quoted context omitted.

Really? You can write FUBAR code in any language, language has nothing to do with this.

Of course you can. But if the same developers write performant code in one language, and something really slow in another, that's a mark against the second language. Maybe there's a tradeoff - maybe the slow codebase was written much faster, or something like that. But the kind of code a language makes you write is totally something you should judge it on.

Well i am quite experienced with Java and in my experience if they have this kind of ridiculous discrepancy in memory use, it implies they had a bad design or made bad choices. A rewrite in Java with sane choices would also end up with much better results. So I don't buy the "language is responsible" argument.

Re: How Rust Is Tilde’s Competitive Advantage [pdf]

#126
post #124

Earlier quoted context omitted.

> C is just some readable assembly. Here's one article that argues the other side. I like this part a lot, though the wording is a maybe a little bit argumentative :) "Be knowledgeable about what’s actually in the C and C++ standards since these are what compiler writers are going by. Avoid repeating tired maxims like “C is a portable assembly language” and “trust the programmer.” Unfortunately, C and C++ are mostly…

I said it's readable, but it's just some simple translation. C still has all the issues of having to write assembly, so a C programmer should have to check if its C code is not doing anything unsafe, like an ASM developer would. Programming is not easy, and it always has been a minefield. You cannot write good code quickly. Even learning rust will have a cost, although it's a worthy cost. Writing unsafe code is cheap…

> it's just some simple translation

I think this is the part that the article is arguing against. For sure, I agree that many of the common problems we run into with C code (out-of-bounds reads, uses-after-free, etc.) are the result of the compiler doing "exactly what you told it to do." But there are also new problems that come up as a result of aggressive C compiler optimizations, which are _not_ what would happen in a simple translation:

- Strict aliasing violations. If two pointers point to different types, the compiler is allowed to assume that the memory they point to doesn't overlap. It can reorder a write and a read based on this rule, even when they should be causally related within a single thread.

- Non-obvious undefined behavior. For example, https://www.imperialviolet.org/2016/06/26/nonnull.html. The C standard says that passing a null pointer to memcpy is undefined, even if the size argument is zero. If you pass a pointer to memcpy (assuming a size of zero would make that a no-op) and then check it for null, the compiler will completely skip that check.

These are cases where modern compilers do something very different from what a human assembly programmer would intuitively do. It's not the majority of code in any program that has to worry about this, but I think the majority of programs do have to worry about this somewhere.

Re: How Rust Is Tilde’s Competitive Advantage [pdf]

#127
post #90

Earlier quoted context omitted.

Having used both, I'd be pretty shocked if anyone found Twisted to be easier to reason about or less prone to bugs than Go...

Twisted predates async/await syntax in Python.

Isn't gevent still better than async/await ? (if it had core support it would be, kinda like golang)
Post reply on HN