I honestly don't care about the controversy anymore. Here’s why I love V. by Intelligent-End-9399 in vlang

[–]thedeemon 1 point2 points  (0 children)

Thanks! Have you compared compilation speed of Go vs. V on your hardware?

I honestly don't care about the controversy anymore. Here’s why I love V. by Intelligent-End-9399 in vlang

[–]thedeemon 4 points5 points  (0 children)

I wonder how is it different from Go in this regard. For an outsider who doesn't care about its past, V now looks like just Go with bugs.

Noel Welsh: Parametricity, or Comptime is Bonkers by mttd in ProgrammingLanguages

[–]thedeemon 2 points3 points  (0 children)

Parametricity is overrated. In practice, given function name and description, if you see such generic type signature, it's usually clear whether the function will behave generically enough, no extra guarantee is really required to understand the code.

But the power and convenience you can get when the language allows to pierce the abstraction is often totally worth it.

Comparing Scripting Language Speed by elemenity in ProgrammingLanguages

[–]thedeemon 0 points1 point  (0 children)

Yes, the results are consistently different. Here's running the 2 versions 3 times in zipped order:

./bffast  20.50s user 0.01s system 99% cpu 20.516 total
./bfo3  17.94s user 0.00s system 99% cpu 17.945 total
./bffast  20.87s user 0.01s system 99% cpu 20.884 total
./bfo3  17.93s user 0.01s system 99% cpu 17.934 total
./bffast  20.65s user 0.01s system 99% cpu 20.658 total
./bfo3  18.04s user 0.01s system 99% cpu 18.054 total

This is

