dwyl / learn-zig

🦎 Learn the Zig programming language for fun!
GNU General Public License v2.0
2 stars 0 forks source link

Why? What? Who? How? #1

Open nelsonic opened 1 month ago

nelsonic commented 1 month ago

Intro to the Zig Programming Language β€’ Andrew Kelley β€’ GOTO 2022: https://youtu.be/YXrb-DqsBNU

nelsonic commented 1 month ago

If you're reading this, please don't worry, for now it's just a placeholder. πŸ’­ I definitely don't have time to be learning a whole new programming language ... ⏳ But I will be returning to this in the future. 🀞

ndrean commented 1 month ago

Excellent idea! Zig seems the thing, cross-compilation, compiles C code (cf FFmpeg for Zig

nelsonic commented 1 month ago

@ndrean yeah, we agree. πŸ’‘ πŸ˜‰ A friend of @dwyl is super keen on TigerBeetle which is built in/with Zig. ⚑ We've watched a few videos e.g: youtube.com/watch?v=sC1B3d9C_sI and are very impressed. 😍 It seems considerably easier to learn Zig than Rust (at least on the surface) and equally reliable/performant. 🏎️

Zigler https://hexdocs.pm/zigler/Zig.html -> https://github.com/E-xyza/zigler is actively developed/maintained πŸ™Œ And allows incredible flexibility to run a specific/separate OTP app to execute the Zig functions/programs. Supports Nerves out-of-the-box so if we need to do something "low level" in IoT we can use a NIF.

Getting all the fault-tolerance, observability and developer happiness of Elixir πŸ’§ and being able to use the performance of Zig when we see a bottleneck feels like an awesome combo! πŸ¦Έβ€β™‚οΈ

nelsonic commented 1 month ago

Read this post: https://matklad.github.io/2023/03/26/zig-and-rust.html πŸ‘€

ndrean commented 1 month ago

Thanks for sharing! ❀️ I only skimmed Rust, and when I started to read a bit about async in Rust, I understood Rust was not for me. I am also curious about Go.

In my TO_VIEW list: don't write NIFs

nelsonic commented 1 month ago

Yeah, the 100% agree with not writing NIFs in C! 😬 The biggest danger with NIFs is the "Shiny Object Syndrome" https://en.wikipedia.org/wiki/Shiny_object_syndrome ✨ whereby people start implementing Business Logic in the NIF instead of just a single perf-focussed function! πŸ™ƒ And that is a recipe for chaos if you do it in C where the are no safeguards! 🎲

To-be-clear: C and C++ were the languages I used for years before I got into Web Dev. ⏳ So I would be pretty confident writing NIFs in C ... πŸ€“ But I wouldn't for the simple reason that I don't wan to maintain them! πŸ™…

NIF (Native Implemented Functions) docs: https://www.erlang.org/doc/system/nif.html πŸ”— explains why someone would want to use one if there's a perf bottleneck. πŸ€” i.e. 99% of the time Erlang/Elixir is perfectly performant 🏎️ because the bottleneck in most apps is the Network and Database latency! ⏳

Zig makes a lot of sense for NIFs because the language is easier to learn than Rust https://www.reddit.com/r/elixir/comments/hel3ps/zigler_elixir_ffis_with_zig/

So far I've only noted the technical reasons for learning Zig. But one of my biggest reasons for learning Zig (towards the end of this year), is simple: Career / Employability relevance. A few of my friends working in finance are starting to use Zig. 🏦 Mostly because TigerBeetle https://github.com/dwyl/technology-stack/issues/112

But I suspect it might be the reason a few other people learn Zig: https://survey.stackoverflow.co/2023/#section-top-paying-technologies-top-paying-technologies

stackoverflow-top-paying-tech

Good to see Erlang still in the Top πŸ” (second place after Zig). Ref: https://blog.logrocket.com/comparing-rust-vs-zig-performance-safety-more/ Looking forward to seeing where these languages are in the 2024 survey. Yes, I know this survey data/result is very skewed by having low numbers of respondents for the lower usage languages ... so take everything with a grain of salt. There are still Fortran and COBOL programmers with deep institutional knowledge of their Bank / Gov systems who are earning way more than the Zig average. πŸ™ƒ Same way there are AI/ML engineers at Startup X writing Python and getting paid millions in <options> that will pay-off if their Unicorn gets acquired / goes public ... πŸ¦„ πŸ“ˆ πŸ’°

As usual, I like to be proactive with my learning; I see myself writing Zig in the future. πŸ’­ I definitely will still write Elixir because I still think it's great for network apps! πŸ•ΈοΈ I love the reliability of Elixir. But I know I'm not going to convince any of my Finance friends to use it. πŸ™„

Zig might be the answer for "What Language to Learn Next?"

@ndrean we are currently writing Go on a Project it's going well. πŸ˜‰

nelsonic commented 1 month ago

What's Zig got that C, Rust and Go don't have? (with Loris Cro): https://youtu.be/5_oqWE9otaE @kristoff-it

image

Again, trying not to get sucked into this right now as have lots of work to do. ⏳

nelsonic commented 1 month ago

https://medium.com/@vladimirvivien/things-i-like-about-zig-as-a-go-programmer-75eb02aab00f

ndrean commented 1 month ago

Thanks for sharing! I looked into TiggerBeetle. But banks are so conservative! Do they adopt this? Tbh, I really know nothing about banking IT but I am sure of one thing: safety is above everything.

πŸ’­ So what about building the Elxiir client for TiggerBeetle? You can promote fault tolerance, scalable web app using Elixir, and interface with Zig? With the advance of LiveView native, you could even propose a mobile version, mandatory I imagine ....

I loved this picture

Screenshot 2024-07-15 at 23 24 47
nelsonic commented 1 month ago

Three Side Quests: ⏳

  1. https://github.com/dwyl/learn-tigerbeetle/issues/1
  2. https://github.com/dwyl/learn-phoenix-framework/issues/157
  3. https://github.com/dwyl/technology-stack/issues/141

😬

nelsonic commented 1 month ago

And to answer your question from above: Yes, some banks are ultra-conservative and avoid any tech innovation. πŸ‘΄ I've worked at/for a few and they weren't fun ... 🐌 ⏳ M&Ms ... πŸ™ƒ

But others are always trying to get an edge and invest heavily in their tech/teams! It all depends on how Management/Execs view their Tech:

  1. "IT" is usually viewed as a "Cost centre": https://en.wikipedia.org/wiki/Cost_centre_(business) i.e. to be minimised and as "stable" as possible; change is the enemy as it drives up cost!
  2. "Engineering" is usually viewed as an investment and innovation i.e. a potential "Revenue Centre": https://en.wikipedia.org/wiki/Revenue_center where investing $1 in building something that gives the firm an edge in the market can return $2 and sometimes $100 ... think Goldman or Bridgewater which has been investing heavily in ML for decades! https://www.bridgewater.com/research-and-insights/greg-jensen-on-algorithmic-decision-making-and-artificial-intelligence image

You definitely don't want to work for a company that sees you as a "cost"; they will "downsize" you in a heartbeat. πŸ’” Whereas working somewhere that understands that investing in tech can give a substantial ROI ... You will be appreciated and compensated accordingly.

The companies that are using Zig are doing it for a reason; innovation in team + program performance. πŸš€ They are the early adopters - who similar to early investors - make strategic investments that produce outsized returns!

nelsonic commented 1 month ago

https://ziglang.org/learn/getting-started/

brew install zig
ndrean commented 1 month ago

Just a tip! You drop your image, and make your image clickable and direct it to the location by using [<the result of the drop-in>](https://the origin)

[<img width="1179" alt="Screenshot 2024-07-16 at 09 43 06" src="https://github.com/user-attachments/assets/cfdc4ce7-3c57-4fe9-88ff-d3f9f14aebb1">](https://www.google.com/search?q=youtube+elon+musk+fires&oq=youtube+elon+musk+fires&gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIGCAEQRRhAMgYIAhBFGDwyBggDEEUYPNIBCDQ1NDJqMGo5qAIAsAIB&sourceid=chrome&ie=UTF-8#fpstate=ive&vld=cid:13572b4c,vid:YZWcC7CbOKQ,st:0)
ndrean commented 1 month ago

A non trivial and nicely written paper.

Screenshot 2024-07-16 at 11 35 14

nelsonic commented 1 month ago

Target WebAssembly with Zig: https://dev.to/sleibrock/webassembly-with-zig-part-1-4onm and https://dev.to/sleibrock/webassembly-with-zig-pt-ii-ei7

ndrean commented 1 month ago

A blog on/for Zig

Screenshot 2024-07-21 at 23 10 40

nelsonic commented 1 month ago

Always find it interesting when a Programming Language uses Forem (Ruby on Rails) to power their blog/site ... πŸ’­

zig-news-forem-ruby-on-rails

https://github.com/forem/forem

Clearly the goal was just to get started/going as quick as possible. :shipit: And they aren't concerned about building the news site using Zig. 🦎

nelsonic commented 1 month ago

"Zig came along and it just fixed everything that was wrong with C" Joran Dirk Greef describing why he chose Zig for TigerBeetle: https://youtu.be/ayG7ltGRRHs?t=2400

image

And gives far more safety [than Rust] including checked arithmetic. "You want "checked arithmetic" enabled on mission critical systems ..."