Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

From a reasonably common programming language, which do you find to be the most mind-bending?

I have been listening to a lot of programming podcasts and taking some time to learn some new languages that are being considered upcoming, and important. I'm not necessarily talking about BrainFuck, but which language would you consider to be one that challenges the common programming paradigms?

For me, I did some functional and logic (for example, Prolog) programming in the 1990s, so I can't say that I find anything special there.

I am far from being an expert in it, but even today the most mind-bending programming language for me is Perl. Not because "Hello World" is hard to implement, but rather there is so much lexical flexibility that some of the hardest solutions can be decomposed so poetically that I have to walk outside away from my terminal to clear my head. I'm not saying I'd likely sell a commercial software implementation, just that there is a distinct reason Perl is so (in)famous. Just look at the basic list of books on it.

So, what is your mind-bending language that promotes your better programming and practices?

share
4  
Any language where white space matters! –  mootinator Jan 7 '11 at 20:30
1  
@Thorbjorn Is someone going to add INTERCAL? APL is a junior-high school project compared to that big daddy. –  Mark C Jan 9 '11 at 3:01
show 5 more comments

locked by maple_shaft Nov 25 '13 at 17:34

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. More info: help center.

closed as not constructive by Mark Trapp Nov 3 '11 at 18:48

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

26 Answers

up vote 73 down vote accepted

APL

This language is incredibly powerful and very terse, it will hurt your brain.

For starters it's tricky to use without a custom keyboard, or at least a keyboard overlay to show up all the obscure symbols it uses.

APL Keyboard

Then the language is of the vector/array-based paradigm and specialises towards complex linear algebra. The original version did not even have loop constructs, anything and everything done by chaining rather unusual array operators together.

  • strip_tags() anybody? (borrowed from Wikipedia)

strip_tags() ala APL

share
18  
+1 for showing the keyboard –  tcrosley Jan 7 '11 at 20:24
5  
@tcrosley: It's nice if you have a real one: wickensonline.co.uk/apl/unicomp-apl-top-large.jpg –  Orbling Jan 7 '11 at 20:35
4  
And if it wasn't already mind-bending enough, there were some operators that required using the backspace/overstrike key. For example, matrix inverse was the square box (over the L key) overstruck with a divide sign (the one next to the backarrow key in the upper right corner of the keyboard image). –  Tangurena Jan 7 '11 at 20:37
2  
I'm having flashbacks to the early 1980s when I did APL to do high level statistical regression analysis, people still use that? Shudder. –  HLGEM Jan 7 '11 at 20:59
2  
I did lots of APL once - it still holds a nostalgic spot for me... I loved it at the time. –  quickly_now Jan 8 '11 at 0:28
show 16 more comments

Haskell. It is very close to being purely functional, which most people are not accustomed to; very demanding, which is helpful once you know what you're doing but frustrating until then; has a rather cryptic, highly symbolic syntax, which is great once you know it but opaque before that...the list goes on.

Also, it's simply impossible to format the stuff in a way that looks good to me.

share
7  
I would have said Haskell too, but not because it's cryptic. While it may certainly be difficult to understand, the mind-bending thing is about the theory behind it. Monad and Arrows are still a domain I have not conquered :) –  Matthieu M. Jan 7 '11 at 19:34
11  
Why "Very close to being purely functional"? It is purely functional. –  dan_waterworth Jan 7 '11 at 20:03
4  
I'd like to quote myself and add to how Haskell will bend your mind: "Haskell prevents you from shoving things under the carpet, forces you to deal with the structure of your program explicitly, and it teaches you a language to describe these structures: the language of types. Understanding types, particularly rich types as is Haskell, will make you a better programmer in any language." programmers.stackexchange.com/questions/28950/… –  Waquo Jan 7 '11 at 21:29
14  
Haskell is a purely functional programming language. The code you write in Haskell is purely functional (as long as you don't use unsafePerformIO and the like). The IO-Monad is purely functional, if you believe otherwise, you don't understand how monads are used to model control-flow in a purely functional way. Think of your program as a shopping list of IO-actions, with a shopping list being just a pure data structure, no side-effects, and the language runtime being the shopper that performs the side-effects. –  Waquo Jan 7 '11 at 21:35
8  
@Jon, how about, we agree that: Haskell, the language, is purely functional, but it's runtime system is not. The execution of a haskell program is impure, but the program itself is pure. –  dan_waterworth Jan 7 '11 at 22:32
show 34 more comments

Prolog. It was just so different than any other language I had used when I was first exposed to it. I like it, so I don't hate the syntax or anything.

share
2  
I approached Prolog as reverse programming, wanting to know my answers already and then program to get the questions :) –  Xepoch Jan 7 '11 at 19:49
1  
@Xepoch: I think you may be right there, Prolog is formulating the question. One of the only proper 5GL languages in use. –  Orbling Jan 7 '11 at 20:07
show 4 more comments

