Earlier quoted context omitted.
Rust is not very suitable for functional programming because it is aggressively non-garbage-collected. Any time Rustaceans want to do the kind of immutable DAG thing that gives functional languages so much power, they seem to end up either taking the huge performance and concurrency hit of fine-grained reference counting, or they just stick all their nodes in a big array.
Using a big array has good performance though?
John Carmack on mutable variables
141–150 of 663 posts
Re: John Carmack on mutable variables
#142Earlier quoted context omitted.
one thing I've learned in my career is that escape hatches are one of the most important things in tools made for building other stuff. dropping down into the familiar or the simple or the dumb is so innately necessary in the building process. many things meant to be "pure" tend to also be restrictive in that regard.
Functional languages are not necessarily pure though. Actually outside Haskell don't most functional first languages include escape hatches? F# is the one I have the most experience with and it certainly does.
Re: John Carmack on mutable variables
#143Variable is by definition mutable. Constant is by definition immutable. Why can't people get it through their heads in 2025? (I'm looking at you, Rust)
That's surely not a constant like PI, is it?
Re: John Carmack on mutable variables
#144Earlier quoted context omitted.
I can't stand modern C#. They've bung in a bunch of new keywords and features that are of dubious benefit every release.
I'm interested what are those new keywords and features that are of dubious benefit?
e.g. Just a very simple example to illustrate the point
if (customer != null)
{
customer.Order = GetCurrentOrder();
}
vs if (customer is not null)
{
customer.Order = GetCurrentOrder();
}
Is there really any benefit in adding "is/is not"? I would argue no. So I categorise that as being of "dubious benefit" and there are many similar small features, keywords etc. that get added each release where they might save a few lines of code somewhere but I've never seem them used that often.Re: John Carmack on mutable variables
#145`let` is so 2020. `const` is too long. `static` makes me fall asleep at the keyboard. `con` sounds bad. How about
`law`?
law pi = 3.142 (heh typing on Mac autocompleted this)
law c = 29979245
law law = "Dredd"
or `set` or `once` or `make`?Re: John Carmack on mutable variables
#146How fast this got to the top, you would think John Carmack just invented nuclear fusion.
Re: John Carmack on mutable variables
#147If designing your hypothetical ideal language, what are some intuitive/cute keywords you would choose for mutables/immutables? `let` is so 2020. `const` is too long. `static` makes me fall asleep at the keyboard. `con` sounds bad. How about `law`? law pi = 3.142 (heh typing on Mac autocompleted this) law c = 29979245 law law = "Dredd" or `set` or `once` or `make`?
I think it never gained traction but it would have been nice to have this in Java
val firstName = "Bob";
val lastName = "Tables";
var fullName = "";
fullName = firstName + " " + lastName;Re: John Carmack on mutable variables
#148> Making almost every variable const at initialization is good practice. I wish it was the default, and mutable was a keyword. It's funny how functional programming is slowly becoming the best practice for modern code (pure functions, no side-effects), yet functional programming languages are still considered fringe tech for some reason. If you want a language where const is the default and mutable is a keyword, try…
In case anyone here hasn’t seen it, here’s his famous essay, Functional Programming in C++:
http://sevangelatos.com/john-carmack-on/
He addresses your point:
> I do believe that there is real value in pursuing functional programming, but it would be irresponsible to exhort everyone to abandon their C++ compilers and start coding in Lisp, Haskell, or, to be blunt, any other fringe language. To the eternal chagrin of language designers, there are plenty of externalities that can overwhelm the benefits of a language, and game development has more than most fields.
Re: John Carmack on mutable variables
#149Earlier quoted context omitted.
Much like PHP, you can actually get stuff done unlike a lot of other programming languages.
Oh? Which “lot of” other programming languages can’t you “actually get stuff done” in? Are you sure the problem lies with the programming language?
I find many of languages I am constantly fighting with dependency managers, upgrades and all sorts of other things.
Re: John Carmack on mutable variables
#150Variable is by definition mutable. Constant is by definition immutable. Why can't people get it through their heads in 2025? (I'm looking at you, Rust)
const int a{10};
An immutable variable well ... does not void some_function(const int a);
Can you tell me what is the value of `a` on both cases?