Re: Symbolic computations in D

2023-11-25 Thread Dmitry Ponyatov via Digitalmars-d-learn

What are semantic limitations you talking about?


lack of pattern matching as example, which can tend to lots of 
ugly code




Re: Symbolic computations in D

2023-10-30 Thread jmh530 via Digitalmars-d-learn

On Monday, 30 October 2023 at 13:24:56 UTC, Sergey wrote:

On Monday, 30 October 2023 at 13:13:47 UTC, jmh530 wrote:

On Sunday, 29 October 2023 at 10:44:03 UTC, ryuukk_ wrote:
Julia is more an alternative to R, Matlab, Python than C++.


Not really.

Many especially popular and widely used (NumPy, PyTorch, 
data.table) libraries for R and Python implemented with C/C++. 
Without using them, it is just impossible to get good 
performance.


So there is "2 language" problem. Someone should create C++ 
engine + Python/R interface.
Julia propose to solve this issue - since you are able to 
implement fast engine and interface both in Julia.


There are aspects of Julia that are certainly nice. I'm just 
saying that most users of Julia would be more likely to use that 
instead R/Matlab/Python, rather than instead of C++.


There are probably many areas where with R or Python, you would 
normally implement it with C or C++, whereas with Julia you could 
probably do just as well with raw Julia. However, that's not to 
say that Julia doesn't also rely on that same approach when it is 
beneficial. For instance, it can use standard BLAS/LAPACK 
libraries [1] for linear algebra that are written in C.


There's nothing really wrong with that. They shouldn't re-write 
the wheel if there is already a highly performant solution.


[1] https://docs.julialang.org/en/v1/stdlib/LinearAlgebra/


Re: Symbolic computations in D

2023-10-30 Thread Sergey via Digitalmars-d-learn

On Monday, 30 October 2023 at 13:13:47 UTC, jmh530 wrote:

On Sunday, 29 October 2023 at 10:44:03 UTC, ryuukk_ wrote:
Julia is more an alternative to R, Matlab, Python than C++.


Not really.

Many especially popular and widely used (NumPy, PyTorch, 
data.table) libraries for R and Python implemented with C/C++. 
Without using them, it is just impossible to get good performance.


So there is "2 language" problem. Someone should create C++ 
engine + Python/R interface.
Julia propose to solve this issue - since you are able to 
implement fast engine and interface both in Julia.


Re: Symbolic computations in D

2023-10-30 Thread jmh530 via Digitalmars-d-learn

On Sunday, 29 October 2023 at 10:44:03 UTC, ryuukk_ wrote:

[snip]

This is sad that people recommend OOP for this

Julia doesn't have OOP and it took over, and that's what i'd 
recommend your students to check, C++ is a dead end, Julia it 
is for mathematical computing


If D had tagged union and pattern matching, it would be a great 
candidate to succeed in that field


Julia is more an alternative to R, Matlab, Python than C++.


Re: Symbolic computations in D

2023-10-29 Thread bachmeier via Digitalmars-d-learn

On Sunday, 29 October 2023 at 08:55:24 UTC, Dmitry Ponyatov wrote:


Maybe someone played in this topic, and can give some advice:
is D language with its OOP without multiple inheritance and 
maybe other semantic limitations able and good enough to be 
used with these books mechanics?


The theme looks complex off the shelf, and I'm not sure to 
speak about D to this above student, especially I myself can't 
help him anyway not knowing the language in deep.


Outside of the most basic functionality, this is only the type of 
thing you'd want to do if you're willing to put years into it. 
There are many such systems out there already. It looks like 
GiNaC (C++) might be their best choice. But note that even that 
library does not do the more advanced stuff.


https://www.ginac.de/tutorial/

https://www.ginac.de/tutorial/#Disadvantages


Re: Symbolic computations in D

2023-10-29 Thread evilrat via Digitalmars-d-learn

On Sunday, 29 October 2023 at 10:44:03 UTC, ryuukk_ wrote:


If D had tagged union and pattern matching, it would be a great 
candidate to succeed in that field


Well, we sort of have it, just not as good as it can be.

