HNHacker News
TopNewBestAskShowJobs

Hirrolot

739 karma · joined January 17, 2020

submissionscomments
Hirrolot··on Cut out everything that's not surprising (2019)
> Nobody has ever complained that a talk was too short.

People did complain. In some of my writings, I regret of not expounding a topic a bit more.

Hirrolot··on I claim Rich Hickey is wrong about non-null arguments to functions (2020)
> Unidirectional type inference would make for more intelligible compiler errors. Full Hindley-Milner can get confusing.

Bidirectional type checking has good error messages and a very intuitive implementation.

Hirrolot··on The Development of the C Language (1993)
> Sure, a turing-complete compile-time language would be nice

I wrote Metalang99 [1] as a compile-time language that is able to perform loops, recursion, etc. It's not Turing-complete though, as the C preprocessor is not Turing-complete.

[1] https://github.com/Hirrolot/metalang99

Hirrolot··on How to keep lambda calculus simple
I don't believe the original performs NbE. It _looks_ like NbE, but the composition of `eval` and `quote` will not give you beta-normal forms. `quote` explicitly wraps inferrable terms in `Inf`, while `eval` eliminates `Inf`.
Hirrolot··on How to keep lambda calculus simple
I don't kind of agree with your statement, since I earlier implemented a 80-line dependent lambda calculus [1]. I think dependent types make type checking a bit more involved due to non-trivial type equality, but that's all about it.

[1] https://gist.github.com/Hirrolot/27e6b02a051df333811a23b97c3...

Hirrolot··on How to keep lambda calculus simple
If you combine these two naming schemes in the same syntax, of course it will be ambiguous. In the examples of the K combinator, they don't clash with each other though, as those are different examples.
Hirrolot··on How to keep lambda calculus simple
The "simple" from the title I wrote as the usual meaning of "simple" in English. I had some hard time devising a proper title, so I understand the complaints.
Hirrolot··on How to keep lambda calculus simple
The techniques present in the paper and blog post are not really from functional programming but from mathematics. Functional programming just happens to present them in the most natural way; this is why the paper chose Haskell. We could implement the same in any Turing-complete imperative language, but then the code would swell by orders of magnitude.
Hirrolot··on Functions and algorithms implemented purely with TypeScript's type system
For those who are wondering whether types can be computed in the same way as values -- yes, they can, with a proper type system. Idris [1] is a prominent example of a programming language with first-class types, meaning that if you can perform (finite) computation on values, you can do so on types. The difference between Idris and TypeScript (Rust, C++, etc.) is that the former treats types as values, and therefore has no traditional separation of values and types; everything is done with the same syntax.

Zig strives to use the same syntax for metacomputation, although its approach is not tightly integrated into the type system, which is why you'd see compilation errors at expansion, not function definition.

[1] https://www.idris-lang.org/

Hirrolot··on Ask HN: Who is hiring? (July 2023)
We are remote (fixed).
Hirrolot··on Some were meant for C [pdf] (2017)
The need to express polymorphism manually in C, the need to remember to check errors returned by functions (instead of the monadic style of computation), the need to define closure's environment structures (those that are passed via something like `void *arg`), etc.

All these things are pretty tedious. And all these things are what other languages are doing under the hood. The difference is that C gives you a choice of _how_ to do (more) things; other languages do not.

Hirrolot··on [dead]
I occasionally have to manipulate binary numbers too. But, aside from bitwise operations, I almost always forget what I had learned last time and have to re-read the material again.
Hirrolot··on The Silent (R)evolution of SAT
I wonder what is the target audience of articles like this. I think the article is well-written, however 90-95% of the terminology make little or no sense to me who is not proficient in this field. Would the article be useful for someone who _is_ proficient in the field?
Hirrolot··on Programming with natural language is going to work (2010)
> The "strong type systems" work by having you design the types correctly in the first place.

I was responding to a comment that was suggesting letting an AI to do that.

> The one thing worse than debugging code is debugging "types".

It depends on a language. In languages with first-class types, we have the same tools to debug types. Classical C++ templates are more akin to a macro system than a type system.

Hirrolot··on Programming with natural language is going to work (2010)
I'm imagining an AI based on a deductive system rather than sequential text generation. This is roughly how "strong type systems" work, and so it might be simpler to map this model to formal methods.

By the way, if you spend 90% of time debugging your code, I think that's really sad. Either the programming language sucks, or the codebase sucks, or both. I probably spend 10-20% max of my time on debugging.

Hirrolot··on Why Lisp?
Good point, gotta try it.
Hirrolot··on Why Lisp?
> So someone joining the project doesn't just have to learn Lisp, they have to learn Inhouse Lisp?

I think this tends to hold true for all complex systems past certain point. Especially web frameworks. They just tend to circumvent the language so much (via macros, type system, etc.) so it's no longer like a bare language that was before. But I appreciate your point that macros can add cognitive burden in many cases where less powerful (and more easily understandable) mechanisms would suffice.

Hirrolot··on Why Lisp?
> When you have a running program you can compile functions, redefine classes, etc. all while the program is running. You are changing the internal state of the image.

This can surely be convenient in certain cases, however most of the times I find myself playing around with unit tests rather than with a single running process. Unit tests are small and fast so I don't even notice any inconvenience with the traditional compilation approach.

