- The memory is erased as well in FPC, when the functions ends, that is what I understand, so no difference.
......
By and large FPC makes variables inaccessible when they go out of scope, but the memory- and this includes strings which have been used for passwords etc.- is not erased/blanked/wiped/zeroed/randomised.
... but the memory- and this includes strings which have been used for passwords etc.- is not erased/blanked/wiped/zeroed/randomised...
......
By and large FPC makes variables inaccessible when they go out of scope, but the memory- and this includes strings which have been used for passwords etc.- is not erased/blanked/wiped/zeroed/randomised.
And that would be because blanking out very large blocks of memory can be a time consuming thing. But few of us would store a (eg) password in a huge data array, should fpc null out smaller allocations and leaving the huge arrays alone ?
OK, thinking out loud, suppose an ANSIString can be told to blank out its memory before it goes out of scope ? ANSIString.NullOnFree : boolean = false ?
Davo
If you want a data type that cleans up when it goes out of scope, why not just create one?
For example:
Rust has an evangelism strike force. Pascal has not. :P
Someone will surely correct me if I am wrong: Pascal records are stack-based, classes are heap-based, objects default to stack but can be heap-based. Dunno about advanced records. Rust structs default to stack but can be heap-based. Are Rust structs directly equivalent to Pascal advanced records?
In terms of language features, most of the newer languages like Rust, Swift, Kotlin etc support nullable or optional types. Such types are supposed to help deal with the null reference, which inventor Tony Hoare has called his billion dollar mistake.
... but the memory- and this includes strings which have been used for passwords etc.- is not erased/blanked/wiped/zeroed/randomised...
Does Rust do that sort of thing?
And seems like Rust has managed to outperform C++ in syntax ugliness?
Put another way, people who say Rust is good are basically praising Pascal-like functionality which they perceive as superior to C-like functionality.- The memory is erased as well in FPC, when the functions ends, that is what I understand, so no difference.
Not quite. By and large FPC makes variables inaccessible when they go out of scope, but the memory- and this includes strings which have been used for passwords etc.- is not erased/blanked/wiped/zeroed/randomised.
MarkMLl
But by telling ANSIString that it is its responsibility to clean up when necessary sounds attractive. That 'telling' happens right at the start of the method, but gets acted on whenever necessary. After all, ANSIString already has some clean up code already. But I'd hate to waste the time overwriting every data structure just for the very occasional time its needed, as rust does.
Why Rust when there is already Ada/SPARK?
then I suggest that you provide your own "compare and contrast", possibly in a separate thread, like OP did in this one.
I see some things:
- Advanced records are available in FPC. No difference there.
- The memory is in FPC by default a copy of that record, not a move. Is possible to do a move and that the first instance is not valid anymore in FPC? Like moving a record to other record, inside the same function and / or to another functions.
- Passing a reference can be done with const or var parameters. In Rust it will be "&" for const and "mut &" for var. So no difference there.
- The memory is erased as well in FPC, when the functions ends, that is what I understand, so no difference.
So, they say Rust is more safe. On my experience is just that the compiler is very smart telling you where are the possible bugs you're making when coding. Other than that I see no point of using Rust.
Well that's it, I'm not saying one languages is better than the other. But just saying that FPC has already features that make it similar to Rust.The answer is simply no. Pascal has neither the capabilities to restrict mutability nor lifetime on a syntactic level. Therefore the features that the Rust compiler provides are impossible to do on Pascal code.
The answer is simply no. Pascal has neither the capabilities to restrict mutability nor lifetime on a syntactic level. Therefore the features that the Rust compiler provides are impossible to do on Pascal code.
So about your last statement:QuoteWell that's it, I'm not saying one languages is better than the other. But just saying that FPC has already features that make it similar to Rust.The answer is simply no. Pascal has neither the capabilities to restrict mutability nor lifetime on a syntactic level. Therefore the features that the Rust compiler provides are impossible to do on Pascal code.
Noting the (non-)mutability aspect of functional languages, but when did this sort of thing enter the mainstream? With a nod to @Pathfinder (if he's still around) did Ada or any other self-professed "safe" language implement that sort of thing?I don't know which was the first language to have that, but it is a big thing in C, so it is already pretty old.
MarkMLl
Indeed, this is the thing on my comparison, that FPC can't do. But the things in common are say the advanced records, constants and references, well other things was proved that FPC can't (by default), like strings (on the heap) erasing (that can be added if someone does it) and that by default memory is a copy in FPC and not a single pointer at a time.But your comparison completely misses the point why rust is the way it is and why it is so popular among the low level development community. The typesafety does not stem from advanced records or constants or references in particular, but the special way they are implemented. Sure both pascal and rust have andvanced records, so does C++ or C#, but the thing that makes rust advanced records special is the runtime tracking of the record and the members due to runtime information annotations (the <'a> in my example). Sure pascal has references, so does nearly any language, but the thing that is special about rust is the reference tracking and enforcement of maximum references which requires runtime information and fine grained mutability information. And yes there are constants in rust and pascal and again, C++, C#, Java, you name it, but the thing that is special about rust is the granularity of that information, that is completely lost in Pascal.
Is impossible actually, but it is impossible to implement as well?
A software that famously is transitioning to Rust is Firefox. This needs to be highly secure and really fast, which is why Rust is perfect.
It is why they designed it that way. Rust comes from the Mozilla foundation, the originator was a Mozilla employee. So it would be pretty bad if it wasn't suitable ;-)
Thinking about it, my guess it would then only work if an application and the libraries it uses would be compiled with such switch, meaning you would need a special distribution of the compiler/libraries/lazarus etc.
QuoteThinking about it, my guess it would then only work if an application and the libraries it uses would be compiled with such switch, meaning you would need a special distribution of the compiler/libraries/lazarus etc.
I'd already got there thinking about the string-wipe problem and system functions like ReadLn(). However, (a) would doing this properly in the RTL/FCL/LCL really introduce unacceptable overhead when compared with the performance lost in X11 and higher-level stuff? (b) having maximal checks enabled during development- even if aspects could be turned off for release- might still be viable.
It should also be noted that the syntactical makeup of a language changes the behavior of the developer. In for example C, everything is mutable unless defined otherwise, in rust it is the other way around. This leads to C developers having more things mutable than strictly being neccessary, simply because the developer did not bother to add the const modifier. By doing it the other way around, rust ensures that the developer only makes the things mutable that are neccessary to have mutable.
But you ought to see some of the stuff that's emerged from places like IBM... not to mention MS et al. Remember in the late 80s when Bill Gates (at his most rapacious) said that in a few years absolutely everything would be written in Visual Basic?I would be glad to have a link to that. :)
But you ought to see some of the stuff that's emerged from places like IBM... not to mention MS et al. Remember in the late 80s when Bill Gates (at his most rapacious) said that in a few years absolutely everything would be written in Visual Basic?I would be glad to have a link to that. :)