- The PHP bug report
- The Ruby programm
- The Java class
Plankalkül is the first high-level programming language, designed by Konrad Zuse in 1945.
This strip is based on various posts and comments which I found on Reddit’s /r/ProgrammerHumor community.
- Sign: Melody’s Guide to Programming Languages
- Melody: Spoiler: I hate them all.
- Caption: Everything that’s wrong with PHP in a single bug report:
- Caption: Everything that’s wrong with JavaScript in two calculations:
- Caption: Everything that’s wrong with Ruby in a single program that outputs “Hello World”:
- Caption: Everything that’s wrong with Java in a single class:
- Richard: So which language do you use to develop your cutting-edge web application?
- Melody: Plankalkül.
|
@ cacklz:
@ cacklz:
@cacklz: you’re right…it’s still FORTRAN to me (learned it in 1969).
Remember: God is real … unless declared integer.
Speaking of FORTRAN, and other old languages…
With the right compilers (on an HP 3000) and corrent line/character spacing, the following 11 lines will compile under THREE different languages, and will print out the name of the language they’re compiled in. (E..g, compile the file with FORTRAN, and it runs and says “fortran”.)
program main {
c begin comment Note: above { in column 73;
comment; array b(0:1); intrinsic print; move b:=”SPL”;print(b,-3,0);end.
c } (output); {
c} type s16 = -32768..32767; var i : s16; {
c} begin {
c} if sizeof (i) = 2 then writeln (‘CM Pascal’) {
c} else writeln (‘NM Pascal’); end. {
print *, ‘fortran’
stop
end }
“C++ is to C as Lung Cancer is to Lung.” — Charles Hannum
@ Wyzwon:
Anyone for Cobol?
http://www.softpedia.com/get/Programming/SDK-DDK/IDE-Cobol.shtml
Looks to me like there’s something wrong with that one too. 😛
@AndiJN
Sorry if I was not specific enough.
Yes that (the link you posted) is what I meant.
Cache locality matters in many resource intensive areas, among others game programming.
Yet many of today’s applications are resource intensive.
Everything related to image processing, sound processing etc. can profit of better cache locality.
That of course includes many tasks happening on mobile devices.
With better cache locality an algorithm can be multiple times faster and can more easily profit of SIMD instructions.
In the mathematical sense algorithms are hardware independent but in practice there are multiple ways on how to implement an algorithm which can have an huge impact on performance.
Today’s optimizers can do tremendous things, but they are constrained by the data layout you gave them.
A great presentation with demos is [1] and there it is shown that such things can even matter for scripting languages.
Of course the mantra profile first applies and in most cases such optimizations won’t be needed.
[1] https://www.youtube.com/watch?v=GPpD4BBtA1Y
How about Whitespace? I see nothing to complain about there.
@ Matthias:
In that case we’re talking about data structures here, and memory access algorithms, rather than simple code optimization. Seems like we did talk about two different things.
When I hear ‘code optimization’, the first thing I think of is using i++ rather than i = i + 1, or using inline assembly code … things like that, which can make the code quite unreadable, although things like that are not necessary, because the compiler will replace it anyway.
Also, if hardware-specific code is really necessary, it would be better to use an existing library or move it into a new one, rather than mix the inline assembly with higher level algorithmic code, just to make it a tiny bit faster. I mean, that’s the purpose of things like DirectX, that you don’t have to write separate code for every graphics card that exists, like you had to before the VESA BIOS Extensions existed. You can usually just use such libraries without having to know what exactly they are doing. Right?
That’s what I meant. I probably was too short about it, or didn’t find the right words. Sorry about that.
If you want something on perl: There’s a lecture happening at the Chaos Communication Congress in Hamburg right now on that topic.
It’s called “Perl Jam 2: The camel strikes back”, you can probably find it on youtube in a few days. (32C3 is the name of the congress btw).
Xellos wrote:
True, but I see nothing not to complain about there, either. 😉
@ Matthias:
Okay, I looked at that stuff now. But actually, most of this is just common sense, rather than clever optimization tricks. Of course you wouldn’t want to go on a wild linked list goose chase for time critical things and rather use simple arrays. If I want to reuse a value, I always use a variable, rather than calling the function again. And I wouldn’t set a variable inside a loop when it doesn’t have any dependencies inside, I’d rather set it before the loop starts. All this is normal for me and I don’t even have to think about it, I do it automatically like that.
The problem is, many people get too used to / distracted by OOP and fancy data structures nowadays and think common sense is irrelevant since PCs are much faster than in the 90’s. That’s why it’s actually necessary to point out all these things in the Youtube video. But it’s kind of sad.
One more thing, what do you mean with ‘mantra profile’? Google doesn’t tell me anything about it.
@ Brother Parvus:
Oh HO, do I spy a VMS systems programmer? 😎
@ AndiJN:
Yes what you mention is common sense.
SOA, or the performance implications of accessing matrices wrong (row-major order and column-major order) only become common sense when one has deeper knowledge of the underlying hardware.
I meant “profile first”.
If performance is a problem you need to know who the main offenders are.
Guessing won’t do any good.
In that respect [1] is also interesting.
[1] http://stackoverflow.com/questions/15875252/premature-optimization-and-premature-pessimization-related-to-c-coding-standar
Matthias wrote:
Yes, but that’s actually compiler-dependent. On the assembly level you don’t have two-dimensional matrices, so the CPU instruction set doesn’t really matter for this decision. The only ways to find out about things like this is by testing, like in the video, or reading the compiler source code.
Just to make sure, I’m talking about the decision which method of matrix processing is faster here, which one you should use. Of course, if you want to understand or explain why one is better than the other, you would need to know how the the hardware handles this.
@ AndiJN:
In terms of 2D-arrays like my_matrix[10][20] the memory layout depends on the programming language specification, and if there is none for this case on the compiler implementer.
I am pretty sure though that most programming languages specify the memory layout there.
For example, in c++ the memory of my_matrix[10][20] is layed out consecutively — basically in a single array — and elements are accessed via m_data[row * num_cols + col].
So to speak there is row-major order.
What the video boils down to is that it is faster to access an memory consecutively instead of jumping around.
Here’s something about fast memory access:
http://board.flatassembler.net/topic.php?t=2571
Didn’t really understand all of it, but looks interesting.
01001001 01100110 00100000 01111001 01101111 01110101 00100000 01100011 01100001 01101110 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00101100 00100000 01100011 01101111 01101101 01101101 01100101 01101110 01110100 00100000 00100010 01101101 01100001 01110010 01110011 01101000 01101101 01100001 01101100 01101100 01101111 01110111 00100000 01110011 01110101 01101110 01100100 01100001 01100101 00100010 00100001
@ bloodycelt:
I did not copy/paste. I downloaded the gist and run Ruby against it. Copy/pasting from browser interprets nbsps as regular spaces, and thus the result fails, while downloading raw code from gist preserves them, so the program runs.
The examples aren’t very good.
For PHP, a much better example is the fact that md5(‘240610708’) == md5(‘QNKCDZO’) is true. Or the fact that there’s no way to get 64 bit time, do asynchronous or parallel IO, or get a monotonic clock.
The behavior shown is actually more error-tolerant and hence robust.
For JavaScript, the behavior of “var” would be a bigger hit (e.g. Use it as a variable captured by a closure in a loop). Or the fact that you can’t extend classes that have a side-effect in their construction. Not that it matters, since exceptions aren’t class-sensitive.
The behavior shown just shows standard polymorphism, and would work exactly the same in C++. In fact, “-0” is usually the accepted notation for casting to a number in JavaScript.
Also, where’s the example in C for how to define an array of function pointers?
For languages to use… Rust is pretty good, since it’s the last language in which you can still specify how you want your variables to be stored. Although HLVM already proved that a machine can make better decisions than you on that end, if you’re looking for performance rather than certain memory-usage constraints.
LISP-derivative have a long history of producing satisfied developers. Dynamic typing and many parenthesis are often sited as their “flaws”. Optional type annotation can help with the prior. The latter is no worse than brackets in JavaScript or even C.
However, the main problem is in paradigm rather than language. For modern UI-heavy programming, or data-heavy programming, you’re not going to get much better than FRP, and I haven’t seen any languages which target it specifically (Although frameworks exist for most languages).
Also, languages, in general, aim for definition locality. Short of JavaScript built-in support for expando, there’s no support for extending a class with additional data and behavior, or, rather, creating any form of “accumulated” behavior at compile-time. AOP comes close, but still stays very far. A good use-case example is a settings dialog, which requires to be populated with options from many modules and features, but usually ends up monolithic.
@ Christopher:
JavaScript is loosely typed. So ‘5’ and 5 are the exact same thing unless you are using the + operator. If ‘5’ is a string, then anything after the + operator is concatenated even if it is a number. So ‘5’ + 3 is ’53’. This is not so much a problem with the language as it is one with the programmer. This is a rookie mistake. Even if you are dealing with a loosely typed language type is something to consider and you have to know what type is in your variable. Just because the language isn’t holding your hand doesn’t mean you can ignore type.
I prefer strongly typed languages like Java and C# personally. The naming issue with Java is usually a situation of combining multiple naming conversions. Again this is up to the programmer. If “AbstractSingltonProxyFactoryBean” is the actual name of a Java class then this is a problem with the framework that owns the class not the language.
I’ve not yet used ruby. I find PHP’s syntax to be too unreadable and unmaintainable. I’ve been a programmer for almost 14 years. I find Melody to be incredibly naive and extremely unprofessional. This is the know-it-all mentality that is common among programmers right out of college. She is lucky she is a fictional character. She otherwise wouldn’t have a job for long.
I’m going to sound like a pedantic a-hole for this comment, but whatever.
SELECT *
FROM [dbo].READERS
WHERE CLUE_ABOUT_JOKE IS NOT NULL
;
0 row(s) returned
Really.
@ Bizkit:
I know at least javascript, and I gotta say, I’m not getting the joke either. The “everything wrong with javascript” part shows outputs that make perfect sense.
Melody should check Lua 😀
[…] Sandra and Woo » [0747] Melody’s Guide To Programming Languages | The comedy webcomic […]
@ Manuel:
Haha, excellent point 🙂
I couldn’t believe my eyes when I saw that PHP bug report was actually true, that’s some twisted logic!
[…] RT Melody’s guide to programming languages http://www.sandraandwoo.com/2015/12/24/0747-melodys-guide-to-programming-languages/ […]
Python. print “Hello World!” all the way.
It’s going to be ending of mine day, except before end I am reading this impressive post to improve my experience.
The complaint against Javascript is silly. Javascript is lazy, so when you say ‘5’ + 3, it takes the easy way out and adds them as strings, making 53. However, you can’t subtract strings, so Javascript converts 53 into a number and subtracts 3. Really, it’s your fault for passing it a string rather than a number.