14 ms·
Exploring Rust (from C#)
- FranOntanaya 11y agoHug of death. Cache https://webcache.googleusercontent.com/search?q=cache:EDeYMvVfqygJ:nblumhardt.com/2016/03/exploring-rust/ https://webcache.googleusercontent.com/search?q=cache:EDeYMv...
- nblumhardt 11y agoThank you - was a bit of an unexpected appearance here so getting onto the erm, technical issues, now...
- h43k3r 11y agoA quick solution could be to host the page as a static page and have a nginx route serve that page.
- nblumhardt 11y agoThanks - kicked off a resize, that may not have been the best idea. That'll teach me for hanging on to mainframe-era blogging technology :-)
- kibwen 11y agoMainframe-era blog tech, eh? http://www.coboloncogs.org/INDEX.HTM http://www.coboloncogs.org/INDEX.HTM
- nblumhardt 11y agoI needed that laugh! And some good news, serving a static copy from the original domain/URL, so all might not be lost :-)
- protomyth 11y agoIt's funny until you run into a group of people actually using COBOL to run their website.
- gedrap 11y agoHTML caching at nginx level would do the trick as well, assuming you have enough bandwidth.
- h43k3r 11y agoThis is offtopic but what should be size of the VM to handle HN's front page traffic. I know a lot of it depends upon whether the website is static or is backed by DB and on various different factors. But many a times some of my friends ask me questions like this. To make it simple, lets take 2 very basic websites. 1. A ghost blog. (node.js) 2. A wordpress blog backed by a mysql db. (php)
- mseri 11y agoI had a ghost blog on a micro instance of a german VPN, a machine with 256mb of ram and not too fast processing power. Both times I reached HN home page, in one case for some hours, it worked without issues and only a minor slowdown.
- mseri 11y agoVPN was meant to be VPS but I cannot edit the post
- qz_ 11y agoCould someone explain why Rust is so damn popular/controversial?
- jinst8gmi 11y agoIt guarantees memory safety without a GC. The result is a high performance language that doesn't require manual memory management like C or C++, and generally consumes less memory, as noted by the Dropbox guys. It's an expressive language which is also suitable for systems programming. It's a more modern language than Go (in the sense that is incorporates modern features, unlike Go which keeps things simple by sticking to familiar features dating back to the 70's), but does require more time to learn.
- echelon 11y agoRust is also an absolute pleasure to write. It feels like a functional Ruby (minus the bad parts) with types. The RAII is natural; writing C++ feels cludgy by comparison. Cargo is absolutely brilliant, too. It's better than NPM. I'm writing most of my new side projects in Rust now, FWIW.
- skoczymroczny 11y agoI think a lot of people are looking for a replacement for C++ that isn't C#/Java. As in a language that is still low-level enough to offer stuff like pointers, but without the pitfalls and minefield which is C++ (a lot of which is due to historic reasons and backwards compatibility with C). Some newer languages that try to fill the niche are D, Nim, Rust and Go. Can't say much about Nim, it seems to be in the background. Go started as a systems programming language, but since then they backed out on it and it's mostly pushed as nicer C and webservice language. That leaves D and Rust on the field. Both are competing for the same audience, but Rust has the advantage of a popular brand backing (Mozilla) and a potential killer app (Servo, Mozilla's new work in progress browser engine). It also seems to have a clearer vision because of Mozilla backing and constant dogfooding in Servo. Meanwhile D is more of a design by community, as a result it gets not always the features that are needed or people want, but the features people are willing to work on. Also, D gets a lot of backlash from the game dev and system programming languages communities for using a (not too great) garbage collector, whereas Rust uses memory management somewhat similar to C++ model with RAII/smart pointers, however greatly improved and with much stronger static checks. I think people just view Rust as the language that could actually be the alternative to C++, because there is a place for a language that is safer to use than C++, yet performs at similar speeds and doesn't handhold you like C#/Java do.
- jld89 11y agoError establishing a database connection...
- kibwen 11y agoI like the author's attempt to explain Rust's borrow checker to a new audience by inventing a variant of C#. Lifetimes are certainly one of Rust's most unique features, and the existence of analogies to express unfamiliar concepts in terms of familiar ones is very valuable.
- gravypod 11y agoWhat I like about the concept is that as soon as you explain it, the first response you see is "Wait, that doesn't already happen in other languages?" The idea just makes sense, it's "right".
- taspeotis 11y agoThe annotated version of C# included in the blog post reminds me of Spec# http://research.microsoft.com/en-us/projects/specsharp/ http://research.microsoft.com/en-us/projects/specsharp/ Spec# has annotations and methods for object ownership. You can see an example of it in the "The Spec# Programming System: An Overview" slideshow (slide 39 onwards). Also: > C# has two families of data structures that dermine allocation behaviour: structs and classes. If a type is a struct then values of that type will be allocated on the stack: Here's a primer on how the Microsoft CLR handles it, because it's more subtle than what's stated above. The end effect is that value types behave like values, reference types behave like references. Where they're stored is a function of where they need to be stored, not their type. https://blogs.msdn.microsoft.com/ericlippert/2010/09/30/the-truth-about-value-types/ https://blogs.msdn.microsoft.com/ericlippert/2010/09/30/the-...
- nblumhardt 11y agoAh yes, my bad - the "value types go on the stack" simplification is a bit sloppy. It's a useful way to describe it to make the comparison - but definitely not for understanding C# in this case.
- taspeotis 11y agoAll good. Also, thanks for alt-composition and stateless.
- forrestthewoods 11y agoThat was a great blog post. Thanks for sharing.
- maxxxxx 11y agoDoes anybody know how good the Rust integration with Windows is? The language looks very good but can you interop with Win32, COM and .NET? Is there a debugger? Without those its usability is a little limited.
- kazagistar 11y agoHaven't used any yet, but there are number of libraries. Generated winapi bindings: https://retep998.github.io/doc/winapi/ https://retep998.github.io/doc/winapi/ A COM library, including a macro for generating a COM interface: http://eljay.github.io/com-rs/com_rs/index.html http://eljay.github.io/com-rs/com_rs/index.html Not exactly sure about .Net, but here is a tutorial for how to use a rust library from C#: http://www.loekvandenouweland.com/content/using-rust-code-from-csharp http://www.loekvandenouweland.com/content/using-rust-code-fr...
- agentgt 11y agoHopefully this is relevant but one of the things I had difficulty with in Rust is closures (or more specifically the lifetime and pointers of closures) and wiring up a system or library that needs lots of callback things. See I'm used to Java where anonymous classes are closures (I really like that about Java/Scala/Groovy. One of the very few things I don't like about C# is that does not have anonymous classes). So the problem is when I want a callbacky thing that has state it gets fairly complicated in Rust because you have lots of options that have limitations. For example there is bare functions or raw functions which basically stateless, there is traits but you'll need to use boxes and or cells, and then there is Rust closures which I had some various issues with because of bugs (they are probably fixed now). I only bring this up because instead of so many tutorials on simple static programming stuff I would like to see how one might wire up a system with many callback components (ie manual dependency injection). I suppose I should look at how its done in Iron. ie if your going to show something analogous to a Java/C# developer show them some wiring up of a complicated system that has interfaces and the components can be interchanged (perhaps that is just something you don't do in Rust but I'm curious how it would be done).
- pbz 11y ago> One of the very few things I don't like about C# is that does not have anonymous classes Anonymous classes are lambdas in C#. http://programmers.stackexchange.com/questions/195081/is-a-lambda-expression-something-more-than-an-anonymous-inner-class-with-a-singl http://programmers.stackexchange.com/questions/195081/is-a-l...
- agentgt 11y agoNot all anonymous classes are lambdas. There are many situations like async streams or even synchronous iterators that require multiple methods. Erik Meijer even mentions somewhere in this video that he is remiss that C# doesn't have anonymous classes: https://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2014/Keynote-Duality https://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2014/Ke... Around 47:50 he says "feature request for C# anonymous inner classes".
- vorg 11y ago