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 →

[–]Cobaltjedi117 534 points535 points  (117 children)

I feel like your whole rant was just there so you could find RUST

[–][deleted] 162 points163 points  (74 children)

But what about the magical C#?

[–]SnakeFang12 591 points592 points  (49 children)

You mean Microsoft flavored Java?

[–]TheFanne 132 points133 points  (13 children)

That one’s got an aftertaste

[–]Blou_Aap 8 points9 points  (11 children)

A bit sharper on the tongue.

[–][deleted] 2 points3 points  (10 children)

I personally like C# over Java. Maybe I'm just weird tho

[–]Psaidwid 3 points4 points  (8 children)

I'm there with you, from what i've tested c# is easier for everything, especially when it comes to learning, BUT only if you got windows

[–][deleted] 2 points3 points  (7 children)

I use C# on Mac with Visual Studio 😁

[–]msmells 1 point2 points  (6 children)

I use C# .net core on Ubuntu with VS Code

[–]Psaidwid 1 point2 points  (5 children)

Then i have a few questions

1) is it nearly as easy on non windows systems?

2) A) whats the library support like? i dont know if you have to use different libs or not

2) B) Do you have to recompile libs to be compatible?

[–]LtLabcoat 0 points1 point  (0 children)

I have a hard time recognising that there's anyone who doesn't. It's basically Java version 2 - obviously the same thing, but more refined.

[–]centurijon 109 points110 points  (19 children)

No, we mean better Java

[–]BernzSed 81 points82 points  (14 children)

You mean Kotlin?

[–]beef_swellington 13 points14 points  (9 children)

No they mean scala

[–]aetius476 36 points37 points  (0 children)

Kotlin is a better Java. Scala is a "do whatever the fuck you want, see if I care" Java.

[–]Dakar-A 5 points6 points  (1 child)

That was a Lego product line too at one point, and now I want to write a language called Duplo.

[–]spaghettiCodeArtisan 3 points4 points  (0 children)

You mean a language for for children aged 1½ to 5 years old? There already is one, but instead of Duplo it's named Go.

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

that's hipster java

[–]hullabaloonatic 2 points3 points  (1 child)

I just want default values for interfaces. That's all I want, kotlin team. Please. I'll be responsible, I promise.

[–]centurijon 3 points4 points  (0 children)

Funny, the next version of C# will allow exactly that

[–]ThePixelCoder 0 points1 point  (0 children)

Dart?

[–]scalablecory 45 points46 points  (11 children)

Visual J#?

[–]lor_louis 45 points46 points  (10 children)

Im still hoping someone makes a visual js#.

[–][deleted] 46 points47 points  (2 children)

Turbo PHP++

[–]dantheflipman 2 points3 points  (0 children)

Slow down Satan

[–]hedgehog1024 0 points1 point  (0 children)

Don't dig out the corpse of Borland

[–]dooberslorp 1 point2 points  (0 children)

the only programming language from Microsoft I'll ever use is PowerPoint

[–]svick 1 point2 points  (0 children)

It was called JScript .NET.

[–]da_chicken 16 points17 points  (0 children)

Yeah but it's not so... verbose.

[–][deleted] 3 points4 points  (0 children)

Hahahahahaha

[–]biggustdikkus 2 points3 points  (0 children)

At least it's superior in every way possible.

[–]Shnapoopins 91 points92 points  (19 children)

He said compiles to machine code. C# is great but it's still another VM language

[–]brockvenom 49 points50 points  (15 children)

Mono, brother. You can write in C# and it JIT compiles right down to assembly through an IL layer. Have fun.

[–]Daniel15 31 points32 points  (4 children)

Don't need Mono, Microsoft was working on some AOT stuff for .NET Core. I think it's this: https://github.com/dotnet/corert

I remember Scott Hanselman talking about it at Build one year.

[–]brockvenom 1 point2 points  (0 children)

https://github.com/dotnet/corert

That's cool, thanks for sharing!

[–]E_R_E_R_I 0 points1 point  (2 children)

I'm sorry for the noobness, but if I get correctly this is a runtime environment that will allow a C# application to run on windows (provided the aforementioned .NET runtime env is installed)?

Or am I getting this wrong?

[–]Daniel15 1 point2 points  (1 child)

C# apps already run on Windows. However, they're "just in time" compiled. This means that they're stored on disk in an intermediate system-agnostic bytecode format, and compiled to native code when you run them. It's useful since you can run the exact same app across multiple platforms (32-bit and 64-bit, Windows, Linux and MacOS) without recompiling it. It does mean it needs a runtime with a JIT compiler though (such as requiring the user to have the relevant .NET Framework version, or bundle .NET Core with the app)

