Live data from Hacker News

I'm not mutable, I'm partially instantiated

blog.dnmfarrell.com

71–77 of 77 posts

Re: I'm not mutable, I'm partially instantiated

#71
post #65
post #58

Earlier quoted context omitted.

Simon Peyton Jones (of Haskell) is working on Verse, a functional relational programming language, that merges the ideas of both functional and logical programming into one. It’s being done to facilitate Fortnite metaverse, as he’s doing this work at Epic. https://youtu.be/OJv8rFap0Nw?si=OmBT9CBJIxdJE1Jv

Functional logic programming much before Verse https://mercurylang.org/

Which interestingly enough is used to make PrinceXML [1] one of the only "browsers" to fully support CSS print media.

1. https://www.princexml.com

Re: I'm not mutable, I'm partially instantiated

#72
post #50

Earlier quoted context omitted.

I always thought that pattern matching would be an excellent feature for other programming languages, but it seems that it hasn't become popular. Many strategies available to Prolog could become possible just by the addition of this feature. One possible implementation of the idea occurs with C++ templates specialized with numerical parameters. It also seems that Mathematica provides pattern matching, but I don't use…

Erlang, Elixir, Swift, Rust, Python, probably some others. That list is roughly in order of how capable and useful the pattern matching is in each of those languages. Erlang was originally written in Prolog. Also, I definitely agree it's a feature I miss everywhere when not using Erlang/Elixir.

I looked at Erlang and it is closest to the Prolog idea (clearly because Erlang was originally implemented in Prolog). Other languages are not really what I mean by pattern matching, the matching should go on the selection of functions to apply to a particular parameter expression. In the compiled world, C++ is the one that gets closest to this behavior. Python would be able to do it due to its dynamic nature, but for some reason it decided not to implement this feature.

Re: I'm not mutable, I'm partially instantiated

#73
Only slightly related, I wish there were a way to express this in run-off-the-mill, imperative/eager languages. Eg some way to explicitly mark a class, or something like it, as immutable-but-partially-instantiated. TypeScript supports this a tiny bit by means of its `readonly` keyword which lets you assign a value in the constructor, or in any method called from the constructor. But no later than that! If there was a way to make a field "readonly once_assignable" or something like that, you could do something like in this article (esp if you nest instances of a class that uses this) with an eager language, albeit with a lot more boilerplate (and getters, I assume).

Re: I'm not mutable, I'm partially instantiated

#74

Only slightly related, I wish there were a way to express this in run-off-the-mill, imperative/eager languages. Eg some way to explicitly mark a class, or something like it, as immutable-but-partially-instantiated. TypeScript supports this a tiny bit by means of its `readonly` keyword which lets you assign a value in the constructor, or in any method called from the constructor . But no later than that! If there was…

Both Java and C# do. In Java marking a variable final makes it immutable after assigned. In C# a variable marked readonly is the same.

Re: I'm not mutable, I'm partially instantiated

#75

Only slightly related, I wish there were a way to express this in run-off-the-mill, imperative/eager languages. Eg some way to explicitly mark a class, or something like it, as immutable-but-partially-instantiated. TypeScript supports this a tiny bit by means of its `readonly` keyword which lets you assign a value in the constructor, or in any method called from the constructor . But no later than that! If there was…

Both Java and C# do. In Java marking a variable final makes it immutable after assigned. In C# a variable marked readonly is the same.

More precisely in C# a readonly field of a type can only be assigned to within that type's constructor.

Re: I'm not mutable, I'm partially instantiated

#76

Earlier quoted context omitted.

Both Java and C# do. In Java marking a variable final makes it immutable after assigned. In C# a variable marked readonly is the same.

More precisely in C# a readonly field of a type can only be assigned to within that type's constructor.

Which means you can't have a partially instantiated object except while the constructor is running.

Re: I'm not mutable, I'm partially instantiated

#77
post #50

Earlier quoted context omitted.

Erlang, Elixir, Swift, Rust, Python, probably some others. That list is roughly in order of how capable and useful the pattern matching is in each of those languages. Erlang was originally written in Prolog. Also, I definitely agree it's a feature I miss everywhere when not using Erlang/Elixir.

I'm curious, how does Swift have better pattern matching than Rust?

I agree with sulam, in that I think they're roughly equally nice to work with. Not as powerful as Erlang/Elixir, but more capable than Python.

There's a decent discussion from a few years ago on hn, as well: https://news.ycombinator.com/item?id=24662262

Post reply on HN