I will agree with you on Perl. It's the most ugly syntax I've ever seen. They say, that even Perl developers cannot remember what they have written the day after.

share
2  
Def +1 on Perl. I was always particularly fond of (I believe they are called) 'implied' variables. Makes for great write-only code. –  GrandmasterB Jan 7 '11 at 22:31
2  
Everyone writes Perl so differently that they might as well be writing different languages- you don't have to just learn how Perl works to pick up someone else's code in it, you also have to learn how that particular person used it. –  glenatron Jan 8 '11 at 0:32
3  
Bah to this answer and both comments on it. Well written perl is easy to read and write. Baby-perl written by newbies is simple, if verbose. The only "unreadable" perl is either obfuscated on purpose, or scripting one-liners. –  Sean McMillan Oct 7 '11 at 14:42
add comment

I would have to say Forth. The notation that all operations are stack manipulations. In its pure form there are no local variables to use.

share
10  
FORTH is a wonderful language. When I was first learning programming in the early 80s, I had an Atari 400 and my choices were interpreted BASIC, Assembly and FORTH. I used all three extensively, but FORTH more than any other. I still have Leo Brodie's ultra-classic Starting FORTH and Thinking FORTH books. In fact, if I were asked to create a self-hosting language from scratch on a new hardware system, I would choose FORTH without hesitation. –  Adam Crossland Jan 7 '11 at 19:39
3  
@Adam Crossland: Thinking FORTH is a great book, you might be interested in this link: thinking-forth.sourceforge.net –  Orbling Jan 7 '11 at 20:42
1  
@Orbling: great minds think alike. Not more then 10 minutes ago, I put the PDF on my Kindle. –  Adam Crossland Jan 7 '11 at 20:50
1  
@Adam Crossland: A fine place for it. That book is generally helpful for programmers, should be on the reading list for people - interested in FORTH or not. –  Orbling Jan 7 '11 at 20:55
1  
I entirely agree. It has a very great deal to say about how we think about solving problems generally. Brodie is such a lucid thinker and clear writer. His works are a joy to me. –  Adam Crossland Jan 7 '11 at 21:00
show 2 more comments

Ruby.

This makes me want to kill myself:

1.month.from.now()

(I could have the exact syntax wrong, but you get the point).

