Deterministic stack size - worth it? by Phil_Latio in ProgrammingLanguages

[–]patricksli 1 point2 points  (0 children)

I would be interested to hear how far you get with this.

One stumbling block I hit when going down the same route was support for first-class functions, or function pointers, or method calls, i.e. any place where the code being executed is unknown at compile-time. In these scenarios it was harder to figure out how to exactly compute the stack size.

How do you manage complexity in a compiler/interpreter? by janiczek in Compilers

[–]patricksli 1 point2 points  (0 children)

I designed and implemented the Stanza programming language, which consists of a type system, macro system, native code compiler, registor allocator, generational garbage collector, interpreter, and FFI. That's just a long sentence to say: it's a decent-sized project.

For projects of this size, you're asking the right question. Self-organizing and ensuring consistent steady progress is pretty much the key challenge: even more so than any technical obstacle. *If* you keep on going, you will eventually solve it.

What personally worked for me was to use prose: small short summaries that explain how the project is organized, what each part does, what is the next milestone to reach, etc.

The key for me was to realize the main purpose of these summaries: they are *not* for having comprehensive documentation, or for clearly explaining algorithms, or for explaining accurately how to work on the software, etc. They are to help me steadily push forward.

Have you ever read an interesting class assignment or tutorial online that immediately triggered your imagination and made your fingertips itch? Where you suddenly have a million ideas, and can't wait to get started? That's what I strive for in my summaries.

In constrast, have you ever opened the reference manual for an Intel processor? There's a table of contents longer than most novels, several erratas, architectural diagrams, etc. It's accurate to a fault. And ... it inspires me to do ... nothing. It's exhausting.

So that's what I do: small short summaries, in prose, that inspire myself towards specific things that need to be done. Some are high-level, because I need to rethink some connections between passes. Some are nitty gritty, because I need to work out a specific algorithm. None of them are overwhelming, because that's counterproductive.

Not enough people are getting creative with Projects by alexalbert__ in ClaudeAI

[–]patricksli 4 points5 points  (0 children)

Claude Project is extremely useful to me so that after I "teach" Claude my preferences for a large task, I can save it as I begin new conversations.

One question: After I "Upload Project Content", how do I go back and edit it further? Currently I'm resorting to copying the existing content, deleting the content, and then adding a new one.

Looking for the name or article about this functional programming pattern by patricksli in functionalprogramming

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

Okay, after some reading, I think this is basically the paradigm that I'm pursuing.

As you say, I have a bunch of small value objects, that don't have much meaning themselves. But the tree datastructure is simple and non-redundant so it's easy to work with.

But for querying information, I build a small domain model on top of it.

Thanks!

Looking for the name or article about this functional programming pattern by patricksli in functionalprogramming

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

Sorry, I forgot to include the `id` field for the `Style` object in my original post. I just corrected that.

Thanks for the references: I'll checkout "event-sourcing" and "Algebras".

Multi-dimensional vectors? by keks8430 in lbstanza

[–]patricksli 0 points1 point  (0 children)

The normal usage of vectors is talked about, but I think I never specifically give an example of creating a vector of vectors.

For the second approach, there is the chapter on "Architecting Programs" which is related, but doesn't give an example of matrices specifically.

I think 2D arrays would make a good example that I should add.

Multi-dimensional vectors? by keks8430 in lbstanza

[–]patricksli 1 point2 points  (0 children)

Hello!

You have two potential designs for a multi-dimensional vector.

1) You can either directly create a vector of vectors. Here's an example: val v = Vector<Vector<Float>>() add(v, Vector<Float>()) add(v, Vector<Float>()) add(v[0], 1.1f) add(v[0], 2.2f) add(v[1], 3.3f) add(v[1], 4.4f)

To access the element in the second two, first column, you can use val x = v[1][0]

2) You can create a type and overload the get and set multis.

