5 ms·
I think Rust and Swift's approach of approach of making the user explicitly annotate (both at function definition time and a call time) these kind of parameters
by nicoburns 8y ago
I think Rust and Swift's approach of approach of making the user explicitly annotate (both at function definition time and a call time) these kind of parameters works pretty well.
I think you're right that it can often be an antipattern. But there are also use cases (usually for performance reasons), and the real problem occurs when you are not expecting the modification to happen. If the parameter is annotated then it's obvious that it might be mutated, and less of an issue...
P.S. Looking forward to the open source release. This langiage looks pretty nice/interesting to me, but there's no way I would invest time into learning a closed source lanaguage.
- amedvednikov 8y agoI don't think it's possible to have a closed source language in 2019 :) It will be released with an open source this year.
- User23 8y agoTechnically (and we are technical folks) it's a language with a closed source reference implementation. A serious language designer is going to specify his language, so that other implementations, closed or open source, are possible if not available. C is the ur-example, there are dozens of implementations, some proprietary and some free.
- amedvednikov 8y agoThere's no reference implementation yet. I had a small page about the language up. I don't have some of the most basic things implemented and figured out yet.
- User23 8y agoI’m very happy to see that you’re doing this. Keep at it!
- iainmerrick 8y agoWe aren’t in a phase where languages have multiple implementations right now. I can’t think of any well-known newish language (created in the last 10 years, say) with multiple implementations. Rust, Kotlin, Swift, Julia, Dart... any others? Go might be a counterexample with its cgo implementation, but that was built by the same team and I have the impression (maybe mistaken) that it’s fallen by the wayside. I don’t know if this indicates a really new language development style, with less emphasis on specification, or if it’s just a cyclic thing and some of these new languages will gain more implementations as they get more established.
- kupiakos 8y agoPython has PyPy?
- iainmerrick 8y agoPython isn’t new! It’s almost 30 years old.
- kupiakos 8y agoI was about to suggest Python 3, but it seems Python 3.0 released December 3, 2008. Barely missed it!
- heinrich5991 8y agohttps://github.com/thepowersgang/mrustc https://github.com/thepowersgang/mrustc is an alternative compiler for Rust.
- iainmerrick 8y agoCool! Looks like that’s not quite ready for prime time, but I hope it succeeds.
- coldtea 8y agoYeah, but no language of the ones the parent mentioned has a non-toy, non-personal-project alternative compiler. Perhaps only Golang (go and go-gcc). For all others, everybody uses the standard compiler. Even in Python, PyPy is not even 10% of the users. Whereas in C/C++ and other such older languages there are several implementation (MS, GCC, LLVM, Borland, Intel) with strong uptake and strong communities/companies behind them.
- rafaelvasco 8y agoThis. Letting the user annotate it is better then enforcing a behavior that is adequate in some scenarios but awkward in others. For gamedev for example, generating copies at game loop is only acceptable for small objects like Vectors and if they're allocated in the stack for example. Even if the compiler optimizes it, it is better to express the intent clearly in the code.
- amedvednikov 8y agoI'm planning to optimize this so that no copies are created.
- rafaelvasco 8y agoYeah , but i meant that a = multiply_by_2(a) still looks like it is copying things even if it isn't. Let it be immutable by default and mutable with a keyword.
- runeks 8y agoFor what it’s worth, if you can optimize away the immutability (copying), I’d much prefer expressing myself this way, rather than using mutability.