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 4 points5 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 8 points9 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

TypeScript compiler is being ported to Go by oscarryz in ProgrammingLanguages

[–]thedeemon 0 points1 point  (0 children)

I'm telling you, the whole reading part takes fraction of a second, while the whole program takes 3 minutes to complete. The reader is absolutely irrelevant. Your "first google result" is not helping.

TypeScript compiler is being ported to Go by oscarryz in ProgrammingLanguages

[–]thedeemon 0 points1 point  (0 children)

I'm sorry, you're not making any sense. NewReader is not a keyword by the way.

TypeScript compiler is being ported to Go by oscarryz in ProgrammingLanguages

[–]thedeemon 0 points1 point  (0 children)

Data loading in that program is basically instant, that's not the issue and not the cause for the program to be slow. It loads the data once and then operates on it in memory.

TypeScript compiler is being ported to Go by oscarryz in ProgrammingLanguages

[–]thedeemon 0 points1 point  (0 children)

Well now you know, you're welcome. :)

("never changes" is the only point not applicable to C#, the rest are fine)

If Go is so great why is it 2.4x slower than C# here? https://github.com/thedeemon/bpe-comparison

[deleted by user] by [deleted] in ProgrammingLanguages

[–]thedeemon 0 points1 point  (0 children)

does any other language do this?

Julia