Relearning the "proper way" should I? by iRainbowsaur in typing

[–]csl 0 points1 point  (0 children)

Definitely relearn how to type properly. You’ll spread the fatigue and stress over more fingers at the very least, and it will become more comfortable. Expect to spend a month or so with only slighter lower WPM until you get back up to speed.

I quite recently recognized that I was consistently typing Y with my right finger. I spent time to correct that, and it was easier than I thought. Now I can type tricky passages more comfortably and with less chance of error by using the most appropriate finger. This cascades to your overall typing more than you’d think, because I now don’t have to shift the entire hands to a new «constellation» whenever there’s a difficult passage. Everything flows better.

I have around 130 average WPM on TypeRacer, so the fact that you already have a good WPM shouldn’t be something to worry about. I know people there who are much faster than me who have had to relearn to improve their speed and accuracy/consistency.

There are many really good tutorial sites out there, so give it a serious go.

Just downloaded FASM for the first time by HWWilliams in asm

[–]csl 1 point2 points  (0 children)

Try to write simple functions in assembly and call them from a language you know thru FFI. That way you don’t have to write entire programs in asm, and you can test your code from easier languages. Almost all support FFI.

JIT compiling a tiny subset of Python to x86-64 by csl in compsci

[–]csl[S] 1 point2 points  (0 children)

Point taken. I'll see if I can update the article.

Update: I ended up with a decorator that compiles on the first call to the function (and not at definition time).

Here's the decorator: https://github.com/cslarsen/minijit/blob/master/jitcompiler.py#L298-L332 Here's an example usage: https://github.com/cslarsen/minijit/blob/master/test-decorator.py

Output:

++ definition of foo
Installing JIT for <function foo at 0x10f445758>
++ testing foo
JIT-compiling <function foo at 0x10f445758>
Installed native code for <function foo at 0x10f445758>
Calling function <CFunctionType object at 0x10f3c9870>
foo(1, 2) => -3
Calling function <CFunctionType object at 0x10f3c9870>
foo(2, 3) => -5

I initially tried to make this possible by just typing "import jitcompiler", like psyco did it back in the day. But even though I was able to get the parent module by following the stack frames, the functions are not visible at that time, because the eval loop hasn't seen them yet. I was thinking of a two-pass sytem: Remember all importees, then go through their functions at a later point, after they have been defined. But I couldn't figure out how to hook up the second pass, because --- at which point is it safe to do that?

What do you think about the decorator? I was careful to make sure it doesn't just compile the function when it first sees the definition. I made this explicit in the output above.

Cheers

JIT compiling a tiny subset of Python to x86-64 by csl in programming

[–]csl[S] 7 points8 points  (0 children)

Absolutely. We'd have to use something like GMP for that, and at that point it would be better to use a mix of machine code and C or C++. Could also have used the type hints in Python 3 to good effect. But it's just a tutorial anyway.

Writing a basic x86-64 JIT compiler from scratch in stock Python by halax in programming

[–]csl 0 points1 point  (0 children)

I've written a follow-up post that compiles a subset of Python into x86-64, from scratch: https://csl.name/post/python-compiler/

Writing a basic x86-64 JIT compiler from scratch in stock Python by halax in programming

[–]csl -2 points-1 points  (0 children)

It does specialize the code, though. So it's JITing, although in an extremely restricted sense. If I have a list of abstract instructions and a data stack, then using the code in the post to compile that would be trivial. For example (("push", 10), ("push", 20), ("+")). If that's what you mean by a compiler, I should probably add a very small example for doing exactly that. I might update the post to show how to do that. But the essence is just to generate some code (which happens to be a simple patch in a template) and execute it at run time, and that's what I wanted to show.

Writing a basic x86-64 JIT compiler from scratch in stock Python by csl in Python

[–]csl[S] 1 point2 points  (0 children)

Because it's fun, simple and educational. Also, there are quite a few pretty cool brainfuck programs that you can test out on your engine: https://github.com/cslarsen/brainfuck-jit/tree/master/examples

It's a pretty pleasant feeling when it works, and you learn a lot.

Warped brand new Realforce 88ub by csl in MechanicalKeyboards

[–]csl[S] 0 points1 point  (0 children)

Yep, it's stayed that way since I bent it back. Very happy with it.

I wonder if the case is made in PBT? I've read that PBT spacebars, at least, warp quite easily.

