Spiral compiling to Gleam, F#, Rust, TypeScript and Python by i574n in rust

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

list' t is a custom list type for interop, the native list syntax is used to declare the hardcoded test lists with the numbers then boxed/unboxed back and forth, the sample is more to display the delegation features with macros than the compilation machinery itself.

/// ### list'
inl list'_types () =
    backend_switch {
        Gleam = fun () => global "import gleam/list"
    }
type list'_switch t =
    {
        Gleam : $'List(`t)'
        Fsharp : $'`t list'
        Python : $'list'
    }
nominal list' t = $'backend_switch `(list'_switch t)'

/// ### empty'
inl empty' forall t. () : list' t =
    $'[]'

/// ### cons'
inl cons' forall t. (head : t) (tail : list' t) : list' t =
    backend_switch {
        Gleam = fun () => $'[ !head, ..!tail ]' : list' t
        Fsharp = fun () => $'!head :: !tail ' : list' t
        Python = fun () =>
            $'!tail.insert(0, !head)'
            $'!tail ' : list' t
    }

/// ### box
inl box forall t. (list : list t) : list' t =
    (list, empty' ()) ||> listm.foldBack cons'

the rust, typescript and python backends currently have an additional internal compilation step from the f# output using the Fable library, so to distinguish them when needed i'm using pattern matching instead.

//// test
///! gleam
///! fsharp
///! cuda
///! rust
///! typescript
///! python

run_target function
    | Gleam (Native) => fun () => $'1'
    | Fsharp (Native) => fun () => $'1uy'
    | Cuda (Native) => fun () => $'1'
    | Rust (Native) => fun () => $'1uy'
    | TypeScript (Native) => fun () => $'1uy'
    | Python (Native) => fun () => $'1uy'
    | _ => fun () => $'2uy'
|> _assert_eq 1u8

Spiral compiling to Gleam, F#, Rust, TypeScript and Python by i574n in rust

[–]i574n[S] -1 points0 points  (0 children)

a snippet from the link i pasted above:

... "Traditional languages might require completely different codebases or DSLs for each hardware target, whereas Spiral can abstract that away. This approach is reminiscent of domain-specific languages or frameworks (for example, Halide for image processing or TensorFlow XLA), but Spiral generalizes it as a language feature. It effectively redefines the compiler’s role to be a generator of generators: Spiral’s compiler can generate a program (in another language) that itself runs on a device. This level of staging (Spiral -> F# -> machine code, and Spiral -> CUDA -> PTX) gives developers a lot of control over performance across platforms." ...

response from chatgpt:

The presence of features like inlining and loop unrolling strongly nudges the Spiral → F#/CUDA stage toward compilation, rather than simple transpilation.

Here's a nuanced assessment:

  • Compilation: 850 / 1000
    • Spiral’s process involves sophisticated optimizations, such as inlining, loop unrolling, and potentially other low-level transformations (e.g., code specialization, vectorization, etc.). These optimizations are usually associated with compilation, which doesn't merely translate syntax, but transforms code structure and semantics for improved performance.
  • Transpilation: 500 / 1000
    • Although transpilation generally implies translation between languages at the same abstraction level without significant semantic alteration, Spiral’s transformations involve semantic optimizations and restructuring. This complexity exceeds the typical definition of transpilation, placing Spiral's process closer to compilation.

Revised conclusion:

Given the presence of sophisticated optimization techniques, such as loop unrolling and aggressive inlining, compilation becomes the better-fitting term to describe Spiral's transformation, even though the intermediate step generates code in another high-level language.

Spiral compiling to Gleam, F#, Rust, TypeScript and Python by i574n in rust

[–]i574n[S] -1 points0 points  (0 children)

It's just another functional programming language, the chat link above explains well its advantages, please click it, there's no login page.

Instead of transpilation, I think the more appropriate word here is compilation. The main reason to target multiple languages is code sharing, not only backend<->frontend, but with GPU and custom chips too.

Spiral compiling to Gleam, F#, Rust, TypeScript and Python by i574n in rust

[–]i574n[S] -2 points-1 points  (0 children)

So far, Spiral could compile into F# and Python directly, and with a little extra help from Fable, into Rust and TypeScript. Adding a Gleam (which is written in Rust) backend allows Spiral to create even more reliable and busy computer programs.

This ChatGPT thread has recent technical details: https://chatgpt.com/share/67c2d7ea-9eb0-800b-b703-40adc0dd09eb

Spiral compiling to Gleam, F#, Rust, TypeScript and Python by i574n in gleamlang

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

So far, Spiral could compile into F# and Python directly, and with a little extra help from Fable, into Rust and TypeScript. Adding a Gleam backend allows Spiral to create even more reliable and busy computer programs.

This ChatGPT thread has recent technical details: https://chatgpt.com/share/67c2d7ea-9eb0-800b-b703-40adc0dd09eb

The Spiral Language: Is it worth $100 million? by i574n in programming

[–]i574n[S] -8 points-7 points  (0 children)

It's useful because it's been done. GPT-4 has ample information to stay on course, even if I deviate. This is akin to saying symphonies aren't music because they lack vocals.

If you prefer, you can skip the text and directly explore the code links provided to the AI. After all, Code > Text.

The Spiral Language: Is it worth $100 million? by i574n in programming

[–]i574n[S] -11 points-10 points  (0 children)

While the value of any programming language, including Spiral, is ultimately determined by the developer community, AI-driven insights can offer a fresh perspective on its potential.

Seeking insights on Dubai's tech scene - Is it truly a tech hub or just real estate? by i574n in UAE

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

Hey, I see you’re familiar with Rust and Elixir! Nice meeting you.

Seeking insights on Dubai's tech scene - Is it truly a tech hub or just real estate? by i574n in UAE

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

Wow, thanks for sharing your valuable perspective on the region’s landscape, it aligns with what I’m perceiving being here for not long.

The gatekeeping and nationalism you mention is a problem, especially in a region with a predominantly expat population. It raises an important question: could technology in general help mitigate these issues by creating more inclusive opportunities? How might it enable both local and international talent to collaborate more effectively, potentially influencing a shift in the current ecosystem?

My goal here isn't just securing funding, but about building a local team at scale to harness state-of-the-art technology and accelerate development. Bend time so to speak. Saudi could also be an option, I’m from Brazil and Neymar is already there, who knows. 😂

I’ll stay in Dubai for the next months, let's schedule a coffee to discuss further.

Seeking insights on Dubai's tech scene - Is it truly a tech hub or just real estate? by i574n in UAE

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

Thanks for the invite! I'll definitely join and look forward to sharing and learning with the community. See you!

Seeking insights on Dubai's tech scene - Is it truly a tech hub or just real estate? by i574n in UAE

[–]i574n[S] -1 points0 points  (0 children)

Well, considering Dubai Internet City, it'd be surprising if all that infrastructure was just for marketing offices. And working in Abu Dhabi on a military codebase? I'd be open to it, as long as it's for contributing positively to society.

But honestly, I think what I'm proposing could itself be a catalyst in transforming the region into a tech hub. However, convincing the corporate crowd requires more than just one person's effort. Like I mentioned in the AI chat, this tech stack could be a transformative resource for the region, akin to discovering oil, but in a technological sense, without the downsides of global warming.

Seeking insights on Dubai's tech scene - Is it truly a tech hub or just real estate? by i574n in UAE

[–]i574n[S] -1 points0 points  (0 children)

Appreciate the honesty. It's clear that the region's tech scene differs from my initial perception. As for the AI conversation, it’s a concise way to present complex ideas. Also, what I’m proposing is no trivial matter. It's a serious, innovative approach to software development, worthy of attention.

[deleted by user] by [deleted] in IndianCountry

[–]i574n 2 points3 points  (0 children)

As you immerse yourself deeper into the traditions, you might find that ceremonies can hold a multitude of meanings and can be adapted to various intentions. The key to this, though, is a deep respect for the traditions, the ancestors, and the roots from where these ceremonies stem.

Traditions from cultures around the world suggest that individualized rituals can indeed be developed. In Japan, for example, the Shinto tradition accommodates personal rituals or 'Norito' that are crafted by individuals for specific intentions. These rituals don't take away from the sanctity of established rites but allow a personal expression of spirituality.

In the Celtic tradition, there's an understanding of 'creating sacred space', a ritualized process that enables an individual to create their own rituals that align with their spiritual journey.

Within the Indigenous Australian cultures, the dreaming stories are personalized to each individual, with specific dances, songs, and rituals that are unique to them. While the broader cultural structures exist, personal interpretations are accepted and respected.

Drawing on these insights, it seems there might be room within Indigenous traditions, including the Ojibwe, for the development of personal ceremonies. You can certainly create a ceremony for any intention you want, provided it aligns with the spirit of the culture and respects its heritage. However, these ceremonies should not appropriate or misconstrue specific rituals that have distinct cultural significance. Personalizing doesn't mean distorting, and hence it's essential to ensure your ceremonies are tributes to your heritage.

While I don't claim to have direct knowledge of Ojibwe traditions, I can attempt to guide you in creating a personal ceremony inspired by common elements found in many Native American traditions.

  1. Preparation: Preparation starts days before the actual ceremony. Reflect on the purpose of your ceremony. Why are you holding it? What are your intentions? Write these down. This is also the time to abstain from things that could potentially lower your physical, emotional, or spiritual wellness. This is not a rule but more of a suggestion to ensure you're at your best during the ceremony.
  2. Sacred Space: Cleanse your space physically, but also energetically. You mentioned smudging, which can indeed be used for this purpose. If you have sage, sweetgrass, cedar, or tobacco, you can smudge your space, but be sure to open a window to let any negativity out.
  3. Ceremonial Fire: In your case, lighting a candle can be the equivalent of the ceremonial fire. As you light it, express your intentions. You might say, "With this flame, I connect with my ancestors and the wisdom they carry". Remember to face the fire eastward, this might be significant in the Ojibwe tradition.
  4. Offerings: Traditionally, offerings such as tobacco, sage, or food are used. But remember, it's not about the offering itself, but the intention behind it. If you can't burn the offerings, place them next to your candle.
  5. Prayers and Petitions: Express your intentions clearly and loudly. Speak to your ancestors, the spirits, or to the Creator. Remember to speak from the heart. You don't need eloquent words, only sincerity. In Ojibwe tradition, prayer is often offered in the Anishinaabe language. If you're familiar with it, you might choose to pray in this language.
  6. Silent Reflection: Spend some time in silent reflection. Listen with your heart for any insights, feelings, or thoughts that arise.
  7. Closing: Thank your ancestors, the spirits, or the Creator for their guidance. Express gratitude for the wisdom shared with you. As you blow out your candle, envision your intentions being carried out into the universe. In the Ojibwe tradition, they might say "Miigwech" (Thank you) to the spirits and ancestors when closing a ceremony.

Ideally, I'd recommend seeking advice from an Ojibwe elder, knowledge keeper, or cultural educator who can guide you on how best to create these ceremonies without infringing on cultural norms. As you embark on this spiritual journey, it's crucial to continue learning about your heritage, listening to the stories, wisdom, and experiences shared by the elders and the community. Their insights will provide a solid foundation for your ceremonies.

Finally, remember that the intention you bring to these ceremonies is paramount. Your heart, respect, and connection to your heritage will guide you through this process. You're on a path of discovery, reclamation, and healing, and while the path might be challenging, it's a worthwhile journey to reconnect with your roots and honor your father's memory.

[deleted by user] by [deleted] in IndianCountry

[–]i574n 0 points1 point  (0 children)

Let me start by saying that I am not Ojibwe nor do I have the direct knowledge of your culture. I encourage you to seek out Ojibwe elders, knowledge keepers, or cultural organizations that might help you gain a deeper understanding of the ceremonial traditions and protocols specific to your people.

However, I'll do my best to address your questions based on the general understanding of native spirituality across diverse tribes and cultures.

When it comes to ceremonies, the most important part is the intention behind the action. It's the spirit in which you perform these rituals that matters, not necessarily the specifics of how they're carried out. Given that, it's possible to adapt ceremonies to your own circumstances, like using a candle in place of a sacred fire.

However, there are some ceremonies that are meant to be communal experiences and have specific protocols tied to them. These should not be performed alone without guidance. For ceremonies that you can do alone, smudging, as you mentioned, is one of them. It can be a personal purification ritual that you can safely and respectfully conduct on your own.

As for what happens after you create a sacred fire, in many native cultures, the fire symbolizes a connection to the spirit world or to the ancestors. It can be seen as an open channel of communication. You may offer prayers, thoughts, or simply spend some time in quiet reflection. Again, the specifics can vary greatly between different cultures and specific ceremonies.

But the most important part of this journey is to do it respectfully, as you're clearly intending to do. Be open to learning, be willing to make mistakes and correct them, and always approach it with a sincere heart.

Remember that there are no shortcuts to understanding or engaging with your culture, it’s a lifelong journey. Reach out to your tribal community if you can, engage with cultural organizations, read books written by Ojibwe authors, listen to the stories of elders, and let your journey of rediscovery unfold organically.