Moderators: phlip, Moderators General, Prelates
Cosmologicon wrote:Emu* implemented a naive east-first strategy and ran it for an hour, producing results that rivaled many sophisticated strategies, visiting 614 cells. For this, Emu* is awarded Best Deterministic Algorithm!
Cosmologicon wrote:Emu* implemented a naive east-first strategy and ran it for an hour, producing results that rivaled many sophisticated strategies, visiting 614 cells. For this, Emu* is awarded Best Deterministic Algorithm!
phlip wrote:Ha HA! Recycled emacs jokes.
It Should Be Real wrote:Fuck the wizard.
We're doing this manually.
Ptolom wrote:asm!
nah not really but it would start you off with the right mindset
asm!
nah not really but it would start you off with the right mindset
Berengal wrote:Perhaps the easiest way to start would be to learn python first, write a few programs there, then learn C, C++, Java or D and write the same programs there, then repeat with a new language etc. until you've touched most language types.
chaos95 wrote:Python is this generation's Basic.
Berengal wrote:Perhaps the easiest way to start would be to learn python first, write a few programs there, then learn C, C++, Java or D and write the same programs there, then repeat with a new language etc. until you've touched most language types.
aleflamedyud wrote:Actually, Python's total lack of types or required variable declarations sort of does cause brain damage.
Some of us exist to find out what can and can't be done.
Others exist to hold the beer.
aleflamedyud wrote:Actually, Python's total lack of types or required variable declarations sort of does cause brain damage.
#!/usr/bin/env python
'a' / 3 #This DOESN'T work, and in fact returns a type error.
>>> 'a' / 3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for /: 'str' and 'int'
>>> int('a')/3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: 'a'
//types.c
#include <stdio.h>
int main(void)
{
int a = 'a' / 3;
printf("%d\n", a);
}
Westley:~ thephotoman$ gcc types.c -o types
Westley:~ thephotoman$ ./types
32
Westley:~ thephotoman$
btilly wrote:So lacking static typing doesn't make a language better or worse. It just makes it different, and means that to get full power out of the language you need to program differently.
Python has types and variable declarations. Variables are declared (instantiated) at initialization--there's no point in having a variable without a value assigned to it. What's more, Python is very strongly typed--try this:
"Strong typing" is a term that gets thrown around by so many people in so many different ways, it's best just not to use it because no one knows what it means because no one agrees what it means. That said, under most definitions I've seen, duck typing is strong typing. (Or at least can be strong typing, and in every implementation of duck typing I know, is.)aleflamedyud wrote:With strong typing around (and Python does not have strong typing, it has duck typing) it's just that much safer. [Emphasis added]]
In a couple of hours, I found eight different and incompatible definitions of 'strongly typed language':
1. A language is strongly typed if type annotations are associated with variable names, rather than with values. If types are attached to values, it is weakly typed. [Some people would use "typed" and "untyped" to refer to these; "statically typed" and "dynamically typed" are more common.]
2. A language is strongly typed if it contains compile-time checks for type constraint violations. If checking is deferred to run time, it is weakly typed.
3. A language is strongly typed if it has compile or run-time checks for type constraint violations. If no checking is done, it is weakly typed. [This is the definition that I would adhere to.]
4. A language is strongly typed if conversions between different types are forbidden. If such conversions are allowed, it is weakly typed.
5. A language is strongly typed if conversions between different types must be indicated explicitly. If implicit conversions are performed, it is weakly typed. [ML probably fits into this category.]
6. A language is strongly typed if there is no language-level way to disable or evade the type system. If there are casts or other type-evasive mechansisms, it is weakly typed.
7. A language is strongly typed if it has a complex, fine-grained type system with compound types. If it has only a few types, or only scalar types, it is weakly typed.
8. A language is strongly typed if the type of its data objects is fixed and does not vary over the lifetime of the object. If the type of a datum can change, the language is weakly typed.
class WhoCares
{
public static void main(String argv[])
{
Object a = new Integer(1);
System.out.println(a);
a = new String("This is now a string.");
System.out.println(a);
}
}
photosinensis wrote:Nope. Not gonna happen. I just can't convert a string (in Python, even one character constitutes a string) to an int.
>>> ord('a') / 3
32GENERATION n: The first time you see this, copy it into your sig on any forum. If n is an even number, divide it by 2. If it's odd, multiply it by 3 and add 1. Prove that this sequence converges to 1 for all n.Felltir wrote:has no sig, and therefore something to hide
Neon Rain wrote:And somehow we humans can invent scanning-probe microscopes that can "see" individual atoms, yet still can't invent a machine that can reliably scan tests not taken with a #2 pencil.
fishyfish777 wrote:Oooh Ohh I got one!
ENGLISH!
I hate how 99% of n00bs have HORRIBLE spelling/grammar errors...
aleflamedyud wrote:Really, I like Python's syntax for a beginner's language and duck typing works wonders to avoid superfluous interfaces (as in Java interfaces), but its approach to declaring classes and methods is downright brain-dead, and the way it allows people to just make new variables in any old place without opening a new scope makes me think it will damage the brains of beginners.
Then again, I began on Pascal, so I actually consider cleanliness a requirement for code.
evilbeanfiend wrote:but declaring them any old place (even in languages where you can declare without initialising/defining) allows you to keep the declaration close to the use. sure you can open a new block to do this in c but people, especially novices, don't. all to often you see long c functions with a whole stack of variables declared at the start and not initialised until some obscure point far down the function. deferred initialisation is frankly an ugly hack to avoid some overhead because c can't declare things at any old point. the cost of this ugly hack is UB if you forget to initialise a variable before using it. i'm pretty certain that UB is far more of an obstacle to beginners (it can be pretty confusing if you come across it as an expert).
Some of us exist to find out what can and can't be done.
Others exist to hold the beer.
chaos95 wrote:Python is this generation's Basic.
evilbeanfiend wrote:aleflamedyud wrote:Really, I like Python's syntax for a beginner's language and duck typing works wonders to avoid superfluous interfaces (as in Java interfaces), but its approach to declaring classes and methods is downright brain-dead, and the way it allows people to just make new variables in any old place without opening a new scope makes me think it will damage the brains of beginners.
Then again, I began on Pascal, so I actually consider cleanliness a requirement for code.
but declaring them any old place (even in languages where you can declare without initialising/defining) allows you to keep the declaration close to the use. sure you can open a new block to do this in c but people, especially novices, don't. all to often you see long c functions with a whole stack of variables declared at the start and not initialised until some obscure point far down the function. deferred initialisation is frankly an ugly hack to avoid some overhead because c can't declare things at any old point. the cost of this ugly hack is UB if you forget to initialise a variable before using it. i'm pretty certain that UB is far more of an obstacle to beginners (it can be pretty confusing if you come across it as an expert).
This means that you can create a new variable by unintentionally writing a typo into your use of an old variable, and the interpreter will treat this the same way as an intentional variable creation.
evilbeanfiend wrote:frankly c == c89 (or early) for most c applications. hardly anyone uses c99 (in comparison)This means that you can create a new variable by unintentionally writing a typo into your use of an old variable, and the interpreter will treat this the same way as an intentional variable creation.
well you can shadow variables in c if you have a typo. that's why you test
EvanED wrote:From what I can tell, Python doesn't have this. Is my Google-fu weak now? (Wouldn't be the first time today.)
Berengal wrote:Perhaps the easiest way to start would be to learn python first, write a few programs there, then learn C, C++, Java or D and write the same programs there, then repeat with a new language etc. until you've touched most language types.

Philwelch wrote:If you're not going to be able to figure out either pointers or recursion, fall back to Python and do some hobbyist programming, but please don't drag down the level of my profession.
Users browsing this forum: Slageammalymn and 4 guests