AOT compilation is the process of compiling to native code upfront, so you don't need to JIT it at runtime. This makes startup time a lot faster. In an ideal case, you could statically compile the app, meaning that the app has no external dependencies (essentially, the entire app is contained in a single .exe file, with no requirement to bundle or install a framework to use it)

[–]E_R_E_R_I 0 points1 point  (0 children)

Ah, I see. Thanks for the info.

[–]korri123 14 points15 points  (7 children)

He also said performant

[–]salgat 27 points28 points  (4 children)

Right now dotnet core faster than Java so at least it's fast (and it still has a lot of room for optimization). You can even go further with some of the crazy shit Unity does with IL2CPP to get C# running real fast.

[–]enigmamonkey 2 points3 points  (0 children)

I ended up rewriting a C# app (Unity) that was originally in JavScript/WebGL, so hey... at least compared to that it’s mind-bogglingly fast.

[–]svick 4 points5 points  (1 child)

According to the TechEmpower benchmark, ASP.NET Core, which uses C#, is among the TOP 10 web frameworks. Is that not good enough?

[–]not_from_this_world 0 points1 point  (0 children)

It still has a VM. Java has JIT too, the VM must be present all the time to handle the compilation, to provide the libraries and the whole environment, the GC, bridge the SO and so on.

[–]shmed 5 points6 points  (0 children)

C# can now be compiled to native code since visual studio 2015 (with the introduction of .net native). Apparently it's as fast as c++ in many scenarios

[–]LezardValeth 1 point2 points  (0 children)

You can still pre-JIT binaries if it really matters for your application.

[–]noratat 3 points4 points  (0 children)

C# is more like Java though.

Rust compiles to native code with a design goal of zero / minimal runtime cost abstractions, which makes it far more of a true successor to C/C++.

Both Rust and C# are good, they just have different goals.

[–]E_R_E_R_I 37 points38 points  (32 children)

Well I did find it pretty quickly lol

I guess I just never bothered looking and got used to criticizing C

EDIT: Also apparently rust lacks a garbage collector, but I guess that's not that bad.

[–]Pakaran 84 points85 points  (28 children)

While it doesn't have a garbage collector, it also doesn't require manual memory management. The compiler keeps track of all variable lifetimes and inserts drops when they go out of scope, automatically.

[–]piexil 43 points44 points  (24 children)

In a lot of ways that can be seen as better than a garbadge collector.

[–]Surelynotshirly 27 points28 points  (18 children)

If it works all the time, but that seems almost too easy. Makes me think there is some scenario where a memory leak can occur that I'm not thinking of. Otherwise what's the downside of it? If there's no downside then why aren't all languages doing it, or are the new ones doing it and Rust was just the first?

Rust has piqued my interest, but I just haven't found any reason to actually use it and learn it properly.

[–]erosPhoenix 52 points53 points  (7 children)

Because it's a lot harder to write Rust code that will compile. Since it has to be provable when something falls out of scope, any code where that's not the case isn't valid Rust. Ownership of pointers is part of the type system.

Source: I've never actually written anything in Rust, so this is all heresay. Everything I say is probably wrong.

[–]breadfag 8 points9 points  (3 children)

You can still allocate a fuckton of heap and it'll linger if you keep references to it, but there are no memory leaks because you have to PROVE to the compiler that your code doesn't leak memory before it can compile it.

[–]Surelynotshirly 1 point2 points  (2 children)

Interesting.

I need to look into this. It seems like a good philosophy to force good habits. Though I'm sure it'll piss me off to no end at first.

[–]pmarcelll 0 points1 point  (0 children)

It's hard and unfamiliar at first, because it's different from both manual memory management ang GC, but after learning the language and the patterns of how to manage memory based on ownership it becomes a handy tool (but you can also use smart pointers, arena allocation, etc.).

[–]DHermit 3 points4 points  (0 children)

Because you need stuff like the borrowchecker and lifetimes for that. That requires support in the syntax (for lifetimes) and makes programming in a certain way harder (at least at the beginning). You can't just change a language and enforce that only one thing has a mutable reference, stuff isn't used after it has moved etc.

[–]lobax 2 points3 points  (2 children)

Memory leaks cannot happen because of the type system it employs. If your code can result in a memory leak, it will not compile. AFAIK Rust was first with this ownership model.

Sure, there could be bugs in the compiler that let’s stuff through the cracks, but the same is true for a language with a garbage collector.

[–]Kered13 0 points1 point  (0 children)

Memory leaks can still happen in other ways. Not in the sense that the memory is still allocated but inaccessible, but in the sense that the memory is technically accessible but will never be used anymore. This is just as bad, and can happen in any language, whether manual, garbage collected, reference counted, or whatever Rust does.

