higherhalf

Joined 8 years ago

Karma
99
Submissions
34
Member since
Aug 1
github.com/rbakbashev
View on Hacker News

Recent submissions

Comment · 9 months ago
Thanks, I really should've looked deeper than that.
Comment · 9 months ago
clock_gettime() goes through vDSO, avoiding a context switch. It shows up on the flamegraph as well.
Comment · 1 year ago
Thanks, I looked it up and it's indeed quite ugly, and my shebang isn't portable. A little saddened that even 'env -S' didn't make it to POSIX.
Comment · 1 year ago
Seems a little complicated when you can do:

  //usr/bin/env rustc "$0" && ./config "$@"; exit
Or

  //usr/bin/env rustc --edition 2024 "$0" && ./$(basename $0 .rs); rm $(basename $0 .rs); exit
Comment · 1 year ago
> It doesn't allow you to import `std::iter::Iterator::collect` on its own. It's an associated function, and needs to be qualified.

You probably noticed, but it should become a thing in RFC 3591: https://github.com/rust-lang/rust/issues/134691

So it does kind of work on current nightly:

  #![feature(import_trait_associated_functions)]
  
  use std::iter::Iterator::{filter, map, collect};

  fn get_ids2(data: Vec<Widget>) -> Vec<Id> {
      collect(map(filter(Vec::into_iter(data), |w| w.alive), |w| w.id))
  }  

  fn get_ids3(data: impl Iterator<Item = Widget>) -> Vec<Id> {
      collect(map(filter(data, |w| w.alive), |w| w.id))
  }
Comment · 1 year ago
What makes this a "systems programming language", especially since it has "no pointers or references"?
Comment · 2 years ago
It's not due to a move to AI-enhanced workflows. The article speculates that it's caused by companies wanting to develop AI-related products, moving some workforce and culling the unwilling, just like my employer.
Comment · 3 years ago
This can be done even simpler:

  global _start
  _start:
      jmp next
  string:
      db `Hello World!\n`
  len: equ $ - string
  next:
      mov ecx, string
      mov edx, len
      mov ebx, 1
      mov eax, 4
      int 80h
  
      mov ebx, 0
      mov eax, 1
      int 80h
For NASM, it can also be put into a macro, for example printing to video memory at 0xb8000:

  %macro print 1
      mov ecx, %%loop_start - %%strdata
      mov eax, 0x0700
      jmp %%loop_start
  %%strdata: db %1
  %%loop_start:
      mov al, [%%strdata + ecx - 1]
      mov [0xb8000 + ecx * 2 - 2], ax
      loop %%loop_start
  %endmacro
Comment · 3 years ago
Comment · 3 years ago
They mention git worktrees in the next paragraph.
Comment · 3 years ago
Comment · 3 years ago
> But rust absolutely does not have any C/C++ compatibilty besides [..]

> In zig you _can_ actually start with a c codebase and rewrite it file by file in zig and you _can_ include c headers in your zig files verbatim. Both of these are not possible in rust.

You can. Either via FFI and bindgen-ing headers, or by using c2rust. The latter is not just a toy ambitious project, but actually a very impressive piece of engineering and does produce a result where you can transpile a project or file and start rewriting file-by-file or function-by-function.

Comment · 3 years ago
Excited for threads, sockets, futexes, but not excited for fork, signals and setjmp. They didn't include POSIX stuff like shared memory, select(2), unix sockets, and had to draw a line somewhere. Why include error-prone cruft?

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton