Jump to page: 1 25  
Page
Thread overview
Shopping for template languages
Aug 07
monkyyy
Aug 07
matheus
Aug 07
Sergey
Aug 07
An Pham
Aug 08
matheus
Aug 08
Mike Shah
Aug 08
cc
Aug 08
monkyyy
Aug 08
ryuukk_
Aug 08
Kapendev
Aug 08
monkyyy
Aug 10
IchorDev
Aug 10
IchorDev
Aug 10
ryuukk_
Aug 10
IchorDev
Aug 10
claptrap
Aug 10
ryuukk_
Aug 11
IchorDev
Aug 10
ryuukk_
Aug 10
ryuukk_
Aug 10
Sergey
Aug 12
cc
Aug 12
IchorDev
Aug 14
cc
Aug 14
cc
Aug 14
IchorDev
Aug 14
user1234
Aug 14
IchorDev
Aug 14
user1234
Aug 14
user1234
Aug 14
ryuukk_
Re: Shopping for template languages - tuples
Aug 14
user1234
Aug 15
user1234
Aug 15
ryuukk_
Aug 15
cc
Aug 15
M. M.
August 07

Its important to review decisions every once in a while, so, why am I tolerating d?

Last year my answer was its the best template language, c++ is ugly as sin and compiles slow, rust is even worse. My goal is to be where I believe sanity is and that is extreme metaprogramming on iterators(api between data and functions) preferably ranges(3 functions primitive, relating to for loops; optional extensions for array-like behaviors when possible); with an extensive std pushing the boundaries.

Is that still true?

preemptive responses to ovisous candidates:

go: go only implements generics and is very irritating about "unused code"; generics are not a replacement for template hell.

swift: I worry about the apple connection(even if its weakening) and when I google swift iterators" it seems to be the oo take.

c3: Im unsure how strong ast marcos are? can anyone claim they are as flexable as templates

zig: zig while fantastic, lacks a fundamental piece, metaprogramming

August 07
On Wednesday, 7 August 2024 at 19:44:57 UTC, monkyyy wrote:
> ...
>
> c3: Im unsure how strong ast marcos are? can anyone claim they are as flexable as templates
>
> ...

Never heard of this one, then looking online what I found? A video from Mike Shah reviewing it... Betrayer?

Just joking. =]

Anyway, I wish there was a C version or a D option for auto free after end of scope for memory manually allocated for example.

Matheus.
August 07
On Wednesday, 7 August 2024 at 20:26:07 UTC, matheus wrote:
> Never heard of this one, then looking online what I found? A video from Mike Shah reviewing it... Betrayer?

tsoding videos about C3 are even better =)

August 07
On Wednesday, 7 August 2024 at 20:26:07 UTC, matheus wrote:
>
> Anyway, I wish there was a C version or a D option for auto free after end of scope for memory manually allocated for example.
>
> Matheus.

No need language feature - here is auto free after scope
compile with -debug option

import core.stdc.stdlib : malloc;
import std.stdio : writeln;

struct Foo
{
    int x;
}

struct Owned(T)
{
    this(void* v) nothrow @nogc
    {
        debug writeln("constructor");
        this.v = cast(T*)v;
    }

    ~this() nothrow @nogc
    {
        debug writeln("destructor");
        import core.stdc.stdlib : free;
        if (v)
        {
            free(v);
            debug writeln("free");
        }
    }

    static typeof(this) malloc() nothrow @nogc // same attribute as stdlib.malloc
    {
        return typeof(this)(.malloc(T.sizeof));
    }

    T* v;
    alias this=v;
}

void main()
{
    { // Simulate scope
    auto foo = Owned!Foo(malloc(Foo.sizeof));
    foo.x = 10;
    assert(foo.x == 10);
    writeln(foo.x);
    }

    { // Simulate scope
    auto foo = Owned!Foo.malloc;
    foo.x = 100;
    assert(foo.x == 100);
    writeln(foo.x);
    }
}
August 08
On Wednesday, 7 August 2024 at 21:39:06 UTC, An Pham wrote:
> On Wednesday, 7 August 2024 at 20:26:07 UTC, matheus wrote:
>>
>> Anyway, I wish there was a C version or a D option for auto free after end of scope for memory manually allocated for example.
>>
>> Matheus.
>
> No need language feature - here is auto free after scope
> compile with -debug option
>
> ...

Yes I understand that and by the way I used to do the malloc wrapping in other languages too.

That works, but I would like that as feature by default, because I could be consuming other source/libraries, and that feature would prevent leaking.