Hirrolot··on Pedagogical Downsides of Haskell
I find the terminology that Haskell uses quite misleading for software engineering. It borrows concepts from category theory with quaint names such as a "monad", "endofunctor", "catamorphism", etc. The problem is that, instead of a "monad", we can say "brrrdogcogfog" and nothing will change -- the name is absolutely irrelevant to the problem being solved. Given that a monad is an interface for sequential computation, a much better name would be something like "Seq", "SeqComp", or something like that.
Hirrolot··on Higher-order functions in Go
Built-in support for closures in Golang is indeed a nice feature. In contrast, in C you would have to explicitly allocate/deallocate closures if they are passed upwards the stack [1], and pack all environmental variables in a single structure (used externally as a `void` pointer). This all tends to be quite clumsy in real-world code.

The Rust support for closures is more pleasant than that of C but the innate `Fn`/`FnMut`/`FnOnce` dichotomy makes things more complicated.

[1] https://en.wikipedia.org/wiki/Funarg_problem#Upwards_funarg_...

Hirrolot··on All you may need is HTML
> Inevitably, you will want to do something the framework did not forecast and will come up with convoluted ways to do it anyway.

I always find static site generators a kind of leaky abstraction. They eventually try to abstract nearly the whole functionality of the web stack, and the larger the SSG the more apparent it becomes. But, for obvious reasons, they just cannot abstract all the peculiarities of the web from you.

I write posts in Markdown, use Pandoc to convert `.md` to `.html` and a simple Go script in 200-300 LoC [1] for my https://hirrolot.github.io/.

[1] https://github.com/Hirrolot/hirrolot.github.io/blob/master/g...

Hirrolot··on I_suck_and_my_tests_are_order_dependent
Well yes. But this all requires additional movements on my side. On the other hand, if the tests are always ordered such that dependencies are tested first, then I won't have to deal with the approaches you've mentioned.

Ideally, a test framework should enforce the order based on the project ontology. They don't usually do that though because they cannot easily examine the code being tested to extract the necessary dependency information.

Hirrolot··on I_suck_and_my_tests_are_order_dependent
I've answered it in the other comment -- because I might not know the entire module dependency graph. For example, if the code is not mine.
Hirrolot··on I_suck_and_my_tests_are_order_dependent
Even if I can have multiple failing tests, unordered testing might get tricky. For example, as I said, A depends on B, and suppose that both A and B tests are failing. If I (or really anyone else in the team) forget that A depends on B, they might be tempted to debug the A test first, only later figuring out that this is B that needs to be fixed.
Hirrolot··on I_suck_and_my_tests_are_order_dependent
I disagree that ordered tests are bad. See, I don't even have mutable state in my program -- but still have ordered tests for another reason: the ease of debugging. Say, if module A depends on module B, then B should be tested first, only then A, since if you test in the other direction, you might have a hard time figuring out whether A or B is misbehaving.
Hirrolot··on Rust vs. Haskell
Well, your example is not a generic closure, since inside `adder`, you already have a generic type `T`; it's introduced by the `fn` keyword. If we try to do the same for a closure, we would face a type error. This issue has been discussed on SO [1].

I haven't claimed that closures are not working, since well, they are working, but under a very limited set of circumstances. Again, I see nothing sensational, since the trickery of using closures has been discussed elsewhere.

[1] https://stackoverflow.com/questions/34814423/possible-to-def...

Hirrolot··on Rust vs. Haskell
The example provided in the post -- yes. But I can basically demonstrate other language features that are not working with closures, such as generics -- you just can't have generic closures in the same way as you have generic functions, even in a synchronous code. With closures, you have a pretty limited scope of what you can do, considering the rest of the language, so I think it'd be pretty useless to consider closures as a separate mechanism that shouldn't interact with the rest of the language.
Hirrolot··on Rust vs. Haskell
You can have general recursion with dependent types though. Theorem provers prohibit it because otherwise it'd render the system logically inconsistent, which is far less severe in programming than in mathematics. But I agree that a great deal of expressivity of dependent types would be lost if they're applied to systems programming, which is somewhat unfortunate.
Hirrolot··on Rust vs. Haskell
That would not be a comprehensive comparison, but:

- OCaml is definitely tailored for more "high-level" tasks, such as writing a programming language or a theorem prover (there are many of them in the OCaml world, and even Rust was initially written in OCaml, as you've mentioned). OCaml has a GC, which might be a problem under certain circumstances.

- Rust has a far better ecosystem despite being a younger language. You can just compare the number of packages on crates.io and OPAM.

- OCaml _sometimes_ has some more fancy type features, such as functors (modules parameterized by other modules), first-class modules, GADTs (Generalized Algebraic Data Types), algebraic effects, and the list could go on. It doesn't have type classes or an ownership system though.

- OCaml is more ML-like, while Rust quite often feels C-like. For example, you have automatically curried functions in OCaml and the omnipresent HM type inference.

- OCaml has a powerful optimizer called Flambda [1], which is designed to optimize FP-style programs.

Having written some code both in OCaml and Rust, I can say they are in a lot of aspects quite similar though. They both take a more practical POV on programming than Haskell, which affects language design quite evidently.

[1] https://v2.ocaml.org/manual/flambda.html

Hirrolot··on Rust vs. Haskell
I find type errors in HM typing systems can sometimes be quite obscure and misleading, due to omnipresent type inference. Writing type signatures can save you from that. For example, even if the type signature is quite "obvious", you can erroneously plug in some other type into the function, which triggers the type system to underline the function being defined instead of the function call.
← PreviousPage 2 of 5Next →