Modular

M

Modular

This server is the home of the MAX and Mojo community. Join us to chat about all things Modular!

Join

questions

community-showcase

SHA256

Any implementations of SHA256 algorithm in Mojo yet, I've seen other work about other hashing algorithms and obviously the builtin, but has anyone implemented this?

casting from smaller to larger integer

Good evening, sorry for making a whole post about something so basic but I'm honestly stumped. I just started using mojo today, past experience is a lot of rust and some c, and I can't figure out how to cast between integer types. Every type parameter I try plugging into the cast method is wrong, I couldn't find anything else that sounded right in the library docs, and kapa.ai comes up empty handed.
let small: UInt8 = 255
let big: UInt64 = # the value of small, cast to a wider size
let small: UInt8 = 255
let big: UInt64 = # the value of small, cast to a wider size
...

.o files?

How do I get an object file out of mojo? I would like to try plugin it into a c++ codename I am benchmarking and see if its any faster

If we talk about performance code, why is MLIR better than LLVM?

In their latest blog they say that MLIR is for next generation copiers and that Mojo is the only language that takes full advantage of it. But in terms of performance I still don't understand what they mean. The only advantage that I understand is that Mojo, using MLIR, can give instructions to the GPU, TPU, etc....

Networking library

Hello, when it the Mojo standard networking library supposed to be released?

Conditional typing of fields.

Suppose I have the following struct: (in pseudo Mojo) ``` struct IntWrapper[N: Int]: @parameter...

String to StringLiteral

Any ideas how I might convert a String to a StringLiteral? I'm trying to interact with a postgres database and if I don't have the parameters as a StringLiteral it doesn't want to work. Not sure how I might get around this. For example the following works if you pass the name as a StringLiteral but not as a String and I don't know how I might convert a String to a StringLiteral for the purposes of using this function: fn get_name(cursor: PythonObject, name: StringLiteral) raises -> PythonObject: let np = Python.import_module("numpy") var name_array = np.array(()) let sql = """...

Bytes-like object when using a python module

Hi there, I'm checking out mojo and was going to make a little IRC client using the basic python socket module, but I ran into an issue when trying to call socket.send which was: a bytes-like object is required, not 'str'. So I tried to get the underlying buffer from the string and got a compile error: argument #1 cannot be converted from 'DynamicVector[SIMD[si8, 1]]' to 'PythonObject' I'm new to mojo and my python is very rusty, but I couldn't find a way to get a bytes-like python object, is there a stdlib function somewhere that I'm missing?...

GAMEDEV+MOJO

🕹️ +:mojo: All GAMEDEV+MOJO Question goes here,if any showcase please put here so that it might Help for people to reference...

Big Integers?

Python integers are arbitrary precision by default. Is that planned for Mojo as well... or is that expected to be a user land implementation. Thanks.

Parallelization not working in Jupyter Notebook extension in VSCode on Linux Mint

I am running the Mandelbrot demo files. Running the regular .mojo file is using all 16 threads on my CPU and I get a Parallel speedup of 8.9 but when I try to run the Mandelbrot Jupyter Notebook it shows that it is only using 8 threads and I get a speedup of 0.5 ...

Creating a string from a DynamicVector Drops the last character in the vector

This example sums up the question: ```python fn test_stringify() raises: var example = DynamicVectorInt8 example.append(ord("e"))...

Mojo `Dict` implementation choice

Why does Mojo has a Dict implementation that is said to be "closely mirrors Python's dict" rather than something like absl::flat_hash_map? The latter makes use of SIMD instructions and can potentially be a breeze to port to a language with first class SIMD. I wouldn't want Mojo to miss the opportunity to make its stdlib SIMD saturated....

theres any oficial image to run mojo code or dockerfile?

theres any oficial image to run mojo code or dockerfile?

Different outputs with random numbers

Hi, I am running code to find the covariance of a matrix from scratch. When the code is run I sometimes get large or small random unexpected numbers or even infinity. It seems to change every time the code is run even when there is no random element in the code, and should produce the same output. Many thanks for any advice. Code snippet: ```fn CovarienceMatrix(borrowed self) -> Matrix: let transposed_matrix = self.Transpose()...

Is it possible to make this Discord indexable for web search?

It's difficult to find answers here, and the common issues may be answered already. Can we connect some sort of bot to repost content to the web?

Improving WebXR Performance/Multi threading Javascript Runtimes

hey guys , I have been exploring options to multi thread javascripts using webworker/Atomic api to help improve webxr scene.Do you think multi threading javascript runtimes would work with mojo??

Is Mojo a general-purpose language? Or an AI language?

I’ve been fascinated by Mojo as a language, despite not touching Python much in my career. However, I came across the recent blog post: “Mojo vs. Rust - is Mojo faster than Rust?” I think what’s off-putting about the article is that this far, Mojo hasn’t been positioned as anything like Rust. I.e. Rust has been marketed as a general-purpose language, and Mojo has been written-about as useful for a very very specific niche use case, even if that niche is popular right now. Can there be some writing on Mojo as a general-purpose language? Can you build command-line apps? Can you build web servers? Parsers? Can it compile to WASM? AI is cool but I feel like software devs (like me) who are not in that field will not be remotely interested in Mojo without demonstrations out of the field....

Lisp (or other languages) on top of Mojo?

I (and many others) derive considerable benefit from using a Lisp-based language: homoiconicity, macro capability, regularity of syntax, terseness, developer convenience (e.g. Paredit, Parinfer), and so on. Plus, even beyond issues of practicality — as anyone knows who's "gotten" Lisp — there's something subjectively beautiful and timeless about it (https://xkcd.com/224/). I'd like to suggest that Mojo have some facility for other programming languages to take advantage of the compiler work being done under the hood. JS has source maps for transpiled languages like TypeScript, ClojureScript, etc. The JVM processes bytecode emitted by hosted languages and treats such languages as first-class citizens. Having some sort of transpilation story (or possibly better, a hook-in to the Mojo MLIR representation?) could be a powerful advantage for Mojo as it draws in indirectly users like me who are disconnected from the Python ecosystem, but who still want to take advantage of Mojo's performance and reach to heterogeneous architectures. This, of course, is all assuming that Mojo is defining some custom MLIR passes that give it some sort of technical advantage over a language that used MLIR directly. Otherwise there's not much to do here 🙂...

Printf - print format

Is there a print format in mojoŘŚ how can I rewrite this python in mojo: ```py def fun (arg): print(f'arg = {arg}') bar = [5, 10, 15, 20]...