Page 2 of 3

Posted: 2006-06-20 11:30pm
by Pu-239
Anyone try Ruby on Rails?

Posted: 2006-06-21 12:31am
by Miles Teg
Dooey Jo wrote:What's wrong with PHP?
The quick and dirty run down:

* No formal language spec or conventions.

* No namespaces

* Dynamic typing is never a good thing for anything other than a one person project (and even then not great).

* Shit poor security model

That said, if they could fix the security issues, it would be an ok language for small projects.

Miles Teg

Posted: 2006-06-21 02:14am
by Faram
Sticky for a bit.

Posted: 2006-06-21 08:13pm
by Pu-239
Miles Teg wrote:
Dooey Jo wrote:What's wrong with PHP?
The quick and dirty run down:

* No formal language spec or conventions.

* No namespaces

* Dynamic typing is never a good thing for anything other than a one person project (and even then not great).

* Shit poor security model

That said, if they could fix the security issues, it would be an ok language for small projects.

Miles Teg
What about Python? And I'm a bit confused about strong vs weak typing and dynamic and static typing

Posted: 2006-06-21 08:41pm
by Beowulf
Dynamic typing is the type of a variable not being determined until it's used. A string "45" can be used as a number 45. Static typing is every variable having a type that can't be changed.

Strong typing is the prevention of mixing types in an operation: string "45" + numeral 1, for example. Weak typing is the reverse. I could increment the string "45" and get "46" back.

Dynamic typing isn't entirely bad. It's an essential feature of polymorphism. If you've never used polymorphism in a project, I'd suggest you learn OO programming.

Posted: 2006-06-21 10:25pm
by Pu-239
Beowulf wrote:Dynamic typing is the type of a variable not being determined until it's used. A string "45" can be used as a number 45. Static typing is every variable having a type that can't be changed.

Strong typing is the prevention of mixing types in an operation: string "45" + numeral 1, for example. Weak typing is the reverse. I could increment the string "45" and get "46" back.

Dynamic typing isn't entirely bad. It's an essential feature of polymorphism. If you've never used polymorphism in a project, I'd suggest you learn OO programming.
But what's especially bad about it?

Posted: 2006-06-21 11:31pm
by Beowulf
Pu-239 wrote:
Beowulf wrote:Dynamic typing is the type of a variable not being determined until it's used. A string "45" can be used as a number 45. Static typing is every variable having a type that can't be changed.

Strong typing is the prevention of mixing types in an operation: string "45" + numeral 1, for example. Weak typing is the reverse. I could increment the string "45" and get "46" back.

Dynamic typing isn't entirely bad. It's an essential feature of polymorphism. If you've never used polymorphism in a project, I'd suggest you learn OO programming.
But what's especially bad about it?
It's hard to tell what type an object is. Which makes it easier to do something you didn't mean to do.

Posted: 2006-06-22 12:19am
by Pu-239
Beowulf wrote:
Pu-239 wrote:
Beowulf wrote:Dynamic typing is the type of a variable not being determined until it's used. A string "45" can be used as a number 45. Static typing is every variable having a type that can't be changed.

Strong typing is the prevention of mixing types in an operation: string "45" + numeral 1, for example. Weak typing is the reverse. I could increment the string "45" and get "46" back.

Dynamic typing isn't entirely bad. It's an essential feature of polymorphism. If you've never used polymorphism in a project, I'd suggest you learn OO programming.
But what's especially bad about it?
It's hard to tell what type an object is. Which makes it easier to do something you didn't mean to do.
That's it? Doesn't anybody use comments (and meaningful variable names)? :P

Posted: 2006-06-22 12:53am
by Mad
Looks like the current them is stuff that changes text input around.

Here's a quick submission. This is an essay rewriter. Takes sentence phrases (separated by punctuation) and reorganizes them into a few paragraphs. So you can convert a long, boring essay into something hopefully more fun.