share
23  
OMG. Who ever thought this was a good idea? –  EpsilonVector Jan 7 '11 at 19:59
8  
The mind-bending is not with the reading, it's with the writing. Coming up with this nonsense is difficult, and having to memorize/lookup all the built-in functions/properties is ridiculous. –  Matthew Read Jan 7 '11 at 20:23
55  
Is it only me that thinks this looks awesome, and is possibly a good reason to learn Ruby? –  Orbling Jan 7 '11 at 20:37
9  
It is awesome to read, yes. But does this mean I can write 3.months.from.last.month.if.it.was.a.leap.year? No. Or at least, I don't think so. If I can...RoR can be the first telepathic language ever. –  morganpdx Jan 7 '11 at 20:49
15  
What is wrong DateTime.Now.AddMonths(1);? These features hardly make the code more readable. (I'm not saying C# has the best syntax. You can shift it to any languages conventions and it will still apply.) –  ChaosPandion Jan 7 '11 at 21:13
show 16 more comments

Brainfuck

Anyone who can honestly write this mockery of a language shouldn't even need a thread like this.

Hello World (pointers, left; explaination, right):

+++++ +++++             initialize counter (cell #0) to 10
[                       use loop to set the next four cells to 70/100/30/10
    > +++++ ++              add  7 to cell #1
    > +++++ +++++           add 10 to cell #2 
    > +++                   add  3 to cell #3
    > +                     add  1 to cell #4
    <<<< -                  decrement counter (cell #0)
]                   
> ++ .                  print 'H'
> + .                   print 'e'
+++++ ++ .              print 'l'
.                       print 'l'
+++ .                   print 'o'
> ++ .                  print ' '
<< +++++ +++++ +++++ .  print 'W'
> .                     print 'o'
+++ .                   print 'r'
----- - .               print 'l'
----- --- .             print 'd'
> + .                   print '!'
> .                     print '\n'
share
2  
Or how about Whitespace? All the evil of Brainfuck combined with invisible code. –  Loren Pechtel Jul 3 '13 at 19:37
add comment

Lisp is my latest mind-bending language.

I've taken the monads and functional programming from Haskell with me, and now I have macros to work with. I'm just getting into CLOS and haven't touched the condition system at all.

share
show 1 more comment

MUMPS

This is a language that pops up from time to time in stories online and has the added honor of being in actual production use storing critical life-safety information (that is, patient records). However, this is also a language where terseness is appreciated and functions such as the following might appear in production code (example from the Wikipedia article on the topic):

s A="String" F i=1:1:$L(A) W $c($S($A($E(A,i))<91:$A($E(A,i))-52#26+65,1:$A($E(A,i))-84#26+97))
share
1  
My first ever programming job was with a company that specialized in MUMPS! Sadly I'd done a university course on web development so they put me in company's newly-formed ASP team instead of with the old hands, but MUMPS was the language we were trained in for our first few weeks. Maybe I had a lucky escape... –  thesunneversets Jan 7 '11 at 21:52
1  
Anybody that posted here from Madison Wisconsin? Verona, really? –  Hans Passant Jan 7 '11 at 22:44
1  
I do believe thedailywtf.com has a whole section dedicated to MUMPS. Doesn't look like a language I'd want to touch. –  Tyanna Jan 8 '11 at 2:55
1  
I remember learning M in academia, and thinking it was interesting as a special purpose language. The terseness it allows is like a perverse sort of minification. In my naivete, I figured production code would contain little of the language's extreme shorthand. The first and only time I saw a production M codebase my gut tightened... it looked just like your example. Oh, the horror! –  ajk Aug 31 '11 at 18:20
show 6 more comments

I'd say Coq, or another implementation of dependent type theory. Haskell's type system is not very expressive comparatively. Moving to a more expressive type system (for example, the calculus of constructions (CoC)) allows you to do some neat things, like proving properties of programs within the language, and embedding strong invariants into your types which can be checked statically.

share
2  
Any Dependent Type system/prover/language would probably rate more confusing than the regular languages, so +1. –  Orbling Jan 9 '11 at 19:36
1  
Formal verification of programs is something I'm just starting out on. It certainly bends the mind and is becoming increasing useful in the real world. +1 –  dan_waterworth Jan 9 '11 at 21:26
add comment

Objective-C. To be fair, I only studied it extremely briefly and disliked the syntax at first glance so much that I gave up on it.

Since it is such a (relatively) common language (mainly for Mac/iPhone/iPad development), I'm sure it's actually somewhat decent once you get used to it.

share
2  
Well, it probably does qualify as a bit mind-bending, but I like it. It might help if you realize [foo bar] is just syntactic sugar for objc_sendMsg(foo, "bar"); which in turn looks up the function pointer (it's a special "bar", not a generic one). Did you realize it's fully duck typed? –  Per Johansson Nov 3 '11 at 18:32
show 1 more comment

I pick Mercury.

Mercury bent my mind by showing me that even pure languages can do I/O.

The way this works is that I/O functions in Mercury take a 'state of the world' value and return a new 'state of the world' value. So I/O functions in Mercury transform the world and hence purity is maintained.

share
3  
+1 "... mercury transforms the world and hence purity is maintained." - I like that out of context. ;-) –  Orbling Jan 8 '11 at 1:23
show 2 more comments

It has to be Scheme, surely. Trying to explain call-with-current-continuation always hurts my brain, but once you understand it you can make incredibly elegant solutions.

Want to stop part-way through an algorithm and hand control to someone else? Sure!

Want to resume the same continuation several times? Of course!

Want to pause execution of an algorithm, redefine a function, then resume execution with the original stack but an updated global state? No problem! And do this several times with different changes to the global state but the same stack re-entry point? For you, sir, anything!

share
1  
Scheme is not the only language with explicit continuations. Haskell, for example, supports it just fine and just as mind-bendingly. –  JUST MY correct OPINION Jan 8 '11 at 5:06
4  
It's arguably more mind-bendy in Haskell, since it (call/cc) is implemented as a library and not a language feature. But maybe that makes it less mind-bendy. –  Logan Capaldo Jan 8 '11 at 19:29
show 4 more comments

I used to use an ancient editor called TECO (Text Editor and COmparator), which was a very powerful text modification language, with all sorts of macro capability. I don't remember the exact famous quote about it but the gist was"any random collection of 20 characters is almost always a legitimate TECO program, and will change your file (it is an editor) in a fundamentally unpredicatable manner. I remember writing a Fortran to PL1 converter in about a page of TECO code.

share
5  
"One of the more entertaining games to play with TECO is to type your name in as a command line and try to guess what it does. Just about any possible typing error while talking with TECO will probably destroy your program, or even worse-- introduce subtle and mysterious bugs in a once working subroutine." Man, those were the days! –  JUST MY correct OPINION Jan 8 '11 at 5:08
1  
TECO was also the original base of EMACS. EMACS started off as just a collection of TECO macros! –  Gabe Jan 8 '11 at 8:08
1  
Makes me remember typing in Vim command mode –  ron Jan 9 '11 at 18:23
show 4 more comments

Assembly has been the most "mind bending" to me, but I'm just starting it.

share
2  
Ah, the Cincinnati Milacron 2200B: Variable word length combined with runtime modification of the address of a JMP. It made LSD look tame. –  Peter Rowell Feb 15 '11 at 3:08
show 3 more comments

Lisp. Learning it is a series of small epiphanies, each of which will totally change the way you think about solving programming problems.

share
add comment

REBOL

It's built around the notion of code-as-data, like Lisp is. The language's adherents have a hard time explaining what its unique benefits are over other approaches in that family, and usually wind up shrugging and saying something like "Well the guy who designed the AmigaOS came up with it, the standard library is included and microscopic, and once you 'get' it that will be like taking the red Matrix pill and you'll never want to go back."

The trouble with it is partially that it's quirky and hasn't precisely defined which programmers are its market. But also partially because many of the people advocating it just suck at explaining. :)

But Douglas Crockford used to be a fan, drew some inspiration from it with the creation of JSON, and has suggested people look into it as recently as October, 2010:

"Ted Neward did a really good job of moderating the panel on 'Future of Programming Languages'. At the end of the panel, Ted asked the panelists which languages they though people should be learning in order to get new ideas. The list included Io (Bruce Tate), Rebol (Douglas Crockford), Forth and Factor (Alex Payne), Scheme and Assembler (Josh Bloch), and Clojure (Guy Steele)."

Source: sauria.com

I think it's worth looking at for anyone looking to stretch how they think about language design and extensibility. Now that it's open source (after 18 years of proprietary development) the usual disclaimers I used to give for keeping it at arm's length no longer apply... it's worth a look! The community has even gotten out of their proprietary Rebol-based messaging program and started chatting on Stack Overflow (much to my surprise!)

share
1  
I avoid REBOL because its sole practical implementation is a non-standardized, non-open piece of software that is changed at the whimsy of its owning corporation. (Rebol 2 vs. Rebol 3...) If it is ever standardized or opened I'll be taking another look but until that day Rebol remains off of my toolbelt. –  JUST MY correct OPINION Jan 10 '11 at 6:34
1  
@JUSTMYcorrectOPINION perhaps the day has come to take another look! Rebol 3 is now Apache2 licensed software. We've even got a RebolBot here in the Rebol and Red chat room on StackOverflow to help us with demo'ing the language. (Red is another open source Rebol variant that is showing some very interesting promise as a hybrid compiled version.) –  HostileFork Jul 3 '13 at 5:39
add comment

I would say from the lengths that many people go to avoid having to directly write it, that developers find SQL to be mind-bending. I guess many people just don't naturally think in terms of sets.

share
4  
SQL is as natural to me as BASIC, just me. Amazing how easy DB-backed application can be when your grasp full data handling in SQL. –  Xepoch Jan 7 '11 at 21:19
show 7 more comments

Pure

Pure is a functional language based on term rewriting. I like it, it is both sparse and expressive, if a little bit understated.

share
show 1 more comment

It might not be the most mind-bending, but it has been by far the hardest for me to learn (I thought Haskell and assembly language were easier!)

That is the set of HDL languages, notably, VHDL (and Verilog to a lesser extent)

Getting over the fact that every "function" runs at the same time is incredibly difficult and you can not avoid the shift to parallelizing absolutely everything. Of course, this is only border-line a programming language though.

share
1  
Being electrical engineer I didn't have much problem with the simultaneity, it was quite a liberation in fact. As for the pain of implementation, well the uP is a niche-solution to specific classes of problems that transform the problem to solution that can be described as algorithms, a concept originally taken from mathematics. A problem with inherent parallelism is among the problems easy solvable and VHDL and FPGA's come in handy at that times. –  user1041 Mar 17 '11 at 8:22
show 2 more comments

Tcl

I started to learn it once, but as I learned enough to make sense I really disliked the way it made my brain feel. That would seem to qualify as mind-bending.

share
1  
I did a lot of Tcl programming around 1995-1997 for no particularly good reason. When I started looking for a new job in 1998, every recruiter in the entire Bay Area tried to get me in to interview for poorly-paid, high-pressure VIGNETTE gigs. I quickly removed it from my resume. I considered giving you a hard time over this, as I remembered Tcl as being really easy, but I kind of wish that I had learned Python instead, in retrospect. –  Adam Crossland Jan 7 '11 at 20:56
show 1 more comment

Turing machine language, obviously. It is extremely powerful, provably superior to all other programming languages that exist, and guaranteed to hurt your brain if you try to use it.

share
6  
I have to object to claiming that its provably superior. The term superior suggests bringing subjective issues into account. Also, if we run C on a computer with infinite memory (which is only fair because a Turing machine runs with infinite memory) they are equivalent in power. –  Winston Ewert Jan 8 '11 at 4:02
2  
@Winston: The tape of a turing machine does not have to be infinite. It only needs to have a tape factory at each end that can manufacture additional tape as needed :) –  Mike Dunlavey Jan 8 '11 at 19:43
1  
That shows that a Turing machine is more powerful. The problem is that, at least as I'd use the term, claiming a language to be superior would also take into account ease of use, availability, etc. –  Winston Ewert Jan 9 '11 at 0:54
show 4 more comments

C

Pointers, memory management and type casting all take a lot of thought and are easy to get wrong. The lack of built-in data structures like hash tables or lists means you either have to devise your own or find a third-party library and learn its API.

share
2  
Assembly languages are mind bending. –  david4dev Feb 15 '11 at 16:39
show 1 more comment

JESS (Java Expert System Shell). Embedded in a Java environment, this adaptation of CLIPS is a functional rule based expert system language. Trying to map real Java objects as facts and find the right questions to ask to get the results you expect is a real challenge. Less so if you are familiar with expert system theory, but when you are coming from a pure OOP mindset it doesn't fit well. NOTE: CLIPS is not Lisp, but looks like it. Yet another mind bender.

Once you get past the initial learning curve, it is pretty powerful and pretty darn quick to come up with the answers.

share
show 2 more comments

TeX counts as a language, since it is Turing complete, and I consider it quite mind-bending. A language for typesetting math, (and books on programming)...

share
add comment

CIL

CIL, the Common Intermediate Language that all .NET programs compile to, a kind of an object-oriented assembly. It's interesting for me to try write or read code in it and comparing its constructs to those of C# that I already know. It's a good way to learn more what .NET does behind the scenes. And it can be useful for things like dynamic code generation or rewriting existing compiled code using Mono Cecil.

share
2  
or bytecode for that matter too? –  Xepoch Nov 17 '11 at 22:14
show 3 more comments

Not the answer you're looking for? Browse other questions tagged or ask your own question.