
Emu: Language for Programming GPUs in Rust - adamnemecek
https://github.com/calebwin/emu
======
pitaj
I have several questions:

1\. What exact syntactic differences does this have from rust, and why?

Some differences I see are in function definitions: lack of `fn` keyword, `->`
for function return type, and colons for parameter types.

2\. How does this make use of the borrow-checker, if at all?

3\. Who is the target audience? Is it meant for general mathematical
acceleration or graphics?

It seems to be meant for scientific purposes, seeing as it provides a system
of units and constants.

~~~
fluffything
AFAICT this does not really use Rust, or the Rust type system at all.

This is just a procedural macro that parses "Rust-like" syntax into an AST,
and then 1:1 fold that AST into OpenCL. This AST is not type checked, and if
you were to, for example, replace the usage of an `u32` in there with a `type
U32 = u32;` then parsing will probably fail, because the proc macro doesn't
know what `U32` means.

The OpenCL code that gets dumped into a byte string, is compiled at run-time
by your graphics driver. The proc macro can probably, at best, try to verify
that it is correct at compile-time, by passing the dump to some OpenCL
verification tool, but it does not appear to be doing that right now.

------
gitgud
A bit off-topic, but it seems articles with "in Rust" or "in Go" tacked on the
end are consistently upvoted to the front-page. I wonder how well this
reflects actual usage of the languages Rust and Go...

~~~
unnouinceput
It doesn't. As a freelancer if I type "rust" on upwork right now I get only 26
jobs. If I type "golang" it yelds 104 jobs. But if I type "php" I get 7966
jobs; "java" = 2547 jobs; C# = 1174 jobs. Even "Assembler" gives 292 results,
more then double of both rust + golang combined. For me Rust / Golang / Swift
are those Instagram "influencers" that the press talk a lot about it but have
little power in the harsh reality of the world.

~~~
adamnemecek
They've been around for a much shorter period of time. Also, maybe upwork
skews toward a different type of jobs.

~~~
unnouinceput
Swift is 5 years old and yields more results then rust who is 8 years old. You
know you have a good one when it picks up and just goes. All of them 3, poor
Rust is the most talked about in HN and yet is the least used in real world.
As for upwork skewing, you really have no idea what upwork is. They have
absolutely zero interest to hide results as their money comes from those jobs
people get hired for. So why would they cut their own revenue?

~~~
wallnuss
It's not about Upwork intentionally skewing the results as you pointed out,
but that there is a potentially sampling bias. Upwork might only attract
certain kinds of programming jobs and those are less likely to use Go and
Rust.

~~~
unnouinceput
Except it doesn't work like that at all. In there you have real problems from
real people who want the job done. If their problem requires Rust, then trust
me, they will ask for Rust. And those are the people who pay the freelancers.
As a freelancer I have zero saying in what clients want, I am there to help
with their problems, not for them to bow before my choice of programming
languages.

------
rjeli
It seems the purpose of rust would be to use the borrow checker for safe
compilation, but this is all in a macro? So the value add of rust here is the
good macro system?

~~~
ajkjk
Well, there's the value add in not having to touch C++...

~~~
fulafel
Indeed. Though there are also other contenders (eg Futhark) in the sane GPU
languages competition.

~~~
auggierose
Interesting: [https://futhark-lang.org](https://futhark-lang.org)

~~~
fulafel
If you want to snack on some Futhark code along with the docs, the Advent of
Code solutions (linked from [https://futhark-
lang.org/blog/2018-12-25-futhark-0.8.1-relea...](https://futhark-
lang.org/blog/2018-12-25-futhark-0.8.1-released.html)) might be a good place
to start. I liked them because they include problems that are not good fit for
Futhark, so it documents how to think about the applicability as well.