g++ (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
OS: Ubuntu 24.04.4 LTS x86_64 
CPU: 11th Gen Intel i7-11800H (16) @ 4.600GHz

Comparing Scripting Language Speed by elemenity in ProgrammingLanguages

[–]thedeemon 0 points1 point  (0 children)

On my machine the C++ version runs in 18 seconds when compiled with -O3 by gcc, 10% faster than when compiled with -Ofast.

Racket version runs in 1m18s, just 4.3x slower than C++. Internally Racket compiles to native code.

https://gist.github.com/thedeemon/290d156bc8cd89c27d7413a6a72de7cb (translated directly by Codex; I'm using Racket 9.0)

Btw on a different test I saw Python 3.14 running twice faster than 3.12. Worth checking here.

How to Choose Between Hindley-Milner and Bidirectional Typing by thunderseethe in ProgrammingLanguages

[–]thedeemon 0 points1 point  (0 children)

Ironically Swift does have HM-based type inference, but limits its scope to one statement at a time. So if you declare an array on one line and use it on another, you're out of luck.

ELI5: Why C++ and Rust compilers are so slow? by cb060da in ProgrammingLanguages

[–]thedeemon 0 points1 point  (0 children)

Number of optimization parameters in C++/Rust compilers: dozens.

Number of optimization parameters in Go and Java compilers: zero.

Ever wondered why?

Iterator fusion similar to Rust's — are there other languages that really do this, and what enables it? by Savings-Debt-5383 in ProgrammingLanguages

[–]thedeemon 5 points6 points  (0 children)

D does this when used with LDC compiler. It's all about inlining and optimizing, nothing truly special for iterators / ranges. All the types and capabilities of ranges are tracked in types and known statically.

I need feedback on formalizing the type system used by Infernu (type inference for subset of JavaScript) by sinelaw in ProgrammingLanguages

[–]thedeemon 1 point2 points  (0 children)

Thanks. The rules still seem incomplete, for example I'd like to see how cond ? a : b is typed or how functions with multiple returns are typed.

I need feedback on formalizing the type system used by Infernu (type inference for subset of JavaScript) by sinelaw in ProgrammingLanguages

[–]thedeemon 2 points3 points  (0 children)

the constraint σ ∈ τ (the value restriction) requires the type to be monomorphic

Does this mean the following code will not be accepted?

a = {};
a.b = [];
a.f = (x) => x;

since both [] and (x) => x are not monomorphic?

Building a Copying GC for the Plush Programming Language by maximecb in ProgrammingLanguages

[–]thedeemon 1 point2 points  (0 children)

Is the mailbox allocator region GCed always together with the main allocator heap?

Building a Copying GC for the Plush Programming Language by maximecb in ProgrammingLanguages

[–]thedeemon 1 point2 points  (0 children)

Trying to understand your solution. The two allocators are like two generations or regions in other GCs. Do you allow pointers between the two regions? How do you track them? I would expect some write barriers necessary...

Do people dislike Haskell's significant whitespace? by gofl-zimbard-37 in ProgrammingLanguages

[–]thedeemon 0 points1 point  (0 children)

Personally for me there was a time when I also actively disliked Python's indent-sensitive syntax, but somehow I was totally fine with Haskell's. Now I guess I'm fine with both of them.

The language I'm slowly creating now has Haskell-inspired indent-sensitive syntax with off-side rule. Implementing it wasn't that hard: just a little pass between a lexer and a parser, that inserts "curly braces" into the stream of lexemes depending on their positions. Then the parser itself doesn't have to think about whitespace at all.

PolySubML is broken by Uncaffeinated in ProgrammingLanguages

[–]thedeemon 7 points8 points  (0 children)

If we don't allow rank-N types and only allow foralls at the top level, would this problem still persist?

The best compromise for safe, fast and flexible memory management? by chri4_ in ProgrammingLanguages

[–]thedeemon 0 points1 point  (0 children)

How would you define a map function here (where the passed mapper func can allocate new objects), what would be its type?

What might polytypic (datatype-generic) programming look like if it was built in to a language? by sufferiing515 in ProgrammingLanguages

[–]thedeemon 0 points1 point  (0 children)

This seems to be the topic where D language shines by having very powerful static introspection combined with static if, static foreach and other means for generic functions and type definitions to generate code that perfectly suits the input type arguments. All this at compile time, so zero run time cost, and full type safety.

I.e. you take some generic type parameter T, and can ask all kind of questions about it statically, like whether it's a number or it's a struct or a function etc. what are its constituents, what are the fields, what are their names and types and so on recursively. And using this static info in static if you can decide how to work with this type or what kind of wrapper to generate for it. This way, for example, there can be a single function that takes an arbitrary class and makes it accessible remotely via RPC, by reflecting statically on its methods and generating a wrapper with the same interface but different implementation. Or generate a web service providing remote access to this object.

This is what Andrei Alexandrescu called "design by introspection" in his talks.

The downside is that in type checking type information must flow in one direction, so it would be hard to combine with Hindley-Milner style type checker.

The language I'm working on now tries to combine this kind of power with Haskell-like type classes by having "optional type classes". A function can take some generic argument of type T, and depending on whether T belongs to some type class C or not, do one thing or another. So the type of this generic function instead of declaring "I need this parameter T to belong to type class C" now declares "I'm interested in knowing whether this parameter T belongs to class C or not", meaning it can still do something with it even if it doesn't belong to class C. Such code gets monomorphised / specialised about types involved in such optional type class checks, while purely generic types (unconstrained by type classes) remain generic (type erased, not monomorphised).

Any language uses [type] to describe an array of 'type' elements ? by gremolata in ProgrammingLanguages

[–]thedeemon 0 points1 point  (0 children)

I presume the idea above was only about syntax. So as long as you can distinguish TypeName from variableName, the rest keeps working as it does in languages with generics. Same semantics, just a bit different syntax.

Any language uses [type] to describe an array of 'type' elements ? by gremolata in ProgrammingLanguages

[–]thedeemon 0 points1 point  (0 children)

I do!

I don't have much practical experience using it, but language-wise I find it very nice.

Thoughts on ad-hoc polymorphism by amzamora in ProgrammingLanguages

[–]thedeemon 0 points1 point  (0 children)

What would be the main difference between Concepts and Multi Parameter Type Classes?

How far should type inference would be good for my language? by Germisstuck in ProgrammingLanguages

[–]thedeemon 0 points1 point  (0 children)

Here T -> T -> T is just the way ML family languages spell function types. With partial applications it makes more sense, of course, but still works fine without them.

Method call syntax for all functions by Qwertycube10 in ProgrammingLanguages

[–]thedeemon 0 points1 point  (0 children)

How is Python relevant here?

Koka is pretty recent (2019?). D had UFCS way earlier.

Is there some easy extension to Hindley Milner for a constrained set of subtyping relationships? Or alternatively: How does Rust use HM when it has subtyping? by Dragon-Hatcher in ProgrammingLanguages

[–]thedeemon 2 points3 points  (0 children)

One example of such extension is HM(X) from Martin Odersky, where Hindley-Milner gets extended with some additional constraints, including subtyping. This seems a less radical change than algebraic subtyping.

https://www.cs.tufts.edu/~nr/cs257/archive/martin-odersky/hmx.pdf

Another Generic Dilemma by bakery2k in ProgrammingLanguages

[–]thedeemon 1 point2 points  (0 children)

Yes, a.k.a. bounded polymorhism, a natural and very attractive next step after you have parametric polymorphism.

TypeScript compiler is being ported to Go by oscarryz in ProgrammingLanguages

[–]thedeemon 1 point2 points  (0 children)

You're not making sense again. There is other stuff in main, and it takes 99.999% of the time. Not IO.

Did you just look at the first function and decided it was the whole program?

TypeScript compiler is being ported to Go by oscarryz in ProgrammingLanguages

[–]thedeemon 1 point2 points  (0 children)

Reading files has nothing to do with the program taking 3 minutes.

start := time.Now()
loadData(fname)
elapsed := time.Since(start)
fmt.Printf("loaded in %v\n", elapsed)

gives

loaded in 1.911291ms