Replies: 12 comments 15 replies
-
In my opinion, doing this makes the program lose its flexibility. A successful programming language is one that is most efficient with the least variety of syntax |
Beta Was this translation helpful? Give feedback.
-
This is the same approach as some languages like APL. But I don't see the benefit and only drawbacks:
|
Beta Was this translation helpful? Give feedback.
-
This is definitely something worth investigating, Swift has the ability to define custom operators, even unicode ones: That said, we're focused on building out the core language, not adding sugar in the immediate future. |
Beta Was this translation helpful? Give feedback.
-
Maybe an editor plugin could display operators as Unicode while in reality they are written as ASCII. |
Beta Was this translation helpful? Give feedback.
-
Okay I get what you are going for. but I think the usable characters are pretty limited imo. I'm just going off APL since languages like that take full advantage of these characters and imo the following code is just completly unreadable. Also when you take a symbol in a vacuum sure You could make the argument that the paradigm of APL makes it unreadable but think the symbols stand |
Beta Was this translation helpful? Give feedback.
-
Imo, this would not be used for production. This operators is used im math, no doubts, but mojo is primary is It's not really comfortable and everyone is getting used to write I can understand you, it's cool to see that, but it's not really practical and comfy for coding. Programming languages designed to be as close to natural language as possible :) |
Beta Was this translation helpful? Give feedback.
-
FWIW, this isn't something we are pursuing in the near future, we are building out the core language. :) |
Beta Was this translation helpful? Give feedback.
-
I really don't like this. What a way to make a language hard to read, extremely hard to write, and difficult to use, when it doesn't even improve it in any meaningful way and is used nowhere else. Simplicity is beneficial sometimes, and this is one of those instances. |
Beta Was this translation helpful? Give feedback.
-
Personally I need a programming language, in its entirety, to be typeable on a MacBook ASCII keyboard for it to be useful to me. I feel like a parser could handle the task of displaying |
Beta Was this translation helpful? Give feedback.
-
To add to this from another perspective since all of the comments expressing their distaste for the suggestion are met with an extended versions of "if you can't benefit from this why not anyone else". there are a few extra points I would like to make: Just like mojo is going to be a superset of python I think it should therefore carry the burden of some python philosophies, as expressed in the Zen of Python (PEP 20), advocates for simplicity and clarity. A key tenet is: "There should be one—and preferably only one—obvious way to do it." This is central to Python's ethos, and it has been instrumental in making Python one of the most loved and widely used programming languages. Most code is not written alone. When accessibility points have been brought up these have been pretty much brushed off. But just like we have code formatters that keep the line length (79 pep) (88 black) in check, we should also keep in mind the wide array of developers who will be working with this code. while it is important to explore and innovate, we must also ensure that the soul of Python is not lost in the process. We need to strike a balance between incorporating new ideas and maintaining the philosophy that has made Python so successful and widely adopted. Let's focus on ways to enhance Mojo while preserving the principles that have inspired its creation. |
Beta Was this translation helpful? Give feedback.
-
When can I use emojis as custom operators struct thing:
fn __🔥__(lhs, rhs) -> Self:
return max(0, lhs * rhs)
Print(thing1 🔥 thing2) |
Beta Was this translation helpful? Give feedback.
-
This is a Python Unicode issue for variable use as well:
So maybe when Python supports Unicode characters (multi-byte) in future this could be looked at. |
Beta Was this translation helpful? Give feedback.
-
Unicode Logical and Mathematical Operators in Mojo: A Discussion
Introduction
I'm starting this discussion to explore the potential benefits of incorporating Unicode logical and mathematical operator characters into the Mojo language. This could provide a concise, less ambiguous alternative to the existing representations and might even introduce new functionality.
Proposed Unicode Operators
Here are a few examples of the Unicode operators we could consider:
Note that in Python calling int(n+m) rounds n+m toward zero if it's not already an integer value regardless of whether n+m is negative or non-negative. In contrast, ⌈n+m⌉ would always round n+m upward when it's not already an integer value, while ⌊n+m⌋ would always round n+m downward when it's not already an integer value.
There are of course many more to be considered. A comprehensive list can be found at the Unicode charts: Mathematical Operators and Miscellaneous Technical.
Potential Use Cases
To illustrate the potential benefits, let's consider the multiplication operator. In Python, the asterisk (*) is used for multiplication. However, if we're multiplying several numbers in a Markdown formatted text, we need to escape the asterisk characters. Using the Unicode multiplication operator (×) would circumvent this problem.
Current syntax: result = 5 * 7 * 9
Proposed syntax: result = 5 × 7 × 9
Potential Issues
While there's potential for this feature, we also need to consider potential challenges. These could include compatibility issues with different systems or programming languages that Mojo might get embedded into or in some other way have to deal with, confusion with similar looking Unicode characters such as the similarity of the Unicode multiplication operator symbol "×" to the letter "x" making it possible that some people might think they could use "x" as a multiplication symbol, and the impact on the learning curve for new programmers finding more than one way of writing the same thing having been used in different programs or different parts of the same program. Perhaps programs or editor features could be constructed to find and deal with or help deal with such potential issues.
Questions and Discussion
I'd love to hear your thoughts on this proposal. Are there any other Unicode characters you think would be beneficial? What do you think of the idea of having these as alias operators, as an option for those who wish to use them? How do you think this might be best implemented to work well with potentially allowing Mojo programmers to add their own operators?
Conclusion
While I don't expect this feature to be a priority at this stage in development, it would be nice to plan ahead to allow for it. Let's discuss the potential advantages, and challenges, and how such a feature might be best implemented.
Summary and Reference Links:
I would like to encourage discussion of adding Unicode alias operators for such things as mathematical and logical operations for which there is an established unambiguous Unicode operator character or enclosing operator, such as any of ¬, ±, ×, ÷, ⁻, ∀, ∅, ∈, ∉, ∋, ∌, ∏, ∐, ∑, −, √, ∝, ∞, ∧, ∨, ∩, ∪, ∫, ∴, ∵, ∶, ∷, ≃, ≄, ≅, ≆, ≇, ≠, ≡, ≢, ≣, ≤, ≥, ⊂, ⊃, ⊄, ⊅, ⊆, ⊇, ⊈, ⊉, ⊊, ⊋, ⊨, ⊭, ⊻, ⊼, ⊽, ⌈⌉, or ⌊⌋, for example, to allow for more conciseness and less ambiguity and perhaps in some cases even to introduce new functionality. Of course, I don't expect any such thing to be a priority at this stage in development, but it would be nice to plan ahead a bit to allow for it. Many and likely most such characters can be found with their descriptive name and Unicode code point at https://unicode.org/charts/nameslist/n_2200.html and https://unicode.org/charts/nameslist/n_2300.html online.
DAK
Beta Was this translation helpful? Give feedback.
All reactions