r/ProgrammingLanguages • • Oct 21 '22

Discussion What Operators Do You WISH Programming Languages Had? [Discussion]

171 Upvotes

Most programming languages have a fairly small set of symbolic operators (excluding reassignment)—Python at 19, Lua at 14, Java at 17. Low-level languages like C++ and Rust are higher (at 29 and 28 respectively), some scripting languages like Perl are also high (37), and array-oriented languages like APL (and its offshoots) are above the rest (47). But on the whole, it seems most languages are operator-scarce and keyword-heavy. Keywords and built-in functions often fulfill the gaps operators do not, while many languages opt for libraries for functionalities that should be native. This results in multiline, keyword-ridden programs that can be hard to parse/maintain for the programmer. I would dare say most languages feature too little abstraction at base (although this may be by design).

Moreover I've found that some languages feature useful operators that aren't present in most other languages. I have described some of them down below:

Python (// + & | ^ @)

Floor divide (//) is quite useful, like when you need to determine how many minutes have passed based on the number of seconds (mins = secs // 60). Meanwhile Python overloads (+ & | ^) as list extension, set intersection, set union, and set symmetric union respectively. Numpy uses (@) for matrix multiplication, which is convenient though a bit odd-looking.

JavaScript (++ -- ?: ?? .? =>)

Not exactly rare– JavaScript has the classic trappings of C-inspired languages like the incrementors (++ --) and the ternary operator (?:). Along with C#, JavaScript features the null coalescing operator (??) which returns the first value if not null, the second if null. Meanwhile, a single question mark (?) can be used for nullable property access / optional chaining. Lastly, JS has an arrow operator (=>) which enables shorter inline function syntax.

Lua (# ^)

Using a unary number symbol (#) for length feels like the obvious choice. And since Lua's a newer language, they opted for caret (^) for exponentiation over double times (**).

Perl (<=> =~)

Perl features a signum/spaceship operator (<=>) which returns (-1,0,1) depending on whether the value is less, equal, or greater than (2 <=> 5 == -1). This is especially useful for bookeeping and versioning. Having regex built into the language, Perl's bind operator (=~) checks whether a string matches a regex pattern.

Haskell (<> <*> <$> >>= >=> :: $ .)

There's much to explain with Haskell, as it's quite unique. What I find most interesting are these three: the double colon (::) which checks/assigns type signatures, the dollar ($) which enables you to chain operations without parentheses, and the dot (.) which is function composition.

Julia (' \ .+ <: : ===)

Julia has what appears to be a tranpose operator (') but this is actually for complex conjugate (so close!). There is left divide (\) which conveniently solves linear algebra equations where multiplicative order matters (Ax = b becomes x = A\b). The dot (.) is the broadcasting operator which makes certain operations elementwise ([1,2,3] .+ [3,4,5] == [4,6,8]). The subtype operator (<:) checks whether a type is a subtype or a class is a subclass (Dog <: Animal). Julia has ranges built into the syntax, so colon (:) creates an inclusive range (1:5 == [1,2,3,4,5]). Lastly, the triple equals (===) checks object identity, and is semantic sugar for Python's "is".

APL ( ∘.× +/ +\ ! )

APL features reductions (+/) and scans (+\) as core operations. For a given list A = [1,2,3,4], you could write +/A == 1+2+3+4 == 10 to perform a sum reduction. The beauty of this is it can apply to any operator, so you can do a product, for all (reduce on AND), there exists/any (reduce on OR), all equals and many more! There's also the inner and outer product (A+.×B A∘.×B)—the first gets the matrix product of A and B (by multiplying then summing result elementwise), and second gets a cartesian multiplication of each element of A to each of B (in Python: [a*b for a in A for b in B]). APL has a built-in operator for factorial and n-choose-k (!) based on whether it's unary or binary. APL has many more fantastic operators but it would be too much to list here. Have a look for yourself! https://en.wikipedia.org/wiki/APL_syntax_and_symbols

Others (:=: ~> |>)

Icon has an exchange operator (:=:) which obviates the need for a temp variable (a :=: b akin to Python's (a,b) = (b,a)). Scala has the category type operator (~>) which specifies what each type maps to/morphism ((f: Mapping[B, C]) === (f: B ~> C)). Lastly there's the infamous pipe operator (|>) popular for chaining methods together in functional languages like Elixir. R has the same concept denoted with (%>%).

It would be nice to have a language that featured many of these all at the same time. Of course, tradeoffs are necessary when devising a language; not everyone can be happy. But methinks we're failing as language designers.

By no means comprehensive, the link below collates the operators of many languages all into the same place, and makes a great reference guide:

https://rosettacode.org/wiki/Operator_precedence

Operators I wish were available:

  1. Root/Square Root

  2. Reversal (as opposed to Python's [::-1])

  3. Divisible (instead of n % m == 0)

  4. Appending/List Operators (instead of methods)

  5. Lambda/Mapping/Filters (as alternatives to list comprehension)

  6. Reduction/Scans (for sums, etc. like APL)

  7. Length (like Lua's #)

  8. Dot Product and/or Matrix Multiplication (like @)

  9. String-specific operators (concatentation, split, etc.)

  10. Function definition operator (instead of fun/function keywords)

  11. Element of/Subset of (like ∈ and ⊆)

  12. Function Composition (like math: (f ∘ g)(x))

What are your favorite operators in languages or operators you wish were included?


r/ProgrammingLanguages • • Apr 25 '22

Announcing Hush, a modern shell scripting language

169 Upvotes

Hush is a new shell scripting language that aims to enable developers to write robust shell scripts. It provides support for complex data structures and common programming paradigms, without giving up on ergonomic shell capabilities.

Official guide: https://hush-shell.github.io/
Repository: https://github.com/hush-shell/hush


r/ProgrammingLanguages • • Dec 27 '21

Language announcement Konna, my programming language

168 Upvotes

About a year ago I started working on a programming language, and it's now almost at the level of functionality needed to write "real" programs. Konna is a functional language based on two level type theory (2LTT). The basic idea of 2LTT is that programs of your language becomes programs in two languages, where one language executes before the other and can manipulate programs of the other language like data. If this sounds like metaprogramming, that's because it can be! Metaprogramming is one of the features that falls under the 2LTT umbrella. 2LTT is a general, principled, type theoretic framework under which nearly all notions of "compile time vs run time programming" fall.

Terminology clarification: Static and dynamic mean "of the compile time language" and "of the runtime language" respectively.

The design space of 2LTT involves what types of features you include or exclude from the two languages. In Konna's case, the static language is dependently typed, pure, and terminating. The dynamic language is simply typed with unrestricted effects. This means that the expressiveness of dependent types can be employed, with the restriction that it must all happen at compile time. This gives you the guarantee that programs which use dependent types can be compiled to efficient code. The same is true for other features I plan to implement like algebraic effects (see Zero Cost Effect Handlers by Staging). An additional idea: You can have the full feature be implemented in the static language, and a restricted version of it that's easy to compile efficiently implemented in the dynamic language. For instance, I'm interested of having some form of dynamic dependent types.

The end goal of all this is to have a functional language with a very expressive type system (for context, my frame of reference is Haskell) and reasonably high and predictable performance. Low-cost and predictable abstractions is something I very much miss coming from systems languages to languages like Haskell. So far I've implemented GADTs, product types, dependent pattern matching, namespaces, and function definitions. As said before, it's almost ready to write real programs in! All it technically needs is IO.

I'm also writing a structured editor to go along with the language! For now it isn't the main focus though, so I'll save writing about it for another time.

Github repo: https://github.com/eashanhatti/konna


r/ProgrammingLanguages • • Jan 12 '26

ELI5: Why C++ and Rust compilers are so slow?

167 Upvotes

This is not a rant of any kind - just pure curiosity. I’m trying to understand what makes these compilers slow.

We know that generating native binary code can be fast (for example, Go). One might assume this is because Go doesn’t have generics, but then Java handles generics quite efficiently as well. So it seems the explanation must be something else.

What are the main factors that make C++ and Rust compilation comparatively slow?


r/ProgrammingLanguages • • Sep 21 '25

Discussion WHEN: A language where everything runs in implicit loops with reactive conditions

167 Upvotes

You know that meme "everyone talks about while loops, but no one asks WHEN loops"? Well, I took that personally and created an entire programming language called WHEN.

In WHEN, everything runs in implicit infinite loops and the only control flow is when conditions. No for loops, no while loops, just when.

# This is valid WHEN code:
count = 0

main:
    count = count + 1
    when count > 5:
        print("Done!")
        exit()

The main block runs forever until you explicitly exit. Want something to run exactly 5 times? Use a de (declarative) block:

de ticker(5):
    print("tick")

Want parallel execution? Just add parallel:

parallel fo background_task():
    monitor_something()

The cursed part? I made a smooth 60 FPS game with keyboard controls in it. It imports Python modules, so you can use tkinter, numpy, whatever. The entire language is built on the principle that everything is a reactive state machine whether you like it or not.

You can actually install it:

pip install when-lang
when your_program.when

GitHub: https://github.com/PhialsBasement/WHEN-Language


r/ProgrammingLanguages • • Sep 17 '25

Wasm 3.0 Completed - WebAssembly

Thumbnail
webassembly.org
167 Upvotes

r/ProgrammingLanguages • • Jul 29 '21

Bob Nystrom's Crafting Interpreters book is available on Amazon. Been waiting to grab a printed copy of this. Yay!

167 Upvotes

r/ProgrammingLanguages • • Dec 11 '20

CS 6120: Advanced Compilers: The Self-Guided Online Course

Thumbnail cs.cornell.edu
167 Upvotes

r/ProgrammingLanguages • • Jun 30 '23

Zig: File for Divorce from LLVM

Thumbnail
github.com
165 Upvotes

r/ProgrammingLanguages • • Jul 09 '21

DitLang: Write functions in any other language! Follow up to "KirbyLang" post from 6 months ago

Thumbnail
gallery
163 Upvotes

r/ProgrammingLanguages • • Nov 11 '22

Resource NSA urges orgs to use memory-safe programming languages

Thumbnail
theregister.com
162 Upvotes

r/ProgrammingLanguages • • Oct 27 '22

Discussion Making JS Garbage Collection 30% faster by differential calculus

Thumbnail
arxiv.org
161 Upvotes

r/ProgrammingLanguages • • Aug 18 '26

Blog post Mojo🔥 is now open source!

Thumbnail
modular.com
159 Upvotes

r/ProgrammingLanguages • • May 05 '21

Language announcement RustScript: A simple functional based programming language with as much relation to Rust as JavaScript has to Java

Thumbnail
github.com
159 Upvotes

r/ProgrammingLanguages • • Mar 12 '21

Dennis Ritchie's first C compiler on GitHub

Thumbnail
github.com
159 Upvotes

r/ProgrammingLanguages • • Dec 25 '20

LLVM Tutorial

Thumbnail
mukulrathi.co.uk
158 Upvotes

r/ProgrammingLanguages • • Feb 23 '21

Resource I’m learning Python, but my favorite resource is my dads Basic textbook from the 70s.

Thumbnail
gallery
157 Upvotes

r/ProgrammingLanguages • • May 04 '22

Discussion Worst Design Decisions You've Ever Seen

156 Upvotes

Here in r/ProgrammingLanguages, we all bandy about what features we wish were in programming languages — arbitrarily-sized floating-point numbers, automatic function currying, database support, comma-less lists, matrix support, pattern-matching... the list goes on. But language design comes down to bad design decisions as much as it does good ones. What (potentially fatal) features have you observed in programming languages that exhibited horrible, unintuitive, or clunky design decisions?


r/ProgrammingLanguages • • Jun 06 '21

Language announcement Introducing the future of Scheme...take your S-expressions to the next level with Scheme 2-D!

Thumbnail
github.com
156 Upvotes

r/ProgrammingLanguages • • Oct 17 '20

Discussion Unpopular Opinions?

156 Upvotes

I know this is kind of a low-effort post, but I think it could be fun. What's an unpopular opinion about programming language design that you hold? Mine is that I hate that every langauges uses * and & for pointer/dereference and reference. I would much rather just have keywords ptr, ref, and deref.

Edit: I am seeing some absolutely rancid takes in these comments I am so proud of you all


r/ProgrammingLanguages • • Jan 07 '20

Introducing the Beef Programming Language

156 Upvotes

Beef is an open source performance-oriented compiled programming language which has been built hand-in-hand with its IDE environment. The syntax and many semantics are most directly derived from C#, while attempting to retain the C ideals of bare-metal explicitness and lack of runtime surprises, with some "modern" niceties inspired by languages such as Rust, Swift, and Go. See the Language Guide for more details.

Beef's primary design goal is to provide a fluid and pleasurable development experience for high-performance real-time applications such as video games, with low-level features that make it suitable for engine development, combined with high-level ergonomics suitable for game code development.

Beef allows for safely mixing different optimization levels on a per-type or per-method level, allowing for performance-critical code to be executed at maximum speed without affecting debuggability of the rest of the application.

Memory management in Beef is manual, and includes first-class support for custom allocators. Care has been taken to reduce the burden of manual memory management with language ergonomics and runtime safeties – Beef can detect memory leaks in real-time, and offers guaranteed protection against use-after-free and double-deletion errors. As with most safety features in Beef, these memory safeties can be turned off in release builds for maximum performance.

The Beef IDE supports productivity features such as autocomplete, fixits, reformatting, refactoring tools, type inspection, runtime code compilation (hot code swapping), and a built-in profiler. The IDE's general-purpose debugger is capable of debugging native applications written in any language, and is intended to be a fully-featured standalone debugger even for pure C/C++ developers who want an alternative to Visual Studio debugging.

Binaries and documentation are available on beeflang.org. Source is available on GitHub.


r/ProgrammingLanguages • • May 08 '23

What are the current hot topics in type theory and static analysis?

155 Upvotes

I’m taking a compilers course right now and really enjoying it, so I’m trying to potentially get involved in PL research. I’ve read some papers from the lab in my college and I’ve found the type theory and static analysis-related papers to be interesting and I’m wondering what are some topics or trends that current research is focusing on.


r/ProgrammingLanguages • • Dec 10 '22

My new type system caught a bug in my own standard library that would have ruined someone's day at runtime

154 Upvotes

That's it. I just wanted to share that. I'm having a proud dad moment (the type system being my child).

I was hesitant to spend time building a proper type system originally, but I'm so glad I decided to do it. Having a typing stage in the pipeline has made my language (Glide) feel so much closer to a real language than the toy language I've always seen it as.

It's also given me the ability to hugely simplify my virtual machine, since the type system handles a bunch of errors I was checking at runtime.

Next step is an optimization layer in the pipeline to make it go fast.


r/ProgrammingLanguages • • May 14 '21

Discussion Comparing algebraic data types: Rust and Datatype99

Post image
153 Upvotes