HNHacker News
TopNewBestAskShowJobs

shirogane86x

106 karma · joined March 30, 2020

submissionscomments
shirogane86x··on OCaml 5.0 Alpha Release
I totally get that sentiment about nix, and actually I sort of share a variation of it too: I really want to learn it, and I like the featureset in theory, but I can't get used to it in practice, and I don't have the time to invest myself into something that difficult to get going.

The reason I brought up the nix command is that I only use nix, for haskell development, for that specific command: I found it once in a blog post, saved it, then put it under a function into my bashrc, and I use nix quite literally for only that purpose. I've done a lot of development on various functional languages (with a dayjob in F# that lasted 3 years) and being able to quickly experiment with libraries was something that I sorely missed when doing repl experimentation in those languages (I think F# recently got a #nuget directive, but that was after I stopped using it).

shirogane86x··on Ante: A low-level functional language
quoting the github readme:

> In general, ante is low-level (no GC, values aren't boxed by default) while also trying to be as readable as possible by encouraging high-level approaches that can be optimized with low-level details later on.

shirogane86x··on C#: IEnumerable, yield return, and lazy evaluation
F# will always assume that the types can be heterogeneous, there's nothing in F# that gives (*) or (+) any sort of special behaviour, so it doesn't conform to an interface. Operators will usually always have an (inline) type of form

    ^x * ^y -> ^z 
because you could technically define a

    static member (*) (a: int) (b: float): double = ... 
and there's nothing saying that you can't. in that case:

   (*) : ^a * ^c -> ^b //^a = int, ^c = float, ^b = double
   (*) : ^c * ^c -> ^b //^c = int, ^c = float, ^b = double. 
and the second one won't work, because ^c =/= ^c
shirogane86x··on C#: IEnumerable, yield return, and lazy evaluation
As a former F# full-time dev, I'd say that there's a few things that really make it worth to use F# (and I will still use it instead of C#, where there's a possibility, in the future):

- Computation expressions make it possible to do ergonomically use value based error and nil handling, with option and result (very awkward to do in C#).

- type providers are a way to generate types at compile time based on some input. They let you do amazing stuff, like compile-time checking SQL against a specific database and automatically generating the correct types for inputs and outputs, or automatically generating types for stuff like XML or JSON files, based on a sample.

- really good type inference and (in my opinion) a better type system than C#'s, mostly wrt generics. You reap all the benefits of static typing, while also typing very very few types, and you get to express some things that just aren't unfeasible to express safely in C#. For example, the compiler will infer things like:

    let add a b = a + b * b
    //has type
    ^a -> ^c -> ^d
    when (^a or ^b) : (static member ( + ) : ^a * ^b -> ^d) and
    (^a or ^c) : (static member ( * ) : ^a * ^c -> ^b)
    //which means: a function from 'a' and 'c' to 'd', where either 'a' or 'b' has an add operator, and either 'a' or 'c' has a multiplication operator
you could also explicitly type it out as a type signature, by the way.

there's probably more, but these are the things that came to my head. DISCLAIMER: I usually reach for F# anyway, as I feel a lot more comfortable programming functionally compared to imperatively. F# is the only real option for actual FP on the CLR - so I'm a bit biased (and for much of the same reason, I would rather use Scala compared to Java on the JVM, for example). My actual favourite programming language to use is Haskell, so take that as you will :)

shirogane86x··on OCaml 5.0 Alpha Release
both cabal and stack have improved, there's now a pretty good language server in HLS, there's ghcup to download and install both GHC and tooling and manage it (both on linux and on windows). And for quick one-off experiments I usually use nix (I don't fully use it, too complex for my brain, but being able to do

    nix-shell -p 'haskell.packages.ghc{version).ghcWithPackages (pkgs: with pkgs; [any number of packages here])'
is just an insane superpower that lets me experiment stuff in ways that most other ecosystems would dream of)
shirogane86x··on OCaml 5.0 Alpha Release
I don't know if those things you ask are in Haskell specifically, but what I do know is that Haskell concurrency is pretty much best in class. You get channels (Control.Concurrent.Chan is in the stdlib), STM, green threads (forkIO). You can also get stuff like async (from the async library) or streamly (even higher level than traditional async). I'm not 100% sure if you can push insane speeds with it (even though Haskell is really fast, it's just very tricky to optimize correctly) like you can with Rust, but the developer experience on concurrency is just through the roof, imho (dare I say even better than rust). STM is just the best kind of magic.
shirogane86x··on Show HN: Arctype, a cross-platform database GUI for developers and teams
I'm pretty sure discord is using rust on the backend, not on the electron app. They use it to make some code faster (through NIFs) inside of their larger Elixir codebase.
shirogane86x··on Flix – Safe, reliable, concise, and functional-first programming language
Thanks for the response! I will surely hop on the gitter when I have some time. I'm also really happy about the presence of let*. I guess I have something to try this evening after work :)
shirogane86x··on Flix – Safe, reliable, concise, and functional-first programming language
As someone who loves Haskell a lot and was looking for a functional language on the JVM, the language looks absolutely awesome. If the richer effect system gets implemented this has a shot to becoming a staple of mine! I'm reading the documentation right now, and I had a few questions:

- is there any plans to add restricted forms of instance overlapping, in the spirit of purescript's instance chains (or Haskell's overlappable/overlapping)?

- I couldn't find resources on error handling, does flix use some sort of Either/Result type? and if so, how ergonomic is it? I'm assuming Flix doesn't have special syntax like Scala/Haskell for monadic for(/do) comprehensions, so I fear that Either based error handling would quickly become gnarly with just monadic operators. Is there any example of Result-dense code out there to check out? I couldn't find it in the example (admittedly, I have checked quite thoroughly yet)

- I read somewhere on the docs (I think on the design flaws blog?) that Flix at one point had UFCS, is that still supported? I can't seem to make it work on the playground

- Is there anywhere I can read up on the way instance resolution works? More specifically, I'm interested in whether Flix takes only instance heads or it also takes the constraints into account when choosing an instance (if it does take constraints into account, that makes overlapping instances a lot less useful in a good way, I think?)

In any case, great work on the language! I will for sure try this out the first time I get the chance, it looks great and has basically 99% of the features that I would ever want in a programming language. Keep up the good work!

shirogane86x··on Go nulls and SQL
I don't think that's quite true. It's sort of the same in how it's used, but the main difference is that T? (or T | null) is a union, and Optional/Maybe/Option is a sum type. Out of all the implementations I've seen, T? can't be nested - you can't have T??, whereas it's quite possible to have a Option<Option<T>> (and it's sometimes useful).
shirogane86x··on Modern programming languages require generics
Is it? To me it seemed like any potentially powerful enough type system starts needing at least some degree of type annotations at some point. Something something typechecking halting problem? Don't know the specifics though.
shirogane86x··on Gov.uk drops jQuery from their front end
In every single project or company I've ever worked on/with, monkey patching was _extremely_ frowned upon (for good reasons). Also, how would you be able to filter without any copies? you'd at least be forced to make one. filter is _not_ supposed to mutate anything. so you'd have to create a new Array and/or NodeList, and put the filtered values back in. Even then, doing all this stuff for what is effectively one single copy that is likely to be insignificant at a performance level is, in my opinion, excessive. I just copy once and make the code clearer.
shirogane86x··on Gov.uk drops jQuery from their front end
I'm also one of those guys that will always spread NodeLists (and other iterable-but-not-array type of objects) but it's really only because I find functional style a lot more readable than imperative style for loops. It might be iterable, but if it doesn't have map/filter/reduce and friends, might as well not be for me.
shirogane86x··on The Rust Borrow Checker – A Deep Dive
Yeah I've had the same experience (with Haskell, and with Rust). Lisp probably counts too, and maybe even Array languages like APL? It does feel amazing though. It does take a while to learn and internalize these great languages, but once you do it feels like you have superpowers sometimes. I would never even attempt to write some of the things I've written in Haskell in other languages.
shirogane86x··on Bubble Tea: fun, functional and stateful way to build terminal apps
if you need a fun language to learn to make TUIs, haskell has the brick library :) . I've heard very good things about it, it's declarative, only downside is that it doesn't support windows.
shirogane86x··on RAD Basic – Compatible with Visual Basic 6 projects
Admittedly most of my experience was in VB.NET, with a small caveat. The codebase I worked on (for around 3 years) was initially ported verbatim from an old VB6 + Access app, and it had the bare minimum amount of changes needed to make it work, so I feel like (and wrote the comment with the assumption that) at least the business logic part of said software was more VB6 than it was VB.NET. Barely no classes and 0 inheritance (the one good side), but also really dodgy imperative code with laughably brittle error handling (when it was there at all), wonky syntax (subjective), and an extremely loose approach with typing.

Considering that I spent (and still do spend) most of my afternoons with Haskell and F#, it was a bit of a shock and an experience that I don't remember fondly at all heh

shirogane86x··on Rust is hard, yes, but does it matter?
If I had to push a fix to prod ASAP, I'd personally rather it take more time but go in production safely. Especially in a case like that with not enough testing to really be sure if everything's okay or not, the stricter the compiler the better.

And if I had to train employees, I'd rather them fight the compiler more in the beginning but write better code later, than be able to write code quickly but make a horrible mess.

I've seen the "fast and loose" approach fail miserably and turn into a nightmare enough times that I now advocate for strict languages whenever I have a say in things. (which is why, with the state of programming languages right now, I will almost never suggest zig or go for a project). I think developers in generals should trust themselves less, to be honest. I feel like it would avoid a lot of issues down the road.

shirogane86x··on Rust is hard, yes, but does it matter?
Weird take: I actually do say the same for Haskell (disclaimer: I've used Haskell in all my personal stuff for about 5 years now) A lot of the stuff I used to hear and say about Haskell (about type driven and compiler driven development) is now making the rounds in the rust community, and I'm honestly super happy about it. I'm really happy that this way of programming by having a (not so) friendly chat with the compiler is gaining traction.

Side note: performance is still black magic.

shirogane86x··on RAD Basic – Compatible with Visual Basic 6 projects
I see a lot of people expressing love and nostalgia for like VB6 and stuff but to be honest... maybe it's me being younger and not having experienced VB during its prime, but when I got to work with VB6 and VB.NET it was a _nightmare_.

I can see that the tooling might've been great and all, but the language is seriously just horrible. And as for VB.NET, my experience was that the bearable parts were the ones it inherited from the .NET and C#. It might've been fine for prototypes, but at least IME prototypes never stay that, they get swamped with features and a few years down the line you have a Frankenstein's monster of badly thought out features struggling to interact with each other... except with VB, all of that is mixed in a soup of On Error Resume Next. I don't really see how anyone would put up with that in 2022

shirogane86x··on Tell HN: AT&T disabled phone numbers and accounts of users using the old phones
Wait a second, sorry if I am ignorant on the matter but... carriers _whitelist_ phones in America? That sounds absolutely insane to me (as a European). Is there a particular reason why they do that? and also, is there any reason why it is allowed? I don't think I've ever heard of anything like this over here in my country. And even though I'm not a law person, I'm pretty sure something like that would either be illegal or just disaster for the company.
shirogane86x··on Why Hy?
I may be wrong about this, but having tried fennel recently, doesn't it have quasiquoting now? at least according to: https://fennel-lang.org/macros
shirogane86x··on Rustaceans at the border
I feel like effect systems like the ones in unison and koka (or haskell with extensible effects / freer libraries like polysemy or eff) get pretty close to that. I feel like there's a lot of effort needed to make the idea "mainstream" and to get a good implementation going though (I think a lot of implementations use delimited continuations, but I'm not sure so don't quote me on that. At least it's the design for haskell's new primops to make that kind of library better)
shirogane86x··on How side effects work in FP
Disclaimer: personal opinion Having used both extensively over the years... I'll have to disagree. Don't get me wrong, purescript is awesome in its own way, but it falls short of haskell in a few major ways. - Lacks ergonomics (for example it has better extensible records, but they are clunky to manipulate due to the lack of features at the type level)

- as of now it's tied mostly to the JS ecosystem and runtime(s): that means no TCO, which _really_ hurts when using monads that require on a lot of recursion. And in fact purescript sometimes has to take a performance penalty and use specific trampolined stack-safe monads to avoid stack overflows

- Haskell layout rules may be complex, but purescript's break in weird and unintuitive ways (by layout rules I mean the indentation-sensitive syntax)

- Haskell is catching up on _a lot_ of the feature that made/make purescript great (mostly talking about syntactic things right now, like RecordDotSyntax, QualifiedDo, BlockArguments...)

- as it turns out, when programming "Haskell-style", laziness is really damn effective. So many times I've had to forcefully (and painfully) introduce laziness in purescript to make things behave well...

As much as I like purescript, I think if you want that kind of strict programming, maybe OCaML or a derivative thereof (or maybe even ReasonML/Rescript?) would work better? I feel like whenever I use purescript it looks so similar to Haskell that I try doing things the haskell way and it just doesn't work, and the "purescript" way will often look weird to a trained haskeller.

shirogane86x··on How side effects work in FP
that is _not_ possible in haskell, simply. generateUUID needs a random number generator, thus it probably has a type like

  generateUUID :: IO UUID
which means that those two lines don't _really_ make sense: you'd get a compile error. to use side effects (which in this case, IO, mostly means opting into sequencing of actions) you'd have to write

  uuidY <- generateUUID
  y = bar uuidY
  uuidZ <- generateUUID
  z = bar uuidZ
in which case, equational reasoning still holds. Side-note: in haskell, you could write it while avoiding the middle line using either the left or right bind operators, so you could write it as

  y = bar =<< generateUUID
  z = generateUUID >>= bar
(mnemonically: the first one runs an action and pipes it to the left, the second one does the same but pipes to the right)

Side-note #2: that's actually not too far away from how random number generators work in haskell: either you pass the state around, or you do it in IO.

shirogane86x··on How side effects work in FP
I still think that it would look a lot less bad than JS callback hell, mostly because of syntax.

  actA >>= \a -> 
  actB a >>= \b -> 
  pure doSomethingWith b
is a lot better (to my eyes) than:

  actA(a => 
    actB(a, b => 
      doSomethingWith(b)
    )
  )
      
and it gets worse from there (blocks to have statements to declare variables, or to call multiple functions. pre ES6 those would've also been functions rather than lambdas. Admittedly monad transformers aren't that great, but that's mostly because of the nxm amount of instances (to avoid explicit lifting).
shirogane86x··on How side effects work in FP
I am not at all an expert on GHC's codegen, but having glanced at that code before (mostly to get an intuition of what IO is under all that sugar), RealWorld doesn't even... exist. Realworld and its close friend, State# are tokens of sort. they're zero-sized and deeply magical (the GHC.Prim is quite enlightening to read). All the primops are defined as infinite loops... it's quite a sight to behold. As something totally unrelated to the above, a lot of the more internal GHC stuff (so the GHC.* modules, the stdlib/base, etc) are in my opinion readable and most of all, well commented, so it's quite fun to take a look sometimes.
shirogane86x··on What Color Is Your Monad
I see that scala(z)'s operators are adapted from haskell which seems to make it quite nice, although I don't know the finer details.

Also thanks for letting me know about the escaping, sadly I can't edit the comment anymore

shirogane86x··on Haskell2020 Is Dead, but All Hope Is Not Lost (2019)
disclaimer: I'm a haskell user who has worked professionally with F# for 3 years I don't think something like native F# would fit Haskell's niche: Haskell's type system is a lot more complete (and complex, by virtue of cruft and necessity) than F#'s. F# also has a lot of object oriented stuff which Haskell doesn't have (by design, i'd say). Maybe purescript or idris if they had more mature native compilation targets would come closer, but even those are strict (while Haskell is lazy) and laziness by default is a big thing that sets Haskell apart from virtually any other language in use.
shirogane86x··on What Color Is Your Monad
small nitpick/counter example: in Haskell, you could make your example look like:

   something <$> effectfulA <*> effectfulB
<$> and <> are very common in haskell code and basically second nature to any haskeller, and that's how I would personally write it (don't know if scala has equivalents). Idris in my opinion does this even better, in Idris it would look like the following:

    something !effectfulA !effectfulB -- using !-notation, or:
    [| something effectfulA effectfulB |] -- using idiom brackets
the two exist separately because !-notation is more general, while idiom brackets abstract _only function application_, and they desugar to map (aka <$>) and ap (aka <
>), rather than !-notation which desugars to bind (aka >>=, aka <- in do blocks) I think given these they are roughly equivalent, with the added benefit (at least IMHO) that the side-effectful/monadic actions are very clearly marked even at a syntactic level
shirogane86x··on Rust Survey 2021 Results
To be honest, and maybe I'm just an outlier... As someone who uses Haskell for most of my personal stuff (sadly, not for work), I really don't mind the complexity. Haskell98 is... nice, at best, but it lacks a lot for me to be truly pleasant. GHC Haskell with extensions however I find a pleasure to use, and I've always felt like the complexity was well placed, right where I wanted it or needed it. Rust is also nice, but for me personally the extra features are just making it better, not worse.
← PreviousPage 3 of 4Next →