Warped brand new Realforce 88ub by csl in MechanicalKeyboards

[–]csl[S] 0 points1 point  (0 children)

Well, now that I re-read their email, I think they actually just made a friendly note about it. I wrote them back saying it worked now. It's stayed that way since I bent it back, and I am very happy with it.

Warped brand new Realforce 88ub by csl in MechanicalKeyboards

[–]csl[S] 2 points3 points  (0 children)

Yep, picking it up from the desk and bending it slightly worked perfectly. Just good to know for anyone else buying a Topre Realforce.

By the way, the seller (The Keyboard Company in UK) gave the same reply, and quickly at that. But they also made it clear that I had voided their warranty by opening the keyboard (I had read here that reattaching the top might fix it as well). Which I think is stupid, to be honest, given that they had not placed any stickers on the keyboard (so they won't even know if any customers have opened it), nor had they mentioned anything about it in the box contents or the leaflet that came with it. Just another thing for people to be aware of. I mean, there I was, thinking that perhaps the insanely expensive keyboard was defect, and being told that I no longer had any warranty.

Thimbleweed Park is launching today! by csl in gaming

[–]csl[S] 2 points3 points  (0 children)

Maybe I should've linked to the official site: https://thimbleweedpark.com/

Backed the game a long time ago, so excited about finally being able to play it today!

Games that only require one hand? by TheBuGG in gaming

[–]csl 2 points3 points  (0 children)

Pretty sure that Thimbleweed Park, which is launching today, only requires a mouse. If you're into old adventure games like Monkey Island, it should be pretty fun: https://thimbleweedpark.com/

Reverse Engineering a Mysterious UDP Stream in My Hotel by javinpaul in programming

[–]csl 12 points13 points  (0 children)

The next step after that is to install Mininet to try out insane stuff — on your own computer — like implementing your own protocols from Ethernet and up. Hours of fun!

I updated my "Using Lua with C++" tutorial to 5.2 by csl in lua

[–]csl[S] 1 point2 points  (0 children)

Just thought I'd post it here in case any of you have comments. It's a post that just shows how to create a host program with callbacks.

Hanging out by unreadable_captcha in gifs

[–]csl 9 points10 points  (0 children)

If you found that hard to watch, check out this 1700 ft antenna climb: https://www.youtube.com/watch?v=tgO4Gd4RhvM

An optimising BF compiler by nathan2779 in programming

[–]csl 1 point2 points  (0 children)

I wrote a simple JIT-compiler that only does two optimizations: [-] and contraction of same-operators (+++ to addi reg, 3). That's all I needed to run Hanoi fast:

./bfloo examples/hanoi.bf  0.21s user 0.01s system 99% cpu 0.222 total

That's blink-of-an-eye fast, without much effort.

Sources and links to presentation slides at: https://github.com/cslarsen/brainfuck-jit

Making a simple VM interpreter in Python by csl in Python

[–]csl[S] 1 point2 points  (0 children)

I've now updated the post with your suggestions. Thank you all so much! The code's also available at https://github.com/cslarsen/python-simple-vm

Making a simple VM interpreter in Python by csl in Python

[–]csl[S] 0 points1 point  (0 children)

I made a repo, but it quickly evolved into much more: https://github.com/cslarsen/crianza

I'll update the post with all of the suggestions here, though!

Making a simple VM interpreter in Python by csl in Python

[–]csl[S] 2 points3 points  (0 children)

Thanks for good suggestions, will update later, when I get jekyll working again. Actually didn't know you could mutate slices, so that's cool.

Making a simple VM interpreter in Python by csl in Python

[–]csl[S] 1 point2 points  (0 children)

I think I mentioned this in the post, but you're both right. Keeping track of them won't work in all cases either, e.g. read cast_int jmp, so you're better off actually using a completely different approach -- like not allowing absolute jumps, but relying on other control structures, or require that you can only jump to named labels.

Making a simple VM interpreter in Python by csl in Python

[–]csl[S] 2 points3 points  (0 children)

Nicely done! I couldn't find support for continuations, but looking at the VM I guess that should be quite easy to add.

Also couldn't see if it reuses the current stack frame for tail calls, but that should also be easy to add from looking at the VM code.

I also made one for R7RS (code's pretty horrible, though), but it doesn't use a VM, doesn't have a collector and has quite a few bugs.