~bubnenkoff

Recent activity

Why Hare app is x3 times slowly than Dart? 18 days ago

From Dmitry B to ~sircmpwn/hare-users

I've decided to compare Hare app and the same app written on Dart.
Both are compiled. Both have the same logic (as far as I can see). But
hare app is x3 time slowly than Dart.

```dart
import 'dart:io';

void main() {
  File inputFile = File('in.xml');
  List<String> lines = inputFile.readAsLinesSync();

  List<String> updatedLines = lines.map((line) =>
line.replaceAll('ns', '')).toList();

Is Valgrind working with Hare? Or any way to analyze memory uage 19 days ago

From Dmitry B to ~sircmpwn/hare-users

I am just learning system programming. I have never used any tools for
analytics of memory usage.

So I have two question:
1. Is Valgrind works with Hare? I do not know how it works but it did
not showed unfreed memory in my hare app.
2. Is it enough to log size of every memory allocated in heap to get
an understanding how much app use RAM?

For example here:

export fn main() void = {

   const file = os::open("app.ha")!;

Assertion `tagged->storage == STORAGE_TAGGED' failed 19 days ago

From Dmitry B to ~sircmpwn/hare-users

use fmt;
use io;
use bufio;
use memio;
use os;
use fs;
use strings;
use types;
use encoding::utf8;

export fn main() void = {

   const file = os::open("app.ha")!;
   const file_scan = bufio::newscanner(file, types::SIZE_MAX);

Naming question: Why type 'off' is 'i64'? 20 days ago

From Dmitry B to ~sircmpwn/hare-users

What is the logic behind this naming?

https://docs.harelang.org/io#off

Re: how to write buffer in teestream? 21 days ago

From Dmitry B to ~sircmpwn/hare-users

I decided that I should try to do read operation from handler:

export fn main() void = {

   const dyn_handler = memio::dynamic();

   const file = os::create("out.txt", fs::mode::USER_RW)!;
   const ttt = io::tee(&dyn_handler, file); // create teestream

   const line = bufio::read_line(os::stdin)! as []u8;
   io::write(&ttt, line)!;
   const r = io::drain(&dyn_handler);
};

Re: how to write buffer in teestream? 21 days ago

From Dmitry B to ~sircmpwn/hare-users

export fn main() void = {

   const input = os::stdout;
   const file = os::create("out.txt", fs::mode::USER_RW)!;
   const ttt = io::tee(input, file); // create teestream

   const buf = strings::toutf8("hello");
   io::write(&ttt, buf)!;

   // which copies writes and **reads** into 'sink'
   const res = io::drain(&ttt); // is it reads operation?
   // if yes then why no hellohello in out.txt?
};

Re: how to write buffer in teestream? 21 days ago

From Dmitry B to ~sircmpwn/hare-users

Oh... It seems that I was need to use:
const input = os::stdout; // not stdin

ср, 31 янв. 2024 г. в 13:02, Dmitry B <bubnenkoff@gmail.com>:
>
> use fmt;
> use io;
> use bufio;
> use memio;
> use os;
> use fs;
> use strings;
>
> export fn main() void = {

how to write buffer in teestream? 21 days ago

From Dmitry B to ~sircmpwn/hare-users

use fmt;
use io;
use bufio;
use memio;
use os;
use fs;
use strings;

export fn main() void = {

   const input = os::stdin;
   const file = os::create("out.txt", fs::mode::USER_RW)!;
   const ttt = io::tee(input, file); // create teestream

How to represent stream as []u8 23 days ago

From Dmitry B to ~sircmpwn/hare-users

Hello! Thanks for help, but I have new problem.
I can't figure out how to represent stream as u8.

Here is my example:

use fmt;
use io;
use bufio;
use memio;
use os;
use fs;
use strings;

export fn main() void = {

What do keyword `as`? 23 days ago

From Dmitry B to ~sircmpwn/hare-users

I am reading docs https://docs.harelang.org/bufio#read_line
Signature of function is next:
fn read_line(file: io::handle) ([]u8 | io::EOF | io::error);

But follow code is reqired using `as` keyword to get it's compiled:

use fmt;
use io;
use bufio;
use memio;
use strings;

export fn main() void = {