4 ms·
Normally I think "rewrite it in Rust!" comments are annoying, but in this case the author's requirements sound pretty relevant: - integration with C libraries
by oconnor663 9y ago
Normally I think "rewrite it in Rust!" comments are annoying, but in this case the author's requirements sound pretty relevant:
- integration with C libraries
- overhead similar to C
- more productive than C
- "Variables are immutable by default, globals are not allowed, functions are pure."
That does sound an awful lot like Rust, at least if we kind of squint our eyes at the purity requirement :) I wonder if the original author considered it?
- zokier 9y agoOn the other hand, Rust definitely does not have "Fast compilation", and although debatable, I would say that "Simplicity" is not one of Rusts many virtues.
- JoshTriplett 9y ago> On the other hand, Rust definitely does not have "Fast compilation", True, though several people are now working on compiler performance. > and although debatable, I would say that "Simplicity" is not one of Rusts many virtues. I've found that Rust seems as simple as it can be given the problem it's solving. For instance, lifetimes and borrow checking aren't trivial, but I have a hard time thinking of a simpler abstraction that has the same safety and performance properties. Another way to look at it: C is "simpler", in some ways, but it pushes the corresponding complexity into the heads of developers and the code of helper/wrapper libraries and tools.
- captainbland 9y agoI think it's one of these things where C is 'simple' but using it often isn't. Taken to the most absurd extreme, Brainfuck is even simpler. So I'm not sure that simplicity is necessarily a virtue in a programming language. That said, I don't think Rust is that complicated - it's just that a lot of the concepts it uses are unfamiliar to a lot of people and 'best practices' are not always set in stone because of that, which causes confusion - that's more of a maturity thing than anything else. Contrast with C++ (or C# or Java) which certainly is a complex language, but people aren't that confused by it because there are a wealth of books which prescribe the best ways to do things in any given scenario.
- oconnor663 9y agoI'll repeat what a lot of other people have said on this one. I think Rust puts the vast majority of its complexity up front, so that you have to deal with it even in toy programs. However, once your toy program is working, it can expand into a real program without uncovering bugs or running into a lot of new complexity. C on the other hand, can make toy programs appear simple. However, there can be a lot of undefined behavior in those programs, which will turn into serious bugs as the programs get more interesting. I like this article for talking about some of those cases: https://blog.regehr.org/archives/1520 https://blog.regehr.org/archives/1520
- dom96 9y agoSince we're suggesting alternatives already I would like to throw Nim into the mix. - Variables aren't immutable by default, but neither are they mutable by default. - Globals are discouraged. - Nim compiles to C so integration with C libraries is easy and overhead is also similar to C. - Productivity is subjective but I'd say it's significantly more productive than C. - Despite going through a C compiler the compilation is still incredibly fast.
- AnIdiotOnTheNet 9y agoIf we're playing "recommend a language", I'll mention my personal favorite: Zig. -`const` for declaring immutables, `var` for mutables, do what you want. -Use globals if you want, or don't. -Can directly import C headers, generally no need to write bindings. -Personally I've found it significantly more productive -Compiles fast, but lets be fair, people only bring this up because C++ and Rust are the outliers here by compiling so slowly. Other noteworthy features: -Standard library is completely optional. -No default allocator. -Comptime functionality instead of macros.
- eggy 9y agoI'll second Zig. I tried Rust and it was just too much overhead for me. I felt immediately comfortable with Zig, and focused on the task at hand. I hope it gets more traction and more people work on it. I will when I'm competent enough!
- solarkraft 9y agoIf we're playing "languages that compile to C" I'll add Vala. - Many apps for Elementary and other Gnome platforms are written in it - oop - properties/automatic getter,setter - for each loops - closures - reference counting - great compatibility with Gnome things - interoperable with c GTK example (from german wikipedia): using Gtk; int main (string[] args) { Gtk.init (ref args); var window = new Window (); window.title = "A simple GTK+ Program"; window.set_default_size (300, 50); window.position = WindowPosition.CENTER; window.destroy.connect (Gtk.main_quit); var button = new Button.with_label ("Click me!"); button.clicked.connect (() => { button.label = "Thanks!"; }); window.add (button); window.show_all (); Gtk.main (); return 0; } https://en.wikipedia.org/wiki/Vala_(programming_language) https://en.wikipedia.org/wiki/Vala_(programming_language) https://wiki.gnome.org/Projects/Vala https://wiki.gnome.org/Projects/Vala