https://dlang.org/phobos/std_sumtype.html

The default example though makes it look like it works only with 
SumType, here is another example from godot-d where match 
compares on types.


``` d
static Variant from(T : GodotType)(T t) {
import std.sumtype : match;

Variant ret;
t.match!(
(Variant.Type t) { ret = cast(int) t; },
(BuiltInClass c) { ret = c.name; },
(Ref!Script s) { ret = s; }
);
return ret;
}
```

Of course there is also third-party libraries that claims to be 
"doing it right".


Re: Symbolic computations in D

2023-10-29 Thread ryuukk_ via Digitalmars-d-learn

On Sunday, 29 October 2023 at 08:55:24 UTC, Dmitry Ponyatov wrote:
Yesterday some student asked me about ability to make some dumb 
symbolic computation in C++ the same like way as it looks in 
the MathCAD or Maxima CAS, but run it compiled on a robot 
platform in realtime.


I have no idea about CAS design and internals, or any math at 
all, but today I found some book:

- _Tan Kiat Shi, Willi-Hans Steeb and Yorick Hardy_
**SymbolicC++: An Introduction to Computer Algebra using 
Object-Oriented Programming

and**
- **Computer Algebra with SymbolicC++**

with the same autors (looka like an alias book from another 
publisher)


Maybe someone played in this topic, and can give some advice:
is D language with its OOP without multiple inheritance and 
maybe other semantic limitations able and good enough to be 
used with these books mechanics?


The theme looks complex off the shelf, and I'm not sure to 
speak about D to this above student, especially I myself can't 
help him anyway not knowing the language in deep.


This is sad that people recommend OOP for this

Julia doesn't have OOP and it took over, and that's what i'd 
recommend your students to check, C++ is a dead end, Julia it is 
for mathematical computing


If D had tagged union and pattern matching, it would be a great 
candidate to succeed in that field


Re: Symbolic computations in D

2023-10-29 Thread evilrat via Digitalmars-d-learn

On Sunday, 29 October 2023 at 08:55:24 UTC, Dmitry Ponyatov wrote:

Maybe someone played in this topic, and can give some advice:
is D language with its OOP without multiple inheritance and 
maybe other semantic limitations able and good enough to be 
used with these books mechanics?


You can have multiple interfaces, and interfaces can have default 
implementation for its methods.
What really prohibited is to have multiple base classes as this 
will over complicate data layout and the compiler without much 
benefit (if any at all).


What are semantic limitations you talking about? D is much more 
expressive than C++, there is also CTFE and code generation with 
mixins.


Mixins can do pretty much anything preprocessor can, except they 
can't inject self-invocable code, you always need an explicit 
"mixin(foo)" statement, and that's the only limitation compared 
to preprocessor.

IIRC Vibe.d using them for template engine.

Also D has raw strings, just like this
https://github.com/buggins/dlangui/blob/master/examples/dmledit/src/dmledit.d#L73

Which again with mixins can be turned into DSL(domain specific 
language),
with this you can write your own template that parses that string 
and for example builds a widget tree out of it, like this

https://github.com/buggins/dlangui/blob/master/examples/helloworld/src/helloworld.d#L20


Symbolic computations in D

2023-10-29 Thread Dmitry Ponyatov via Digitalmars-d-learn
Yesterday some student asked me about ability to make some dumb 
symbolic computation in C++ the same like way as it looks in the 
MathCAD or Maxima CAS, but run it compiled on a robot platform in 
realtime.


I have no idea about CAS design and internals, or any math at 
all, but today I found some book:

- _Tan Kiat Shi, Willi-Hans Steeb and Yorick Hardy_
**SymbolicC++: An Introduction to Computer Algebra using 
Object-Oriented Programming

and**
- **Computer Algebra with SymbolicC++**

with the same autors (looka like an alias book from another 
publisher)


Maybe someone played in this topic, and can give some advice:
is D language with its OOP without multiple inheritance and maybe 
other semantic limitations able and good enough to be used with 
these books mechanics?


The theme looks complex off the shelf, and I'm not sure to speak 
about D to this above student, especially I myself can't help him 
anyway not knowing the language in deep.