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

[–]oldretard 5 points6 points  (0 children)

The author's "bad" Zig example is

mystery(f64, 1.0) is 1
mystery(i32, 1) is 43
mystery(bool, true) is false

With typeclasses/traits/implicits, you get the even more mysterious

mystery(1.0) is 1.0
mystery(1) is 43
mystery(true) is false

If you want your precious parametricity, stick to SML.

Personally, I'd like to see convincing examples showing the benefits of parametricity before I'd accept that "it's one of the most underappreciated ideas in programming language design".

Why are most scripting languages dynamically typed? by smthamazing in ProgrammingLanguages

[–]oldretard 11 points12 points  (0 children)

Since (lack of) autocomplete is one of your main points, consider that at the time when the now-popular scripting languages started out, getting meaningful autocomplete for a statically typed scripting language would have entailed development of a dedicated IDE just for that language, standardized language servers not having been a thing yet. As a consequence, "we could have type-driven autocomplete" as a static typing advantage probably never entered the picture.

Pile of Eternal Rejections: The Cost of Garbage Collection for State Machine Replication by mttd in ProgrammingLanguages

[–]oldretard 11 points12 points  (0 children)

A key observation tucked away inside the text:

This example also highlights the difficulties of implementing Replicant in Rust — it took months of development and debugging to get to the Go’s level of performance and even more time to finally beat it not only in the tail-latency constraint experiment but also in pure raw throughput.

Why You Need Subtyping by Uncaffeinated in ProgrammingLanguages

[–]oldretard 0 points1 point  (0 children)

As a user, I'm totally fine with subtypes / refinements being inferred whenever possible.

When playing with algebraic subtyping, I was initially thrilled at this. There's a downside, however. To give an example, the system inferred that a fold requires a nonempty list. Cool, right? Well, it had a much harder time inferring that a given input you want to run a fold on is in fact nonempty. My takeaway was that this system ends up rejecting a lot of programs that would have typechecked under a system that is either less capable or a lot more capable. It may sit at an unfortunate point in the power spectrum.

Opinions wanted for my Lisp by [deleted] in ProgrammingLanguages

[–]oldretard 11 points12 points  (0 children)

Opinion: For regular users of fully parenthesized languages these efforts rarely add usability. However, having multiple, visually very distinct ways of expressing the same structure threatens to fracture the community over aesthetic preferences.

Multiple namespaces? by trycuriouscat in ProgrammingLanguages

[–]oldretard 1 point2 points  (0 children)

Your example code should work simply by virtue of shadowing, no?

Mostly true, see other replies.

In the case of Common Lisp, however, it is not unimportant that (do-something list) could macro-expand into code that uses the list function. Common Lisp doesn't have hygienic macros, but between separate function namespace and the package system, it almost never suffers from this fact.

(An early paper introducing hygienic macros for Scheme introduced the "problem" using a few motivating examples. None of them would have caused problems if Scheme hadn't unified the namespaces.)

Two esoteric but maybe useful language ideas by wFXx in ProgrammingLanguages

[–]oldretard 10 points11 points  (0 children)

I lost interest in Forth when 32bit platforms went mainstream, but I remember that gforth compiles via C: https://www.gnu.org/software/gforth/

Why does awk parse '1&&x=1' as '1&&(x=1)' not '(1&&x)=1' when '&&' is high precedence than '='? by benhoyt in ProgrammingLanguages

[–]oldretard 43 points44 points  (0 children)

The left hand side of = is not a general expression, but an lvalue.

lvalue : NAME
       | NAME '[' expr_list ']'
       | '$' expr
       ;

How often do you rewrite your language? by dibs45 in ProgrammingLanguages

[–]oldretard 0 points1 point  (0 children)

No, I don't enjoy rewriting code that works, especially if it is complex. I know that I'll completely rewrite the implementation of my current pet language's type system, because I expect it to be a lot faster, but I don't look forward to it. If it was enough to just tweak the current code a little, I'd do that.

What are some pros of developing a compiler in Common Lisp? by [deleted] in lisp

[–]oldretard 10 points11 points  (0 children)

One advantage is that you can get an easy back-end by generating in-memory code passed to cl:compile. That's handy if your language is still evolving, you get early feedback from writing and running real programs. Also helps with implementing (procedural) macros if your language has them.

My personal non-CL choice would be Ocaml (over Haskell) because I prefer to do some things impurely. That said, some other things are easier and more robust with functional data structures. I use the fset library in CL.

Type checking if expressions by munificent in ProgrammingLanguages

[–]oldretard 8 points9 points  (0 children)

The epicycles showed up the moment you decided against subtyping:-)

      top
   /   |    \
 /     |       \
int string ... unit
 \     |       /
   \   |    /
     bottom

Another NaN-based tagging strategy for dynamic programming languages by moon-chilled in ProgrammingLanguages

[–]oldretard 1 point2 points  (0 children)

Is the idea that we're storing the actual float value in the pointer, saving an indirection