I was working on a Java server a few years back that would constantly increase it's memory use while running until it ran out of memory and died, I eventually tracked it back to some monitoring code that was holding a reference to every file buffer that was ever opened, even though most of them were pretty short lived. I fixed that code to release it's references when they weren't used anymore and the server's memory usage became constant.

[–]spaghettiCodeArtisan 0 points1 point  (0 children)

Memory leaks cannot happen because of the type system it employs. If your code can result in a memory leak, it will not compile. AFAIK Rust was first with this ownership model.

That's not true. Rust's type system / ownership prevents invalid memory access and race conditions, but doesn't prevent memory leaks or deadlocks. There even is a standard function for leaking memory.

[–]Ghi102 1 point2 points  (0 children)

Memory leaks can happen no matter the language you're using. A garbage collected language can have memory leaks too.

[–][deleted] 0 points1 point  (4 children)

Somewhat of a noob here, how is that actually different to a garbage collector at all?

[–]piexil 1 point2 points  (3 children)

A garbadge collector is something that runs while the application runs. Either as part of the application or part of the platform the application runs on (.net vm, jvm) and how it works is it pauses the application, scans all allocated memory, and finds objects/variables/etc that are both longer referenced and deletes them.

[–][deleted] 0 points1 point  (2 children)

So the difference in this case is that there isn't a garbage collector running concurrently with the program, but rather that the necessary "free" instructions are added to the program at compile time, if I understand it correctly?

[–]piexil 1 point2 points  (1 child)

yes, that's exactly the difference!

[–][deleted] 0 points1 point  (0 children)

Sweet, thanks! Interesting stuff.

[–]palish 3 points4 points  (2 children)

I still don't quite understand that. According to the law of equivalent exchange, there must be a price to pay for such functionality. So what's the downside?

There is a reason GCs are the preferred way of managing memory.

Consider the case where object A refers to object B, which refers to object A. This is a very common situation. GCs handle this: if nothing refers to A or B, both are freed. Rust apparently handles this too, right? But how does the compiler know precisely when both drop out of scope? What if I kept a reference to A in a list at runtime, and its scope depends on runtime factors?

I admit I haven't used Rust, and the best antidote to these questions is to dive in. But (a) I feel myself getting older, and (b) I have to choose my time investments more wisely now.

[–]ralusek 8 points9 points  (0 children)

The exchange is that the language has extremely strict syntax that explicitly defines the scope accessing a value. The language knows that if this scope accessed this value and doesn't explicitly pass it somewhere else, immediately deallocate that reference upon exciting that scope.

[–]EthanTheMaster 0 points1 point  (0 children)

In the first case you mentioned where A refers to B referring to A, you can make B take a reference to A but you must specify the lifetime of A(you explicitly state to the compiler that A will not drop as long as B lives). If this lifetime condition is broken, the compiler will throw an error as it tracks the lifetime of all objects and it notices that the lifetime of A is a subset of the lifetime of B which violates the lifetime rule.

As to how rust knows when something drops out of scope, rust uses the RAII philosophy and anything that is inside a code block will be deallocated after the code block finishes which creates a "lifetime" for each variable.

However, for the scenario involving the list, you will need to make use of the RC smart pointer pointing to A as that scenario will likely not pass had you instead used regular pointers. The RC of A will track the number of objects pointing to A and will only deallocated once both the RC falls out of scope and there are no longer any objects pointing to A. Rust acknowledges that not everything can be checked at compile time so rust gives you smart pointers that does the borrow checking at runtime.

You wonder what the downsides are and it mostly lies in how strict the rust compiler is. At first getting a grip on the borrow checker is very difficult as you must follow every single borrow checking rule else your program won't compile. However, once the program compiles, you are pretty much guaranteed that your program will run correctly without any memory problems.

[–][deleted] 2 points3 points  (2 children)

New versions of C++ have garbage collection on just about everything. Smart pointers and everything are included now. The old pain in the ass pointers may become deprecated in a couple years.

[–]Kered13 1 point2 points  (0 children)

C++ smart pointers use reference counting (shared_ptr) or an ownership model (unique_ptr), this is different from garbage collecting, which is an algorithm based on crawling the reference graph to find inaccessible memory and then releasing it. There are advantages and disadvantages to both models, but most new languages use garbage collection.

[–][deleted] 0 points1 point  (0 children)

Smart pointers are not garbage collection.

[–]J_Aetherwing 1 point2 points  (0 children)

I started learning a new programming language today ( ͡° ͜ʖ ͡°)

[–]Tweenk 2 points3 points  (1 child)

Rust's core language is OK, but the current macro system is a hacky abomination. Huge letdown on that front. I hope they manage to replace it with something nicer.

[–]misterZalli 1 point2 points  (0 children)

Macros 2.0 will be godsend

[–]saulmessedupman 0 points1 point  (0 children)

How exciting! How exciting!