News for hackers. Stuff that matters.
Re:Windows has a new wormable vulnerability, with no patch by jimmaswell on Wednesday March 11, 2020 @01:25PM (#22547751)
I really wanted to give Rust a chance for the memory management but I just don't have the motivation to get past the absolutely bizarre syntax, naming conventions full of weird abbreviations like it's the 80s, and the inscrutable replacement for the OO everyone is familiar with. Every facet of the language feels like an exercise in NIH syndrome and it's just too much at once.
Re:Windows has a new wormable vulnerability, with no patch by steveklabnik on Wednesday March 11, 2020 @01:35PM (#22547942)
Almost all of these things come from other languages, some that have existed for decades. It's probably unfamiliar because you haven't run across them yet, which is fine!
Re:Windows has a new wormable vulnerability, with no patch by wrs on Wednesday March 11, 2020 @02:27PM (#22548719)
> an exercise in NIH syndrome

Don't fall into the trap of thinking the entire world is like what you can see from where you're standing. It's not really "not-invented-here", it's "not-invented-there", where "there" is wherever you're used to being. There aren't many unprecedented ideas in Rust.

Re:Windows has a new wormable vulnerability, with no patch by vmchale on Wednesday March 11, 2020 @01:47PM (#22548160)
> Every facet of the language feels like an exercise in NIH syndrome and it's just too much at once.

Not really, a lot of things are taken from sensible theory (e.g. traits and typeclasses).

Re:Windows has a new wormable vulnerability, with no patch by simias on Wednesday March 11, 2020 @03:14PM (#22549333)
A lot of the syntax was borrowed from C++ for better or worse. It does make the transition from C++ a lot easier but of course if you're not familiar with the language there'll be some friction. Beyond that there are things that Rust needs syntax for that simply doesn't exist in many other languages such as the Trait-based generics, modules (that didn't use to exist in C++) and of course lifetimes.

Beyond that I can't help but feeling that you're following this (IMO) counterproductive cargo cult that holds that sigils are teh 3v1l and everything should be alphanumeric only. Python was at the forefront of this movement but it's now very popular. IMO it's completely counterproductive, even in Python case. It's form over function. You end up with a language where you have to be careful when you refactor because indentation becomes significant and no way to scope your variables properly. Or a language like JS where somebody genuinely thought that having arcane rules to automatically insert semicolons was a reasonable idea because "ewwww semicolons look ugly". It sure looks good if you want to get them tatooed, but in practice at best it's pointless and at worst it gets in the way.

I'm all for descriptive variable and function names but the core syntax of the language is repeated all over the place all the time and benefits from concision. Having Rust spell out "function" instead of "fn" wouldn't disambiguate anything since you're exposed to it within 5 minutes in the language and you'll be super familiar with it very quickly. Having a shorthand means that it doesn't pollute the code listing and leaves more room for the actually important stuff.

A lot of people like to point out Perl as an example of "sigil soup gone wrong" but I'd argue that it's not even the real problem here, Perl can become an unreadable mess because of all the "magic" it allows, meaning you can write code that seems to do absolutely nothing but actually does a whole lot (with things like the implied variable $_ for instance). If you look at an exhaustive list of Perl operators there are only a handful I'd personally consider questionable (like `x` and maybe `<=>`. Also some of the quoting q{} qq{} and qx{} are really obtuse).

Re:Windows has a new wormable vulnerability, with no patch by skykooler on Wednesday March 11, 2020 @01:50PM (#22548193)
Coming from Python, Rust feels like C++ with a stricter compiler. It depends on how you look at it.
Re:Windows has a new wormable vulnerability, with no patch by nicoburns on Wednesday March 11, 2020 @04:46PM (#22550328)
Bizarre syntax? It's almost identical to JavaScript/TypeScript syntax. You know, the #1 most used language.
Re:Windows has a new wormable vulnerability, with no patch by jimmaswell on Wednesday March 11, 2020 @05:16PM (#22550764)
JS, C++, C# are what I'm coming from. There was no need to put things in strange orders and otherwise do so many other things different from C style for no apparent reason. Sure, you can find some example of another language doing something any way, but that doesn't make it a good idea. What tangible benefit is there to having to put the type after the function declaration?
Re:Windows has a new wormable vulnerability, with no patch by TheDong on Wednesday March 11, 2020 @05:43PM (#22551104)
You've given one concrete example, the type after the function deceleration.

I'll respond to that because there is a concrete benefit. For what it's worth, typescript, go, SML, haskell, and many other languages follow this pattern too.

In C, there's the "clockwise spiral rule"[0] to read a complex c declaration. Let's take an example from that:

    void (*signal(int, void (*fp)(int)))(int);
In rust, that would be:

     fn signal(i: isize, fp: Fn(isize) -> ()) -> Fn(isize) -> ()
In rust, the clockwise spiral rule is more simply the "read left to right" rule, which follows more naturally for most people.

For what it's worth, C++ also includes alternate function syntax [1], which matches rust's ordering of return values.

The reason it was added to C++ is because there were actual expressions the old syntax could not unambiguously express. Even to a machine the C-style declaration is more confusing.

With no offence meant, you're sounding a little blub[2]-ish in that complaint.

[0]: http://c-faq.com/decl/spiral.anderson.html

[1]: https://en.wikipedia.org/wiki/C++11#Alternative_function_syn...

[2]: http://www.paulgraham.com/avg.html

Re:Windows has a new wormable vulnerability, with no patch by jstimpfle on Wednesday March 11, 2020 @07:29PM (#22551924)
The spiral rule is wrong (or at least overcomplicated). There was once a guy who didn't understand how C declarations work, so he made some guesses, put them on his webpage, and then he still didn't know how declarations work! Too bad this page got so popular.

What he did was essentially he discovered precedence rules for normal C expressions. That's all. https://news.ycombinator.com/item?id=22451431

Re:Windows has a new wormable vulnerability, with no patch by cyphar on Thursday March 12, 2020 @07:51AM (#22555797)
While you are correct that the spiral rule is an over-complicated (and sadly, popular) rule for C declarations, that doesn't really answer GP's point -- that putting the types after the binding results in much less messy type signatures. This was the reason why Go went with such a setup (and presumably also Python, though their hand was slightly forced by backwards compatibility concerns).
Re:Windows has a new wormable vulnerability, with no patch by jstimpfle on Thursday March 12, 2020 @12:12PM (#22558286)
Consider it a reaction to something else than what might be the true point of this comment. Nothing wrong about that.

And that point is pretty much a straw man, intentionally cherry-picked and obfuscated. The type signature in my signal(3) manpage is given as

       typedef void (*sighandler_t)(int);

       sighandler_t signal(int signum, sighandler_t handler);
And functions taking and returning function pointers are exceedingly rare. In practice I still find C type syntax the easiest to read (it's so concise, and in fact there is almost no type synax because it's just expressions). The valid argument for me why we should move away from that syntax is tooling - the syntax is hard to parse for machines (but not for humans) because it requires serial reading and complete preprocessing from the start of the file.
Re:Windows has a new wormable vulnerability, with no patch by frou_dh on Thursday March 12, 2020 @05:09AM (#22555020)
That's like insisting Month/Day/Year is the one true way to write dates, and thus having a hard time ever spending time outside the USA.

Actually, the C, C++, Java, C# dynasty being the USA of programming languages seems quite fitting in terms of economics.

Re:Windows has a new wormable vulnerability, with no patch by empath75 on Wednesday March 11, 2020 @03:43PM (#22549689)
i actually really enjoy the syntax and trait system and dislike the memory management stuff -- i'd rather have the rust syntax in more of a scripting language.

It's a joy to write rust code for the most part.