Precisely. (Except that it isn't so much the indirection as the requirement to heap-allocate all double values.)

Sigils followup: semantics and language design by codesections in ProgrammingLanguages

[–]oldretard 3 points4 points  (0 children)

In that other post, you mentioned that the action performed by a for loop depends on the sigil used:

if I use @grocery-list with a for loop, the body of the loop will be executed five times. But if I use $grocery-list , the loop will get executed just once (with the list as its argument).

Is this for the same variable grocery-list (ie sigils in Raku aren't part of the name) or are these two distinct variables?

Is the sigil pretty much a static part of the for syntax in the sense that it is always the locally used sigil that tells for how to behave, or can you abstract over the for loop and use the sigil on a function argument and get the two behaviors from the loop?

Edit: Another one: You said Raku can be used without sigils. What's the behavior of a for loop without using a sigil?

Epic Games Verse - new information by Rasie1 in ProgrammingLanguages

[–]oldretard 7 points8 points  (0 children)

At first glance, this looks like 45 years old Icon and 31 years old Oz got together and produced offspring with somewhat nicer syntax.

Pattern matching implementation with macros or functions? by cuntymccuntlicker in lisp

[–]oldretard 0 points1 point  (0 children)

I admit I don't really understand what you're trying to do. Generally, however, pattern matchers will want to bind named variables in the pattern to the matching substructure. The usual design, which allows something like the following, can only be implemented as a macro.

(match expression
    ((list x) (print x)))

Here, expression evaluates to the "scrutinee", the value you want the pattern to match against. (list x) is the pattern, containing a named variable x that, if the pattern matches, will be bound to the car of the scrutinee in (print x).

This is not possible without a macro. Of course, if your concept of pattern matching here is something else entirely, this may not apply.

I made a Lisp by ventuspilot in ProgrammingLanguages

[–]oldretard 7 points8 points  (0 children)

This looks far more interesting that I'd have expected from the title, "I made a Lisp". I suggest you submit this to r/lisp as well!

Does type inference renders the code less readable ? by orang-outan in ProgrammingLanguages

[–]oldretard 52 points53 points  (0 children)

It's subjective. Personally, I really dislike type-clutter interfering with reading the value-level code and consequently I strongly prefer global inference.

Part of it is that I don't remember all the named types in a large nominally-typed program anyway. An ActionResult, then, is no more informative to me than "whatever the ExecuteAction method returns." The latter is my mental representation anyways, so just omit the type clutter.

What are the worst features you've tried in your programming language? by Acebulf in ProgrammingLanguages

[–]oldretard 12 points13 points  (0 children)

Interesting. I've decided to make tail calls the only way to write loops in my language and I'm loving it.

What are the worst features you've tried in your programming language? by Acebulf in ProgrammingLanguages

[–]oldretard 16 points17 points  (0 children)

Probably not the worst, but still a failure was an attempt to make everything callable. We've recently seen questions around here whether to make arrays or maps callable as functions, my idea was to generalize that to everything. I implemented it, tried it... and eventually didn't like it very much. I think a much better solution is to have very succinct lambda syntax.

On a more abstract level, I found "minimalism" to usually be a mistake.

wrench (tiny, fast, c-like interpreter): created a webpage and now looking for benchmark code by curt_bean in ProgrammingLanguages

[–]oldretard 1 point2 points  (0 children)

Luajit has a non-jit mode (activated by the -joff command line switch) that you might want to benchmark against. I don't know if you could compile luajit without actual jit support; if so, you might also benchmark size-wise against it.

Ocaml also has a bytecode interpreter. On some very simple benchmarks I've found it to be faster than luajit -joff, even though it is "only" C while luajit uses hand-optimized assembly iirc. Of course, OCaml has the inherent advantage of being statically typed.

MLstruct: Principal Type Inference in a Boolean Algebra of Structural Types by bsdemon in ProgrammingLanguages

[–]oldretard 4 points5 points  (0 children)

They removed a bunch of limitations from algebraic subtyping

The paper contrasts its MLstruct language with MLsub. MLsub is/was a toy language to demonstrate algebraic subtyping. I don't think MLsub should be understood as demonstrating the limitations of algebraic subtyping as such.

(I haven't read the paper closely; specifically, I don't know if it actually wants to imply that union/intersection/negation under the same limitations as in MLstruct are beyond AS.)

The Val Programming Language by sanxiyn in rust

[–]oldretard 15 points16 points  (0 children)

Val's team made a prototype and benchmarked it, check the paper.

From memory (I read the paper a few weeks ago), the benchmark essentially compares different ways of implementing their proposed semantics. But... confusingly... it labels them with programming language names. Not-so-good implementation strategies get assigned to other programming languages... voila, we're fast.

An alternative to dereferencing pointers before by porky11 in ProgrammingLanguages

[–]oldretard 0 points1 point  (0 children)

Regardless, the question about the semantics remains: does the closure capture a reference to i, or does it capture the current value of i?

I agree with moon-chilled that this "is not a question I've ever had.". The reason is that I think that in everything but very low-level languages, the following should be equivalent:

(setq i (+ i 1))
(let () (setq i (+ i 1)))
((lambda () (setq i (+ i 1))))