The one they have with <?php print("Hello World"); ?> is also an opcode longer than using <?php echo "Hello World"; ?> because off the FREE on the return value from the print. But a file just containing the string: Hello World
and nothing else will generate the same opcodes as the echo version so they are equivalent and you might as well use the shorter form. A file without an opening <?php tag is still a perfectly valid PHP program.
But one way that is easier than diving into the source code is to just dump the opcodes using vld (see pecl.vld). I have a little wrapper shell script /usr/local/bin/vld:
While Hello World is nice, something a bit more involved could give you more insight. Among many people, Amit Singh (of MacFuse and Mac OS X Internals fame) did this with the Towers of Hanoi: http://www.kernelthread.com/projects/hanoi/ (111 Hanoi implementations total).
One of my favourites is 99 Bottles, with just under 1,500 implementations: http://99-bottles-of-beer.net/abc.html - some are inspiring, but others are just plain funny.
Why is Morse code included? I'm not being flippant, but rather genuinely curious as to whether there's some basis for it being considered a "programming" language or precursor thereof.
I started to read Code: The Hidden Language of Computer Hardware and Software by Charles Petzold two days ago - and he starts with morse code (and braille). You're right, it's no programming language (just an encoding) - but seemingly near conceptually to a language (for Petzold, anyway - yay it's got 0's and 1's, too).
Does the book really focus on Morse code having 0s and 1s? Isn't it technically a ternary encoding as opposed to a binary (0/1) one? The gaps between letters are pretty significant.
This is what I found funny about Gmail Tap 28 days ago. They managed to take Morse Code - a tertiary encoding with only one input button - and "simplify" it by having three buttons.
You could say the same about C. Sure, the C standard library is specified along with the language, but it's still a library, not a set of language features. You could have C without the stdlib. So does that mean an example in C with an alternative IO library would be ok, but not a similar example in Python?
I don't think whether IO is built into a language is really the important question. If people are interested in seeing how IO works with different frameworks, those examples should be there. But if people just want to see what a language's basic syntax looks like, not the specifics of emitting IO in various frameworks, there should be one example per language, even for languages which lack built-in IO.
It's a language that predates C. Maybe some the things that you take for granted are not there, and some syntax is weird, and order of evaluation is strict left-to-right. (i.e. "'x+1=2+3" first computes 'not x', i.e. 0 or 1 if x=1 or x=0 respectively, then adds 1 to the result, then compares that result to 2, then adds 3 to that result, giving either 3 or 4 as a final answer).
but if you write controlled, sensible code, then it's actually not. certainly never my language of choice but it it's not just still used due to inertia... it's pretty fast, it makes database interaction easy, it's pretty easy to understand if the code isn't doing something awful like assuming variables and relying on hidden state. (which you can do, yes.)
if you're talking about the Daily WTF articles, then no it's not nearly as bad as those articles would imply. I worked for a company that is probably featured in one, but not all, of those articles... we had good tools, good coding standards/dev process, a good internal API/libraries that do quite a lot, and sensible people. Under these circumstances it was not bad--I'd actually grown quite fond of it. (No codebase of a large old company will be WTF-free but this isn't language-specific. I don't think any actual code from those Daily WTF articles actually comes from that company...)
Also, "A Case of the MUMPS" gets many things wrong.
'Scope of IF and FOR is "remainder of current line."' Nope. That's what 'do' is for. Note that ';' comments out everything to the right on the same line.
for i=1:1:100 do ; equivalent to 'for(int i=1;i<101; i++) { }', with the lines below indented with a period serving as the body of the brackets
. write !,"line 1 of code block, iteration "_i
. write !,"line 2 of code block, iteration "_i
. write !,"line 3 of code block, iteration "_i
write !,"Done with loop" ; this gets executed after the for loop
Note that I'd actually write this as 'f i=1:1:100 d' and 'w "string"' in place of "for i=1:1:100 do" and 'write "string"'. It's just as easy to read if you know the language, especially if you have nice syntax highlighting, and easier to write. Which brings me to...
'To edit the code stored in the “database”, developers needed to use the internally-created text editor.'
Not in our case, and this makes me wonder how long ago this guy's experience was. in our case, the vendor provided an IDE and we also had our own, written in C#, which is actually my favorite IDE from any language.
I can't think of a more usable productive language from the 60s that still survives. It's got a lower barrier of entry than C, and it's miles better than BASIC. It's more friendly than BASIC in fact, while still being faster, and is way more accessible than FORTRAN or COBOL.
You want to do FizzBuzz? I present the shortest FizzBuzz in almost any language other than APL or Perl:
f i=1:1:100 w ! w:'(i#3) "Fizz" w:'(i#5) "Buzz" w:'$x i
Or, in pseudocode:
for i=1:1:100
print "\n"
if not (i%3) print "Fizz"
if not (i%5) print "Buzz"
if not x_pos_of_cursor print i
Ah, yes, and don't ever use dot notation as above if you plan on wanting comments on your line, i.e.
for
. blah
; some comment here
. foo
foo here won't execute. Instead this works:
for
. blah
. ; some comment here
. foo
Tripped me up the first time I dealt with that... however, these days with Caché ObjectScript (the most popular MUMPS dialect) it'd be written:
i.e.: i'm one of the most senior ACT3 programmers worldwide. (well, there were only about a dozen or so people) it was a programming language used extensively at the national austria press agency. it was - at it's time (around 2001) - for more advanced as PHP 4. the hello world would have looked something like this
<!--%'hello world'-->
(the <!-- --> was a relict from ACT2 ...)
yes it was an abomination, but it worked, and it was fast.
ok, anyway, ARC is missing, too. I think the claim "every programming language" is a) wrong and b) not really feasible.
"every programming language" is an infinite set. Every programming language where an interpreter/compiler was implemented once is maybe better. But, when you consider that most programmers have at one point invented their own language, or languages (I cannot really count how much toy languages I have created at some point), it is still way too much and impossible to get them all. Maybe more restrictive would be to take languages which at least 2 people have used at one point. But even then...
The point I'm trying to make is: "Every programming language" will always be wrong.
Hello World
The one they have with <?php print("Hello World"); ?> is also an opcode longer than using <?php echo "Hello World"; ?> because off the FREE on the return value from the print. But a file just containing the string: Hello World and nothing else will generate the same opcodes as the echo version so they are equivalent and you might as well use the shorter form. A file without an opening <?php tag is still a perfectly valid PHP program.