Now that we're all up to speed, discuss the pros and cons of each language, as well as which you believe to be the superior language.
Name:
Anonymous2007-04-24 18:57 ID:DwbH7Sj5
Brainfuck is sadomasachism for geeks.
Python is Haskell for dummies.
Java is for dummies.
Name:
Anonymous2007-04-24 20:24 ID:fgYYp+33
NO EXCEPTIONS
Name:
Anonymous2007-04-24 20:31 ID:qNEckRqU
Java is a useful yet verbose and ugly language. The libraries it has are set out sort of ok, anyway I find it amusing for coursework because at least you emulate functional programming.
Python, ONE WORD,
THE FORCED INDENTATION OF CODE,
THREAD OVER!
brainfuck is a beautifully elegant gem of programming but idiots like >>2 cant appreciate it
Brainfuck is a Turing tarpit, and a Touring tarpit. Only for lulz.
Java is a piece of shit of a language (good syntax, but stupid object model, stupid operators, stupid lack of features such as operator overloading, stupid constraints, stupid static typing) with a piece of shit of an API (extensive and useful, but completely insane, overengineered, ridiculous, full of enterprise-grade best-practices that create synergy between business logic and operative cost). Productivity will suck, and it may very well be even worse than C.
Python is a quite good languge with a feature set similar to that of Ruby and, to a lesser scale, Lisp. It has a clean syntax (good looking save for __, easy to read, forces idiots to indent statement blocks though nothing else) and a powerful object model, and supports structured, OO and functional programming. It comes with an extensive and useful API that's usually simple to use. Get things done very fast, and good execution speed for an interpreted dynamic languge. Also, QUACK.
also JAVA programmers use a language so fucking verbose they dont mind using a build system which rqeuires them to write XML files
Name:
Anonymous2007-04-25 10:31 ID:IZnYf7Az
I used to think Java was pretty cool. Now I have to use it all the time for uni projects.. If real programming jobs are like this, I will become an hero.
Name:
Anonymous2007-04-25 11:02 ID:eBsE8c7r
>>14
Yes, real programming jobs are like this.
real programmers do programming for a hobby and not to get paid.
Name:
Anonymous2007-04-25 11:29 ID:x2wGFFqe
>>14
get used to fapping to multi-platform, enterprise-grade, scalable solutions to produce synergy using the industry standards
You'll be pleased to know that not all real programming jobs are Java wankfests. But far too many are.
True story, one of my friends had a mental breakdown from having to program Java every day, for 70+ hours a week (he worked in London in the financial sector, they love long hours there)
Name:
Anonymous2007-04-29 15:53 ID:gSxLSN9T
>>4
GTFO. How can you say Java lets you emulate functional programming? It lets you do object-oriented. You obviously have no idea what functional programming is. Python, on the other hand, is multi-paradigm, and lets you try your hand at functional programming.
python takes away all your power because it's sad excuse for functional programming is not supported by Guido van faggot Russo or whatever the fuck and it is dog slow.
Name:
Anonymous2007-04-30 15:58 ID:pLvBtLNK
>>21
Learn to fucking spell. I had to read your post three times to understand what you are trying to say (protip: there's a difference between `it's' and `its'). Anyway, Python indeed sucks really badly for functional programming, and that's a very sad thing. Python itself is pretty useful though, mostly due to the hueg number of do-what-I-want libraries.
Name:
Anonymous2007-04-30 16:14 ID:LLFBVlcK
Python doesn't have lambda's anymore. End of story.
Name:
Anonymous2007-04-30 16:38 ID:Mz6NxB8Y
>>23 ONE WORD, FORCED LACK OF LAMBDAS, THREAD OVER
Name:
Anonymous2007-04-30 16:49 ID:pLvBtLNK
>>23
Python lambdas have always sucked so badly that they have been almost useless. Are they actually going to be dropped in 3K?
Name:
Anonymous2007-04-30 20:49 ID:RmMdNz80
>>21
You can bash Guido for not liking FP much, but Python is the fastest of the modern dynamic languages (at least the barely popular ones).
$ cat >> count.hs << EOD
* count :: Int -> Int
* count i = if i == 100000000 then i else count (i+1)
*
* main = putStrLn (show (count 0))
* EOD
$ ghc --make count.hs -o count
Chasing modules from: count.hs
Compiling Main ( count.hs, count.o )
Linking ...
$ time ./count
100000000
real 0m10.569s
user 0m10.560s
sys 0m0.010s
$ cat > count.c <<EOD
* main() {
* int i;
* for(i=0;i!=100000000;++i);
* printf("%d", i);
* }
* EOD
$ gcc -o count count.c
$ time ./count
100000000
real 0m0.399s
user 0m0.400s
sys 0m0.000s
$ gcc -O3 -o count count.c
$ time ./count
100000000
real 0m0.003s
user 0m0.000s
sys 0m0.010s
Name:
Anonymous2007-05-01 9:25 ID:2UqWc0AY
>>33
Even though you can treat any sequence of bytes in assembly as whatever type you like, whenever you want without indicating that intent, it's not strictly "dynamic" because there is no automatic type conversion. There really isn't any types at all. The only notion of types that assembler has is the difference in some math instructions, which vary depending on data length and whether it's signed or not. FP instructions are also different than integer instructions. But your original data can be any type and the assembler nor the program won't bitch, notice, or even care. Pretty much the only built-in type conversion available period is offered by some sign extend instructions like CBW, CWD, CDQ. (There are instructions available to help convert binary to ascii or BCD but they need other instructions). You have to manually do any type conversion yourself.
Name:
Anonymous2007-05-01 9:25 ID:5HSVbBGx
>>33
No. What you described is weak typing. Dynamic typing != weak typing.
>>36
Let's do something that can't be optimized away: % seq 1 1000000 | tee sorted | shuf > shuffled
% cat > Sort.hs
module Main where
import Data.List (sort) -- Pure Haskell implementation: http://darcs.haskell.org/ghc-6.6/packages/base/Data/List.hs
main = readFile "shuffled" >>= return . unlines . map show . sort . ((map read) :: [String] -> [Int]) . lines >>= writeFile "unshuffled"
^D
% ghc -O9000 Sort.hs --make -osort
% time sort
./sort 59.82s user 1.70s system 100% cpu 1:01.52 total
I'm too lazy to write something in C, of course. Oh, and copying the sorted file or generating a list of numbers is cheating. And this code sucks of course, read is slow as hell.
However, I was surprised at PHP 5's performance so I've done a more realistic test (n times more realistic than yours, n times less realistic than reality; n is a large number).
It consists of a function f(n) -> list of primes up to n, using a simple algorithm. It involves nested loops, simple Maths and list concatenation. Code available below results. Tested on Win32 for 500000 primes.
PHP 4.3.11: 17.078 s
Perl 5.8.7: 11.453 s
PHP 5.2.2RC2: 7.750 s
Python 2.4.2: 6.437 s
Python 2.4.2 + Psyco: 1.141 s
g++ 3.4.2 MinGW -O0: 0.625 s
g++ 3.4.2 MinGW -O3 -funroll-loops: 0.515 s
Important things to see:
1. PHP 5 has got a massive improvement in performance. Now it outperforms Perl, and it's closer to Python than it's to Perl.
2. Python is still the fastest.
3. Python + Psyco is half as fast as C++ for intensive computation, offering a language that's vastly more powerful and flexible, ridiculously more productive, and easier to learn.
4. CFLAGS JUST KICKED IN, YO!
-----------------------
Sauce:
PHP:
<?php
function Primes($max) {
for ($i = 1; $i <= $max; ++$i) {
$prime = true;
$limit = (int) sqrt($i);
for ($j = 2; $j <= $limit; ++$j)
if (!($i % $j)) {
$prime = false;
break;
}
if ($prime)
$a[] = $i;
}
return $a;
}
def Primes(max):
a = []
for i in xrange(1, max + 1):
prime = True
for j in xrange(2, int(sqrt(i)) + 1):
if not i % j:
prime = False
break
if prime:
a += [i]
return a
Primes(500000)
C++ (by Anonymous):
#include <vector>
std::vector<int> primes(int max) {
std::vector<int> a;
int limit(1);
for (int i(1); i <= max; ++i) {
bool isPrime(true);
int newLimit = limit + 1;
if (newLimit * newLimit <= i) ++limit;
for (int j(2); j <= limit; ++j) {
if (!(i % j)) {
isPrime = false;
break;
}
}
if (isPrime) a.push_back(i);
};
return a;
}
int main() {
std::vector<int> v = primes(500000);
}
Name:
Anonymous2007-05-01 21:47 ID:eDA9mLes
>>43
The Python version could be optimized a bit with for/else.
def Primes(max):
a = []
for i in xrange(1, max + 1):
for j in xrange(2, int(sqrt(i)) + 1):
if not i % j:
break
else:
a += [i]
return a
PHP 4.3.11: 17.078 s
Perl 5.8.7: 11.453 s
PHP 5.2.2RC2: 7.750 s
Python 2.4.2: 6.313 s
Python 2.4.2 + Psyco: 1.140 s
g++ 3.4.2 MinGW -O0: 0.625 s
g++ 3.4.2 MinGW -O3 -funroll-loops: 0.515 s
Psyco didn't benefit from this; the specialized code must be the same.
Probably has something to do with Lin/Win, CFLAGS, and 64bit.
And: Psyco only runs on Windows and Linux 32-bit Intel-based machines
So that doesn't really matter for me.
Name:
Anonymous2007-05-02 1:26 ID:AmyrZpU7
Here's a slightly rewritten Perl version. Most of the differences are purely aesthetic, but it gets a decent boost simply from converting the inner for loop to foreach (15s to 9s on my machine):
sub Primes {
$max = shift;
@a = ();
>>45
You're using a release candidate of PHP, but not even the lastest stable Python or Perl?
I'd be interested to see the latest stable of each (Python 2.5.1, Perl 5.8.8, and PHP 5.2.1) compared. If you can't resist using unstable, then use the lastest of each, although I think it's a bad idea.
Name:
Anonymous2007-05-02 18:40 ID:uSeM9WGs
>>49
Yeah, sorry, I'm lazy. I used the Python, Perl and PHP I had right now (on my Windows 2000, 2.4.2, 5.8.7 and 4.3.11), but I also downloaded PHP 5.2 because I was curious about its supposed awesome improvement. I know a more serious benchmark should compare the latest of all.
Anyways, I have to admit PHP has got pretty fast. I'd like to see how it fares against Python for large applications, but it's very hard to compare.