Of course, the real fun that I had was doing this with no braces in the source code (except the ones required for main(), of course). (There's also the boring, readable, class-using version I whipped up first. But what fun is that?)

It reads from standard input and sends to standard output. Either redirect from a file or use CTRL+Z on an empty line in Windows to end. (If you're running UNIX or Linux, the key combo to signal end of input is different, but you should already know it. :P)

C++ source compiled and tested using GCC 3.3.2 on Windows (MinGW) and Solaris (g++).

Code: Select all

#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#define BRACES_ARE {
#define FOR_CHUMPS }
using namespace std;
const string SENTENCE_END = ".!?";
const string SENTENCE_MIDDLE = ",;:";
int main(int argc, char *argv[]) BRACES_ARE
string source_string;
string rewritten;
vector<string> starter;
vector<string> middle;
vector<string> ender;
vector<string> simple;
srand(0);
while(cin) source_string += cin.get();
int num_fragments = 0;
string fragment;
bool cont = false;
bool makezero = false;
bool clearit = false;
string::const_iterator p;
for(p = source_string.begin(); p != source_string.end(); ++p)
if(!(fragment.empty() && isspace(*p)))
goto tehwoot;
else
ret: continue;
goto ohdone;
tehwoot:
clearit = false;
makezero = false;
fragment += *p;
if(SENTENCE_END.find(*p) != string::npos &&
(clearit = true) && (makezero = true))
if(++num_fragments == 1)
simple.push_back(fragment);
else
ender.push_back(fragment);
else if(SENTENCE_MIDDLE.find(*p) != string::npos && (clearit = true))
if(++num_fragments == 1)
starter.push_back(fragment);
else
middle.push_back(fragment);
if(clearit) fragment.clear();
if(makezero) num_fragments = 0;
goto ret;
ohdone:
if(starter.size() == 0) starter.push_back("Hello,");
if(middle.size() == 0) middle.push_back("if you didn't know,");
if(ender.size() == 0) ender.push_back("braces suck!");
if(simple.size() == 0) simple.push_back("That is all.");
for(int i=0; i<3; ++i, rewritten += "\n\n")
for(int j=0, n=rand()%5-1; j<10; ++j, n = rand()%5-1)
if(n == -1)
rewritten += simple[rand()%simple.size()]+ " ";
else
for(int k=0; k<n; ++k, rewritten += ender[rand()%ender.size()] + " ")
if(!k) rewritten += starter[rand()%starter.size()] + " " +
middle[rand()%middle.size()] + " ";
else rewritten += middle[rand()%middle.size()] + " ";
cout << "Moblin says: Jumble, jumble..." << endl << endl;
cout << rewritten << endl;
return EXIT_SUCCESS; FOR_CHUMPS;

Posted: 2006-06-22 02:47am
by Miles Teg
Pu-239 wrote:
Beowulf wrote:
Pu-239 wrote: But what's especially bad about it?
It's hard to tell what type an object is. Which makes it easier to do something you didn't mean to do.
That's it? Doesn't anybody use comments (and meaningful variable names)? :P
lol Of course they do!

Dynamic typing tends to lead to large amount of runtime errors, whereas static typing tends to reduce runtime errors because they are caught at compile time. (Compilers are infinitely better at catching errors than any human will ever be). It basically boils down to this: In a statically typed language I feel its easier to concentrate on solving a problem because I can let the compiler deal with making sure I'm not trying to find the square root of "A" because some schmuck passed my function a string instead of an int ;-)

Miles Teg

Posted: 2006-06-22 09:47am
by Mad
In addition, if the interpreter is constantly casting the variable as different types, the program will run slower.

Some editors can list the members and methods of classes or structures while typing an identifier to them elsewhere in the source. Of course, in order to make use of that, the editor has to know what the identifier is referring to.

Posted: 2006-06-28 11:13am
by Mad
No more entries? Lack of ideas/direction? (Lack of time?)

Posted: 2006-06-28 03:29pm
by Dooey Jo
I could post the code for the game I'm currently writing. Only it's probably around 20 000 lines or so :wink:

Posted: 2006-06-28 10:49pm
by Chris OFarrell
I was going to paste this work of horrible art as a slab of text...but I'll be nice and seperate it a little.

I'm curious to see who can work it out WITHOUT dumping it into a compiler.


#define C1 1000

#include<stdio.h>

int main()
{
int A1[C1],I1,I2,I3,I4,I5,I6,I7;
A1[0]=2;I2=1;
scanf("%d",&I1);
I3=1; I6=0; I7=4;
for(;I2<I1;I2++)
{
I4=0;

L1:
I3+=2; I5=0;
if(I3>=I7)
{
I6++; I7=A1[I6]*A1[I6];
}

do I5++;
while(I5<I6&&I3%A1[I5]!=0);

if(I5>=I6)I4=1;

if(!I4)goto L1;
A1[I2]=I3;
}

I2=0;
L2:

printf("%8d",A1[I2]);
I2++;
if(I2%10==0)printf("\n");
if(I2!=I1)goto L2;
if(I1%10!=0)printf("\n");

return 0;

}

Posted: 2006-06-28 11:04pm
by phongn
Can I find a C interpreter and do that instead? :lol:

Posted: 2006-06-29 12:28am
by Mad
phongn wrote:Can I find a C interpreter and do that instead? :lol:
That's cheating. You have to convert it to a different language and run it through that compiler instead. I choose C++. :mrgreen:

Oh, and it crashes if you enter a number that's too big, that's what it does.

Actually, I figured out the first three numbers by running it through my head and took a guess from there. I ran it and was correct.

Big hint (but not as big as running it :P): they're pretty easy because a lot of logic used later is skipped for the first numbers. Things get more complex after that, but the first numbers tell you all you need to know. The guess is assuming the rest of the code works, because if it doesn't, I'd be wrong.

Posted: 2006-07-05 08:57pm
by Durandal
Miles Teg wrote:* No namespaces
Frankly, I couldn't give two shits about namespaces. They're designed to solve a problem that is the result of poor design: conflicting function names. I prefix all my class methods with a class acronym. WOW! I just made namespaces totally redundant!

Posted: 2006-07-06 09:46am
by Chris OFarrell
Durandal wrote:
Miles Teg wrote:* No namespaces
Frankly, I couldn't give two shits about namespaces. They're designed to solve a problem that is the result of poor design: conflicting function names. I prefix all my class methods with a class acronym. WOW! I just made namespaces totally redundant!
You use common sense instead of an over the top, insane, elaborate....oh right, you work for Apple instead of Microsoft no? :)

Posted: 2006-07-06 08:03pm
by Durandal
I feel the same way about multiple inheritance. Talk about a feature that is completely useless for 99% of programmers. "OMG I'VE GOT CONFLICTING ATTRIBUTES!" Well design your class structure better next time.

Posted: 2006-07-06 08:37pm
by Pu-239
Durandal wrote:
Miles Teg wrote:* No namespaces
Frankly, I couldn't give two shits about namespaces. They're designed to solve a problem that is the result of poor design: conflicting function names. I prefix all my class methods with a class acronym. WOW! I just made namespaces totally redundant!
Well, it makes for less typing... I think? Don't have to type the prefix on everything, and it can be changed later w/o mass renaming. Also you have 3rd party libraries who's names may conflict...

Posted: 2006-07-06 08:46pm
by phongn
Durandal wrote:I feel the same way about multiple inheritance. Talk about a feature that is completely useless for 99% of programmers. "OMG I'VE GOT CONFLICTING ATTRIBUTES!" Well design your class structure better next time.
Bah. I like namespaces, though I know they are abused. As for multiple inheritance - I can't tell if you say it's a good thing or bad thing?

Posted: 2006-07-06 09:33pm
by Mad
Durandal wrote:
Miles Teg wrote:* No namespaces
Frankly, I couldn't give two shits about namespaces. They're designed to solve a problem that is the result of poor design: conflicting function names. I prefix all my class methods with a class acronym. WOW! I just made namespaces totally redundant!
In that case, is "boost::regex" really so much harder to type than "boost_regex"?

In any case, namespaces are just a natural extension of scoping rules. Why not just have a bunch of global variables each prefixed with the function they belong to? Then you won't have any conflicting variable names and you can use them whenever you need to. :P (The correct answer is "that's stupid, and it prohibits recursion.")

Code inside a namespace looks a lot cleaner without class prefixes dangling around everywhere. (Sorta like you're probably glad you don't have to use this to reference methods and members... unless you're using PHP.)

Posted: 2006-07-06 09:55pm
by Durandal
Mad wrote:In that case, is "boost::regex" really so much harder to type than "boost_regex"?
No, but "boost_regex" looks nicer. :D
In any case, namespaces are just a natural extension of scoping rules. Why not just have a bunch of global variables each prefixed with the function they belong to? Then you won't have any conflicting variable names and you can use them whenever you need to. :P (The correct answer is "that's stupid, and it prohibits recursion.")
The other correct answer would be that variable names are reused far more frequently than function names. See 'i', 'j' and 'k'. My personal favorite is from the guide to writing unmaintainable code.

marypoppins = superman + starship / god;
Code inside a namespace looks a lot cleaner without class prefixes dangling around everywhere. (Sorta like you're probably glad you don't have to use this to reference methods and members... unless you're using PHP.)
Actually, being an Mac OS X developer, I work in Objective-C. When calling an internal method, you send the message [self methodName]. Makes it easy to tell where the call is coming from. Since method calls are actually messages, you can have two different classes have the same method names without any need for scoping.

By the way, I take it that everyone here has read the Guide to Writing Unmaintainable Code?

Posted: 2006-07-27 06:13am
by Dooey Jo
Destructionator XIII wrote:The awesome part is 16k is so pathetic. Even the NES had 64k of memory, in addition to the sprite buffer. There's an idea to get around the framebuffer issues: force you to use sprites like the NES did.
Heh, you think 16k is pathetic? Try the Atari 2600. It had 128. Bytes! And 4k of ROM storage. Now that's shit :lol:
Am I the only one who thinks this would be fun as hell, or does it sound like a good challenge?
It sure sounds challenging... Though on the topic of NES, I think it would be cool to make some kind of (un)official SDN NES game or something...

Posted: 2006-07-27 12:42pm
by Mad
Destructionator XIII wrote:Still, I'd be willing to try a SDN NES game.
Now that would rock.