ITT:
We write different ways to produce 'hello world' in the shell
language : c++
no syntax errors, and no copying others work. I'll start with something simple
Compile javac this and run it through a Java bytecode interpreter: \u0063\u006c\u0061\u0073\u0073\u0020\u004d\u0061\u0069\u006e
\u007b
\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0076\u006f\u0069\u0064\u0020\u006d\u0061\u0069\u006e\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0061\u0072\u0067\u0073\u005b\u005d\u0029
\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007b
\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0053\u0079\u0073\u0074\u0065\u006d\u002e\u006f\u0075\u0074\u002e\u0070\u0072\u0069\u006e\u0074\u006c\u006e\u0028\u0022\u0048\u0065\u006c\u006c\u006f\u0020\u0057\u006f\u0072\u006c\u0064\u0022\u0029\u003b
\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007d
\u007d
I remember once posting a Brainfuck program that outputted a Perl script that outputted a Brainfuck program that printed 'Hello, World' or some other combination of BF and Perl.
# Clear empty lines to keep it clean
basic = filter(None, basic.splitlines())
# Considered harmful
goto = {}
for pos, code in enumerate(basic): # pos is "real" line num, code.split()[0] is basic line num
goto[code.split()[0]] = pos
# Interpret BASIC code
pos = 0
while pos < len(basic):
line = basic[pos] # Get line
if match(PRINT, line):
print get_arg(line, PRINT) # Print argument
elif match(GOTO, line):
point = get_arg(line, GOTO)
pos = goto[point] # Pass line number through goto table
continue # Don't increment pos as usual
pos += 1 # Next line
Name:
Anonymous2010-09-18 6:11
I call on the power of infinate monkeys to help me with this
#include <stdio.h>
int main() {
int i,c=0150;
for(i=0;i<12;i++) {
switch(i) {
case 2: c += 4;
case 4:
case 8: c += 3;
case 0:
case 3: break;
case 5: c &= 176; break;
case 6: c |= 87; break;
case 7:
case 10:c -= 2;
case 9: c -= 3;
case 1: c -= 3; break;
case 11: c ^= 'n'; break;
}
putchar(c);
}
}
In Java, the idea of a namespace is embodied in Java packages. All code belongs to a package, although that package need not be explicitly named. Code from other packages is accessed by prefixing the package name before the appropriate identifier, for example class String in package java.lang can be referred to as java.lang.String (this is known as the fully qualified class name). Like C++, Java offers a construct that makes it unnecessary to type the package name (import). However, certain features (such as reflection) require the programmer to use the fully qualified name.
Unlike C++, namespaces in Java are not hierarchical as far as the syntax of the language is concerned. However, packages are named in a hierarchical manner. For example, all packages beginning with java are a part of the Java platform—the package java.lang contains classes core to the language, and java.lang.reflect contains core classes specifically relating to reflection.
In Java (as well as Ada, C#, and others), namespaces/packages express semantic categories of code. For example, in C#, namespace System contains code provided by the system (the .NET framework). How specific these categories are and how deep the hierarchies go differ from language to language.
Function and class scopes can be viewed as implicit namespaces that are inextricably linked with visibility, accessibility, and object lifetime.