We just had a similar problem in C# conuming a PDF generator written in C which on the other hand had a memory leak, in that case since the lib wasn't ours, the cheap way to solve was running it inside a process and killed it.

But thanks again for the example, this obvious could be a nice solution.

Matheus.
August 08

On Wednesday, 7 August 2024 at 19:44:57 UTC, monkyyy wrote:

>

why am I tolerating d?

I really, really like D's templating and metaprogramming. You get the engine bits and wiring in under the hood, and then the front-facing interface is clean and expressive, with a huge amount of the work being done compile-time. It's just way more fun to work in than anything else.

@TABLE("characters")
struct Character {
	enum Class {
		NULL, FIGHTER, KNIGHT, ARCHER, MAGE, HEALER
	}
	enum Elements {
		NONE = 0,
		EARTH = 1<<0,
		AIR   = 1<<1,
		FIRE  = 1<<2,
		WATER = 1<<3,
	}
	@NULLABLE @PRIMARY int id; // auto_increment
	string name;
	@ENUMSTRING @COLUMN("class") Class cClass;
	int rarity;
	@ENUMSTRING Elements elements;
	SysTime mdate;
}

void main() {
	auto db = DBH("chars.db"); // SQLite

	auto table = db.createTable!Character;
	table.insert(Character(name: "Bob", cClass: Character.Class.KNIGHT, mdate: Clock.currTime));
	table.insert(Character(name: "Joe", elements: Character.Elements.EARTH | Character.Elements.FIRE, mdate: Clock.currTime));

	auto sth = db.query("SELECT * FROM characters;");
	foreach (chara; sth.as!Character) {
		writeln(chara.toStringer);
		auto u = chara.updater;
		u.mdate = Clock.currTime;
		db.update(u);
	}
}
Character(id:1, name:"Bob", cClass:KNIGHT, rarity:0, elements:NONE, mdate:2024-Aug-09 00:18:05.457)
Character(id:2, name:"Joe", cClass:NULL, rarity:0, elements:EARTH|FIRE, mdate:2024-Aug-09 00:18:05.465)
sqlite> SELECT * FROM characters;
┌────┬──────┬────────┬────────┬────────────┬───────────────┐
│ id │ name │ class  │ rarity │  elements  │     mdate     │
├────┼──────┼────────┼────────┼────────────┼───────────────┤
│ 1  │ Bob  │ KNIGHT │ 0      │ NONE       │ 1723130285473 │
│ 2  │ Joe  │ NULL   │ 0      │ EARTH,FIRE │ 1723130285482 │
└────┴──────┴────────┴────────┴────────────┴───────────────┘

I'm aching to improve this some more if we could get a fix to allow this:

void foo(Nullable!int d) {}
foo(3); // compilation error
August 08

On Thursday, 8 August 2024 at 15:31:11 UTC, cc wrote:

>

On Wednesday, 7 August 2024 at 19:44:57 UTC, monkyyy wrote:

>

why am I tolerating d?

I really, really like D's templating and metaprogramming.

> >

with an extensive std pushing the boundaries.

I cant mantain 1000 projects, or 100 projects or probably even 12, can I manage 3?. I love the meta programming, but I feel its wasted without major pushes to make generic code.

Templates come at a steep cost I dont think your getting a return if you reuse a block of code 3 times(an over estimation, even filter may not be used in every project), and thats my templates the std and the official style guide wants templates+contracts+formalized interfaces+bureaucracy documents

August 08

On Thursday, 8 August 2024 at 15:31:11 UTC, cc wrote:

>

table.insert(Character(name: "Bob", cClass: Character.Class.KNIGHT, mdate: Clock.currTime));

D needs .ENUM ASAP, this is painful to look at

August 08

On Thursday, 8 August 2024 at 17:15:48 UTC, ryuukk_ wrote:

>

On Thursday, 8 August 2024 at 15:31:11 UTC, cc wrote:

>

Character.Class.KNIGHT, mdate: Clock.currTime));`

D needs .ENUM ASAP, this is painful to look at

Yeah, the .enum syntax in some other languages is nice. Would be nice to have.

>

templates

Nim? Has bad docs, but the templates are a bit scary. You might like it, moonkeyy.

August 08

On Thursday, 8 August 2024 at 19:13:53 UTC, Kapendev wrote:

>

Nim? Has bad docs, but the templates are a bit scary. You might like it, moonkeyy.

I really hate python, and I dont know if ast macros are a replacement for templates but I'm leaning no

« First   ‹ Prev
1 2 3 4 5