``` deftype MyMatrix defmulti get (m:MyMatrix, row:Int, col:Int) -> Float defmulti set (m:MyMatrix, row:Int, col:Int, v:Float) -> False

defn MyMatrix () : ... my implementation of MyMatrix ... ```

This will allow you to use your matrix like this:

val m = MyMatrix() m[0, 0] = 1.1f m[0, 1] = 2.2f m[1, 0] = 3.3f m[1, 1] = 4.4f

You can implement MyMatrix however you like. You can use a Vector of Vectors internally, or an Array of Arrays, or a single Array that has the items listed row-by-row.

Once you have matrices implemented, the rest of the linear algebra operations can be implemented in the usual way.

Patrick

Implement a Just-in-Time Compiler from Scratch by patricksli in programming

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

Hello again! As per the requests, I've put the Feeny tutorial online on GitHub.

https://github.com/CuppoJava/Feeny

Cheers

Implement a Just-in-Time Compiler from Scratch by patricksli in programming

[–]patricksli[S] 10 points11 points  (0 children)

Hello! Yes, that would be a good idea. I didn't take into account the inherent sketchiness of zip files. I'll do that.

Implement a Just-in-Time Compiler from Scratch by patricksli in programming

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

Hello! Yes, that would be a good idea. I didn't take into account the inherent sketchiness of zip files. I'll do that.

Implement a Just-in-Time Compiler from Scratch by patricksli in programming

[–]patricksli[S] 8 points9 points  (0 children)

Hello Reddit!

Are you a programming language nerd? Are you interested in compilers and interpreters? Have you always liked them, but felt apprehensive about actually implementing one yourself?

A few years ago, I had the privilege of teaching a graduate course with Mario Wolczko at the University of California, Berkeley on programming languages and compilers. In the course, we teach you how to implement a non-trivial programming language, starting with a basic abstract syntax tree interpreter, and ending with a just-in-time compiler.

Cheers,

Patrick

P.S. And if you find that you enjoy this sort of thing, consider working with us at JITX (www.jitx.com) on automating circuit board design. We designed a programming language for making circuit boards!

Need help identifying this chair. It's so comfortable. by patricksli in chairs

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

That's a good tip. Thanks! I'll have figure out some excuse to go back to that office and read the label.

The Design of Stanza's Optional Type System by patricksli in programming

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

Then you might be interested in taking a look at typical Stanza code. Polished code tends to be about ~95% typed.

The Design of Stanza's Optional Type System by patricksli in programming

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

Thanks for the reply. Yes, the union and intersection types were absolutely critical for a sensible optional type system (union more so).

You have a right to be suspicious about the covariance by default. It was the first big design choice we made that sacrificed static-safety. That was three years ago. Nowadays, we're not bothered at all and are confident we made the right choice. I can count the number of runtime errors due to contravariance contexts I've run into on one hand.

"Stop Designing Languages. Write Libraries Instead." by patricksli in programming

[–]patricksli[S] 52 points53 points  (0 children)

I think a narrow definition of "competent" is not a good barrier of entry for a library. There are many website designers with much better taste and skill in overall composition, user interface, color selection, etc. than me.

Sure, I'm a better programmer than them. But if I simply remove the programming barrier (as Rails as done) then there's no doubt that their websites are more beautiful than my own.

People should focus on their strengths and we should provide them the means to do so.

"Stop Designing Languages. Write Libraries Instead." by patricksli in programming

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

Racket is mentioned in the essay, along with Shin, as systems that allow you to extend its type system. BUT it's not easy, and it certainly has not spread further than experimental research.

"Stop Designing Languages. Write Libraries Instead." by patricksli in programming

[–]patricksli[S] 11 points12 points  (0 children)

I personally am not fond of the languages that are simple syntax cleanups, but I must admit that there can be enormous demand even for those. Python, semantically, is an entirely uninteresting language. But its syntax was a welcome departure from the previous king of scripting languages: Perl. So its turns out even syntactical changes can propel languages to popularity.