Live data from Hacker News

Functional programmers need to take a look at Zig

pure-systems.org

151–160 of 163 posts

Re: Functional programmers need to take a look at Zig

#151

Earlier quoted context omitted.

"slightly different ways to initialise stuff." can you elaborate? theres only what 11 datatypes in elixir?

Perhaps they are referring to the syntactic sugar around keyword lists? [a: 1, b: 2] == [{:a, 1}, {:b, 2}] Or maybe atom vs string keys in maps? %{a: 1} vs %{"b" => 1} Or keyword lists always needing to come last in lists? [some: :value, :another] # error [:another, some: :value] # valid Or maybe something else entirely. Those are just things I remember having to lookup repeatedly when I was first learning elixir.

completely reasonable. eventually you internalize them, and the rules aren't that bad and are consistent.

Re: Functional programmers need to take a look at Zig

#152

Earlier quoted context omitted.

idk in elixir we basically do exactly whats happening with io parameters when mocking or swapping implementations that all satisfy the same behaviour. here. i am not the only one that refers to it as dependency injection: https://daily.dev/blog/zig-async-io-io-uring-zig-0-16-rethin... "Zig 0.16 introduces std.Io, a flexible I/O abstraction that uses dependency injection, similar to the Allocator interface"

Sigh. I meant that the zig authors did not make it a general pattern and just slapped on the DI pattern specifically for io, instead of generalising the abstraction so people can DI stuff.

it's a general pattern. Allocators use the exact sane vtable mechanism. It's not like first class or anything, but that's fine: its enough of a pain in the ass to set it up that you dont start doing BeanFactoryFactory everywhere

Re: Functional programmers need to take a look at Zig

#153

Earlier quoted context omitted.

because you're not reaching for elixir when you need performance. btw we do sometimes bitch about performance :)

But then we have ports/NIFs etc that shell out to Rust & Zig ...

> NIFs that shell to zig

I'm aware

Re: Functional programmers need to take a look at Zig

#154

My stack today is kinda nice but perhaps a bit odd: - Go - backend + CLIs - TypeScript - fronted, occasionally zx for more complex scripts - Nushell as my scripting language (I’ve been relentlessly using it everywhere I can instead of bash/zsh and man it is such an improvement) I heard so much good stuff about both Zig and Rust and would love to eventually get to know one of them.

nushell + 1. After ~20 years of bash+zsh, I'm translating all my scripts to nu. Yesterday I noticed I still don't know how to write ls | where modified in zsh after all years.

   find . -type f -mtime +21 -delete
Or if you have fd

   fd -t f --changed-before 3w -X rm

Re: Functional programmers need to take a look at Zig

#155
post #93

Earlier quoted context omitted.

Nushell, from their website, looks a lot like PowerShell's idea of a shell, but less verbose.

PowerShell is not really that much more verbose. This is the equivalent of the nushell command by crabsand. dir | ? LastWriteTime -lt (Get-Date).AddDays(-21) | del

Too much casing changes, IMO

Re: Functional programmers need to take a look at Zig

#156

Earlier quoted context omitted.

PowerShell is not really that much more verbose. This is the equivalent of the nushell command by crabsand. dir | ? LastWriteTime -lt (Get-Date).AddDays(-21) | del

Too much casing changes, IMO

Sorry. Fixed it for you.

  dir | ? lastwritetime -lt (get-date).adddays(-21) | del
PowerShell is not case sensitive (but nushell and bash are).

Re: Functional programmers need to take a look at Zig

#157

Earlier quoted context omitted.

> using SpringBoot well there's your answer, isn't it?

This is both a fair response and isn’t! The OP was talking about typical Java stuff you’ll encounter, which is overwhelmingly spring boot. But I also agree that you can do much better than that for resource usage if you’re willing to avoid the common defaults the community has embraced.

I agree, but it's still frustrating. There are a lot of red flags / contradictions in the post above which are typical of such debates. E.g.

> Java is a resource hog when you use patterns and libraries popular in Java land

Which java land. The java 8.0 land which is all about design pattern hell? Or modern java in 2026 which is largely about terseness and functional programming? From the tone, they're referring to the former.

> Deployment is super simple in Go, upload a single cross compiled binary it's done

To me this just sounds like OP is unaware of simple things like jlink or jpackage, and their idea of deploying a java application probably involves launching an IDE.

> But when you'll code the same thing in Go using the same method

Same method would mean using "Springboot for Go". Or, conversely, doing a clean implementation in pure java or with equivalent lightweight libraries. If all you want to do is basic calculations, you don't compare using a computer to a calculator and then complain the computer is heavy and slow to boot.

I agree and appreciate that there's a lot of legacy bloated java libraries out there which are "popular" and possibly for the wrong reasons, and that this is a problem. But, that aside, they're comparing building a bespoke lightweight tool from scratch in a language they enjoy, to using a bloated framework they can't be bothered to fine-tune on a language they associate with pre-2000 patterns. Just say you're more familiar with Go than modern Java and enjoy it more and leave it at that. Java has made great leaps into becoming a very beautiful language recently, and biased rants like this aren't helping.

Re: Functional programmers need to take a look at Zig

#158
post #103

I am still hearing about Monads, but is it not the case that they have well-known flaws? And that is the reason why algebraic effects are interesting, because they don't have these flaws?

Monads are a math/organization pattern. What flaws do you mean?

See the comment by mmaniac.

Re: Functional programmers need to take a look at Zig

#159
post #49

Earlier quoted context omitted.

I went the same way but with only using Lisp dialects like Elisp and Clojure and Nix. Although I would ditch Nix too if another Lisp could supplant it too.

Obvious follow-up that's begging to be asked -- if you like nix and want a lisp, have you tried guix/guile?

I see good use cases for both projects, but I found the Nix ecosystem to be friendlier with non-free software and a thrill to work with on MacOS.

The robust and immutable functional paradigm, especially with Determinate Flakes, overlaps enough with mindset of the language that brought me to Lisp in the first place (Clojure).

Re: Functional programmers need to take a look at Zig

#160
post #89

Earlier quoted context omitted.

I went the same way but with only using Lisp dialects like Elisp and Clojure and Nix. Although I would ditch Nix too if another Lisp could supplant it too.

Elisp and Common Lisp for me, although I still use bash in the terminal.

I use nushell for the terminal, but it's too nu for LLMs expecting a normal shell. I use blesh to rice my bash shell and it's even better than my Nu experience sometimes.

I think going back to the fundamentals and revisiting what works is a luxury developers have in the post AI era. Lisp is decades olds, but Paul Graham called it the Maxwell Equations of PLs for a very good reason. Uncle Bob holds it in high regard as well, and the future of the industry could be very fruitful applying their wisdom.

Post reply on HN