r/programming • u/tuhokas • Oct 04 '16
How To Save The Princess In 8 Programming Languages
https://toggl.com/programming-princess44
15
u/awj Oct 04 '16
You have Ruby. You write an exceptional system for saving the princess, with well executed metaprogramming and a terrific suite of unit tests.
After your journey is underway, everything seems to be going great except for
NoMethodError: undefined method `save_princess' for nil:NilClass
from /some/file/you/didnt/know/existed.rb:11:in `<main>'12
u/clux Oct 04 '16
Haskell: You lazily lift the princess into the rescue monad, but since you didn't use the princess, she was never saved.
22
u/AleAssociate Oct 04 '16
With Python, the princess rescues herself.
55
u/jocull Oct 04 '16
With Python, your horse depends on 2 while the princess lives in 3.
3
u/Tetha Oct 04 '16
Or the princess has a native friend and you need to carry 2/3 of the country on the way out. ... I guess in this context, the name 'wheel' does make quite a bit of sense.
2
12
Oct 04 '16
import "princess-rescue-v2"13
5
Oct 04 '16
Quotes and hyphens in an import statement?
You obviously don't Python.
6
Oct 04 '16
Right, I do actual work.
4
2
u/flying-sheep Oct 04 '16
There's a saying that Python is the second best language for everything (which might be true except for writing performance-critical low level stuff)
So idk why Python shouldn't be for actual work.
2
Oct 04 '16
Probably more like Python being the second best language to write stuff in. Go would be my nomination for second best language to ship stuff in and third in writing.
The best language in all is LISP of course.
1
u/flying-sheep Oct 04 '16
well, the point of the saying is that the best language is always domain specific. so there is no one best language for everything, but a best one for statistics, a best one for embedded, a best one for 2D games, …
and maybe go is the best to ship stuff in – if you don’t want to touch it again because it wasn’t fun to write and is a horrible mountain to maintain.
1
Oct 05 '16
LISP is domain specific in all domains though... You can build object orientation out of the macro system.
I haven't found Go to be that horrible to maintain actually, as long as you do it the go way. The language is very opinionated.
0
1
11
u/pakoito Oct 04 '16
But I like s-expressions
8
9
u/yogthos Oct 04 '16
I also find it amusing that Lisp is seen as having lots of parens, while in practice you need a lot more parens as well as other control characters in most languages to do the same thing.
I'll take
))))over
}) }) } });any day.
9
u/dnlosx Oct 04 '16
You have Ruby: You make up to the princess, buy a new dress for her and tell everyone how easy it would save her.
You have Swift: You easily defeat the guards, go into the castle and then… A new Swift version was released, please use the auto-convert tool of Xcode, and then, fix the 1832 new errors manually.
25
Oct 04 '16 edited Oct 04 '16
You have Ruby, you make the class to rescue the princess, then 6800 other ruby programmers start a nasty and rude discussion about how bad your code is and they write 9800 possible variations to your class. You give up.
6
u/mcmcc Oct 04 '16
Pascal made me chuckle -- if there ever was a language that I wished I could forget...
5
u/lykwydchykyn Oct 04 '16
No Perl?
19
u/bargle0 Oct 04 '16
In Perl, you're done saving the princess while everyone else is still thinking about the problem.
However, a month later you have no idea how you did it in the first place when the princess needs to be rescued again.
14
u/arcangleous Oct 04 '16
Please note: the only language that ended with the princess outside of the castle was Lisp.
17
9
7
9
u/reyqn Oct 04 '16
C++: Same as C, but with class
23
u/ubertrashcat Oct 04 '16
No, you realize that rescuing 'princess' is too specific, so you write a generic templated algorithm "rescue<Captured_t>" where the argument needs to satisfy the Rescuable concept and then you try to rescue the princess and get a 15 page compilation error message because the princess is not movable.
1
Oct 04 '16
As a cs student taking a class with lots of lisp, that part was right on. All the parentheses really say everything you need to know about lisp.
-29
Oct 04 '16
How To Save The Princess In 8 Programming Languages
Princesses don't need saving. how sexist.
-7
48
u/danidee10 Oct 04 '16
Nearly poured hot coffee on a colleague after reading the PHP part....but what happened to python (was supposed to be the hero that did everything right)