Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
sjrd
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
8 ms
·
31.
▲
by
sjrd
1y ago
Float to double conversion is safe. The thing that's not safe in your example is to write `0.3f` (or `0.3d`) in the first place. The conversions from decimal to float or double is unsafe (inexact) and gives different results from flo
32.
▲
by
sjrd
1y ago
Always... except when you're actually writing floating point operations. If I'm implementing `sqrt`, I'd better make sure the result is exactly the expected one. Epsilon is 0 in all my unit tests. ;)
33.
▲
by
sjrd
1y ago
Signed ints are also the integers mod 2^n. The beauty of modular arithmetics is that it's all equivalent. At least for all the operations that work in modular arithmetics in the first place. They just have different canonical represe
34.
▲
by
sjrd
1y ago
The trick is to call the latter GCC. Much less confusing. ;-)
35.
▲
by
sjrd
1y ago
It's acceptable. Meanwhile 5.6MB of Wasm is about the size of the entire test suite of Scala.js. :-p GraalVM is excellent technology, but when it comes to targeting Wasm, I believe the core language compilers will always have an edge.
36.
▲
by
sjrd
1y ago
The spec mandates normalization of NaNs in ArrayBuffers. If other engines do not normalize, I believe it's a bug in those engines!
37.
▲
by
sjrd
2y ago
We actually proved correctness of the fast Long division of Scala.js using similar reasoning. [1] We had mechanical proofs for the other operations, but the solver couldn't handle division. The interplay between bit vector semantics an
38.
▲
by
sjrd
2y ago
Scala solves the primitives-in-generics, and it significantly improves on the array-hates-generics. So it's possible.
39.
▲
by
sjrd
2y ago
(I don't work on Moonbit, but I am a compiler engineer.) > It's not really a compiler, but a transpiler to WAT. That's still a compiler. What do you think many languages' early compilers were doing when they compiled
40.
▲
by
sjrd
2y ago
Oh shoot, yes. I have imitation copies of the original game graphics in there, and so I can't make it public without violating copyright of their assets. :-( Here is a public gist with the `Result` data structure, as well a good portio
41.
▲
by
sjrd
2y ago
The way I did this was to design a more-or-less monadic container `Result<A>` for all my game logic functions. It batches a sequence of animation steps with a result. It can also model error conditions (like not having enough resource
42.
▲
by
sjrd
2y ago
Huh? I teach a first year programming course. I often reply to questions with "let's see if the compiler lets us do that" or "let's quickly search how to do that". We do this in our regular job. It makes sense
43.
▲
by
sjrd
2y ago
The Scala.js compiler toolchain has been using similar techniques since 2015 by default. It features parallel and incremental whole-program optimizations, so it is also used for release builds. In fact it's so fast we run most advanced
44.
▲
by
sjrd
2y ago
Even the component model has nothing to say about the concept of methods. All you have are top-level functions with immutable arguments and immutable results. You can't hold on to an instance of an object created by the other language.
45.
▲
by
sjrd
2y ago
I develop the Scala-to-Wasm compiler, and also maintain the JVM backend of Scala. I can tell you that Wasm is very different from JVM bytecode. The fundamental difference is that the JVM bytecode has an object model . When they talk to eac
46.
▲
by
sjrd
2y ago
And it's so convenient, too! No letter thus requires several syllables to be pronounced. It's one thing I keep using from Belgian French despite having lived in Switzerland for over a decade, because it's objectively better.
47.
▲
by
sjrd
2y ago
> Is there are proper French spelling for that pronunciation? Like how h is aitch in English. No, French doesn't have spelling for the name of letters. (I'm a native French speaker.)
48.
▲
by
sjrd
2y ago
> Projects like Hoot (Scheme) and Kotlin port are already demoing such things. And Scala.js has shipped it. [1] Although technically experimental, it has no known bugs and it has full support of things like manipulating DOM objects from
49.
▲
by
sjrd
2y ago
I've been following that proposal closely, and even (unsuccessfully) tried to contribute suggestions to it. I think what's killing it is that the authors of the proposal won't accept arbitrary values as fields of R/T, bu
50.
▲
Scala.js 1.17.0 released, with experimental WebAssembly support
(scala-js.org)
3 points
by
sjrd
2y ago
|
0 comments
51.
▲
by
sjrd
2y ago
It's a bit between the two, really. There are typically still JavaScript helpers in the middle, but not for the reason most people think. The remaining reason is that Wasm cannot perform JavaScript method calls (with a receiver objec
52.
▲
by
sjrd
2y ago
The correct answer to that question would be the Logarithm. 32 can be divided 5 times by 2 before it becomes 1 and you can't divided it anymore. I think the phrasing of the question is incorrect. That's the only question I got wro
53.
▲
by
sjrd
2y ago
This is what we did for Mozart/Oz [1]. We have a compiler for "proto-Oz" written in Scala. We use it to compile the real compiler, which is written in Oz. Since the Scala compiler produces inefficient code, we then re compil
54.
▲
by
sjrd
2y ago
It's not every day that we see Oz mentioned here! I was very involved in writing the Mozart/Oz 2.0 VM. I also wrote a "toy" (read: for school) dialect of Scala compiling to Oz and therefore turning every local variable o
55.
▲
by
sjrd
2y ago
I sampled about 20 questions and got them all right. I guess it helps to be author of a compile-to-JavaScript language. That gives way more knowledge about the tricky spec corner cases. Knowing these things is less useful for a JavaScript p
56.
▲
by
sjrd
2y ago
IMO most proposed changes to teaching using AI are misguided. My philosophy regarding AI copilots and teaching is: as calculators are for those who already know how to compute, so are AI copilots for those who can already develop software.
57.
▲
by
sjrd
2y ago
OK it seems they changed the doc since. In the docs for JDK 21 we read instead [1]: > If MULTILINE mode is not activated, the regular expression ^ ignores line terminators and only matches at the beginning of the entire input sequence. T
58.
▲
by
sjrd
2y ago
`$` does mean end of input in Java, unless you explicitly ask for multiline mode. In the latter case it means `(?=$|\n)` if also in Unix-lines mode, and the horrible `(?=$|(?<!\r)\n|[\r\u0085\u2028\u2029])` otherwise. I wrote a compile
59.
▲
by
sjrd
3y ago
I disagree. The landscape has significantly evolved into incremental compilation techniques in the past decade. While theoretical developments are mostly confined into parsers, practical implementations do it across the entire pipeline, all
60.
▲
by
sjrd
3y ago
This looks very interesting. One question: would I be able to develop a game using my favorite compile-to-JS language? Or would the game infrastructure force me to use TypeScript?
More ›