What's the next big language?
03-15-2009, 06:34 PM
|
Re: What's the next big language?
|
Posts: 3,176
Name: Thierry
Location: I'm the uber Spaminator !
|
Quote:
|
I am interested in application scalability, as it applies to the web, at least.
|
I won't be able to help you there. My application is a daemon (a service in the windows world) that listen to requests, starts them if they are not in cache.
It's not web based.
Quote:
|
Will I be able to deal with the increased load without understanding how multiple processors work in conjunction with each other when traffic scales way up?
|
I seriously hope so.
This is not the work of PHP, but of the web server.
What can help, is to switch apache to a threaded model. The default is a forked model.
Forked model is ok for low to middle range traffic. Threaded model is more recommended for high traffic.
Mostly because the implacations can be somewhat bad if you don't know what you do.
I don't really know what I did, but the tests seems to show an increased answer rate, and somewhat less memory used.
Quote:
|
Is it even important for me to understand this?
|
I'd say that no.
If you plan this from the beginning, it can help when you are hit by it, but optimizing for really high traffic is in fact de-optimisation for low to middle traffic.
It means un normalizing the database, it means caching pages (and thus limiting the "dynamic" of your site), it means spreading your site on several servers to even the load.
All this cannot be done solely on the PHP level, and you will need an experienced IT team to adapt the hardware as well as the software.
I had the chance to go through this with my first job. It was a local dating site, and it rocketed.
It meant: having a "head" web server that dispatched the requests to 5 slaves web servers. The web servers talked to a 6 postgresql servers db cluster and 4 mysql servers cluster.
The postgresql was the main DB, but synthetic view of several pages where kept in mysql, for speeding up the beast.
The count(*) in the mail part of the site where simply killing the postgresql servers. And when some users had more than 1'000'000 messages, the page could take 2 minutes to render.
Some simple flags where moved in mysql too (new mail, contact updated, near end of membership) for the same reason.
A simple filesystem based caching mechanism relying on output buffering functions was implemented too, and certain parts of the web pages where cached for a customized time, usually 15 minutes.
At a certain time, I even introduced an adaptive caching mechanism that was incrementing the cache validity dynamically to adapt itself on the servers average load.
But, back to your original question, what I can tell you, is that converting the gateway between the web and the daemon from PHP to python gave me an increased display/seconds count with Apache Benchmark.
I went from 12 to 35 requests per seconds.
But, to be 100% fair to PHP, the language is not the only to be taken in account.
The php version is the result of several tries and different implementations.
It's 1300 lines long, and I'm certain that refactoring it could have speed it up.
The python version is 720 lines long, but I used all the help that python could give me.
Especially when iterrating over an array, where php is
PHP Code:
$this->ip= $_SERVER['REMOTE_ADDR']; $this->host=gethostbyaddr($this->ip); $aryAllowed=$GLOBALS['objAuth']->getIp('allowed','ARY'); $aryDenied=$GLOBALS['objAuth']->getIp('denied','ARY'); $denied=FALSE; foreach($aryDenied as $key=>$ip){ //checking the blacklist $ip=sanitize($ip); if($ip==''){ break; } if($ip=="*"){ $this->logger("denied to all"); $denied=TRUE; } elseif(!is_ip($ip)){ $this->logger("denied $ip is an host"); if(gethostbyname($ip)==$this->ip){ $denied=TRUE; } } else{ $this->logger("denied $ip is an ip"); if($ip==$this->ip){ $denied=TRUE; } } } if($denied===TRUE){ //checking the whitelist. An entry in the whitelist revoke the blacklisting. foreach($aryAllowed as $key=>$ip){ $ip=sanitize($ip); if($ip==''){ break; } if(!is_ip($ip)){ $this->logger("allowed $ip is an host"); if(gethostbyname($ip)==$this->ip){ $denied=FALSE; } } else{ $this->logger("allowed $ip is an ip"); if($ip==$this->ip){ $denied=FALSE; } } if($ip=='*'){ $this->logger('allowed to all'); $denied=FALSE; } } } $stat=($denied===TRUE)?"denied":"granted"; error_log("access is $stat");
where python is:
Code:
def checkAccess(self):
ret=white=black=False
if self.parent.ip in self.blackList or '*' in self.blackList:
black=True
if self.parent.ip in self.whiteList or '*' in self.whiteList:
white=True
if white and black:
#whitelist voids blacklist
ret=True
elif white and not black:
#whitelist
ret=True
elif black and not white:
#blacklist
ret=False
else:
#whitelist by default
ret=True
return ret
As for the multithreading of the python web part, it's the framework I use that handle it (webpy).
I could see from the logs that several requests can be handled simultaneously faster than in PHP.
The PHP manual tells that PHP is not designed to be multi-threaded, and advise against it, as many modules can be non thread safe.
The fact is, that when the gateway web<->daemon was in php, never more than 2 reqests ended on the daemon from the same source at the same time.
Since I switched to python, I see sometimes 12 requests in a window of 3 milliseconds from the same ip.
There is definitively something different between mod_php and mod_wsgi and apache. It's like mod_php would limit by itself the processing queue he have.
What should be kept in mind, too, is that even if PHP is running in the form of a module, with an opcode cache, it is still a "connect to the db, do stuff, and die" process.
Python, as .NET and java, is an executable that stays up all the time, and answers to requests. It allows the interpreter to be somewhat more optimized, I think.
But I have not hard facts to prove that.
It's just a guess, fonded after almost 20 years of computing, and a certain capacity to understand how a computer works.
__________________
Only a biker knows why a dog sticks his head out the window.
|
|
|
|
03-30-2009, 08:52 AM
|
Re: What's the next big language?
|
Posts: 6
Name: No
|
I don't think C++ will be replaced to be honest.
|
|
|
|
03-30-2009, 12:42 PM
|
Re: What's the next big language?
|
Posts: 1,066
Name: Matt
Location: Irvine, CA
|
Quote:
Originally Posted by ocZio
I don't think C++ will be replaced to be honest.
|
Isn't that already happening?
Of course there will be many jobs that involve maintaining C++ code for a long time (just as there is money to be made maitaining cobol code), but that does not mean new software should be written in C++.
The real advantage C++ has over many other newer languages is speed, but that advantage is being marginalized even by interpreted languages like Java.
|
|
|
|
03-30-2009, 05:21 PM
|
Re: What's the next big language?
|
Posts: 1,388
Name: Paul Davis
Location: San Francisco
|
I expect the next big language to be something like Scala, Haskel, or Clojure.
It seems like a lot of new languages are designed to compile to JVM byte code. The main benefit of this is platform independence and the ability to leverage a mature VM with garbage collection and runtime optimization.
Writing a VM with decent performance is a pretty difficult task. Compiling to the various OS/CPU combinations is just a pain.
Tools like JavaCC make creating a new language a fairly simple task.
If you really want to go native, the best bet is to create a front-end for the GCC compiler. This can greatly simplify building on multiple platforms.
|
|
|
|
07-02-2009, 03:48 PM
|
Re: What's the next big language?
|
Posts: 1
Name: Brian
|
I absolutely think WYSIWYG editors are hurting hard-core coders, but at the same time, it's helping to broaden the range of people who can be "web programmers" by definition. However, I don't think you can really call yourself a "web programmer" if you don't know at least a little coding. CSS, HTML, anything...
|
|
|
|
07-05-2009, 11:24 AM
|
Re: What's the next big language?
|
Posts: 164
|
In a way it helps proper coders when the majority is drawn towards the easy way around. A lot of salaried programmers are really out of touch vis a vis mavericks/entrepreneurs etc - because they are forced (it's not their fault, the system DEMANDS it of them) to favour softer approaches to building. It helps us because it makes it that much easier for us to stay on top of everyone else.
If you consider the whole OOP model it's soft in the head - an average "procedural" response to a problem that takes say 3 hours to code would take at least 36 hours (including the time between each day of work) to properly code, as it is a real headache, absolutely not done from just thinking through all the stuff in your head, to sit down and create a piece of code which has a finger in 15 other coding pies and needs to be made to work in synch with them and use boring standard stupid variable names with no glamour so that anyone would be forgiven, if they saw your code, for thinking that programming is BORING!!!!
That's the real crime these appeasers commit! One would sympathize with every last hacker alive, since they gladly defy it all, but for the fact that a lot of them are just criminal goons who should be locked up!
I'd still be wary of calling css or html "languages" where "language" is a "computer language" - they are just markup. Definitely not acceptable as a substitute for language training. Any language (even bbc basic or, Chip forbid, bbc's precursor to the entire worldwideweb {visually, sort of, if you think about it}, "logo").
Nonetheless, my key aim is to finish coding a fullscale "a.i." environment including a full development environment and the language I use to write any software at all will be English - succinct English. I shall tell my a.i. driven machine what I want, and it will write it for me! It may need to ask me a few questions and I'll gladly answer, but that's about the fullest extent of the work I'll have to do, if I achieve my goal with the a.i. environment.
__________________
I acknowledge Parker out of Thunderbirds and Glaxo Industries.
Last edited by hairygunther; 07-05-2009 at 11:27 AM..
|
|
|
|
07-05-2009, 10:28 PM
|
Re: What's the next big language?
|
Posts: 492
Name: Lashtal
|
Quote:
Originally Posted by hairygunther
Nonetheless, my key aim is to finish coding a fullscale "a.i." environment including a full development environment and the language I use to write any software at all will be English - succinct English. I shall tell my a.i. driven machine what I want, and it will write it for me! It may need to ask me a few questions and I'll gladly answer, but that's about the fullest extent of the work I'll have to do, if I achieve my goal with the a.i. environment.
|
This is something I thought about doing but lack the knowledge to do.
Such a system would be off the hook/frickin' sick.
|
|
|
|
07-05-2009, 10:29 PM
|
Re: What's the next big language?
|
Posts: 492
Name: Lashtal
|
or, how 'bout this: a WYSIWYG PHP editor.
|
|
|
|
07-06-2009, 03:22 AM
|
Re: What's the next big language?
|
Posts: 1,066
Name: Matt
Location: Irvine, CA
|
Quote:
Originally Posted by Lashtal
or, how 'bout this: a WYSIWYG PHP editor.
|
One thing everyone should understand about software and programming is that most programs do not have a user interface. In language like PHP code does not necessarily translate into something you see. HTML and CSS on ther otherhand are meant for creating interfaces. I have seen wysiwyg editors for programming languages (c in particular) but they are typically very limited and aimed toward beginners and non-programmers.
If someone did create a non-trivial wysiwyg PHP editor, it would share the same problems as current wysiwyg editors (to an even greater degree): bad code. If you want to be a programmer you have to write code. There is no short-cut or work around.
Regarding the topic, as I mentioned a while back when this thread was first posted, I think the future of programming lies in highly parallel languages. As I mentioned before LISP and functional languages are inherently parallel, but actor model (Axum, Erlang, Haskell) give the programmer control over which processes run in parallel.
In part I think that parallelism is a job for compilers and interpreters, but considering the brick wall engineers have hit regarding the number hertz a processor can have and the rise of multi-core processors I think we may see the decline of OOP.
|
|
|
|
07-07-2009, 10:37 PM
|
Re: What's the next big language?
|
Posts: 492
Name: Lashtal
|
What do you guys think of Ruby, and what do you think about the future of Ruby?
|
|
|
|
07-10-2009, 02:38 PM
|
Re: What's the next big language?
|
Posts: 3,150
Name: Abel Mohler
Location: Asheville, North Carolina USA
|
I don't know a whole lot about RoR (Ruby on Rails), but I believe that Twitter is the largest RoR application every deployed. I have read rumors they are considering switching to PHP because they've had a lot of problems scaling the application when Twitter's user-base exploded. I've read more about scalability since this thread started, and know that PHP is well proven (by Yahoo) to be able to run massive web applications with millions of users. Of course, most of us will never need to deal with this fully, but I think it is useful to know something about it.
Here's the article I read about RoR and Twitter (though it's just a rumor) Twitter Said to be Abandoning Ruby on Rails.
|
|
|
|
07-10-2009, 06:40 PM
|
Re: What's the next big language?
|
Posts: 1,388
Name: Paul Davis
Location: San Francisco
|
rumor from May 2008?
Actually, Twitter recently switched the backend code to Scala.
( http://www.artima.com/scalazine/arti..._on_scala.html)
Last edited by willcode4beer; 07-10-2009 at 09:17 PM..
|
|
|
|
07-11-2009, 02:01 PM
|
Re: What's the next big language?
|
Posts: 3,150
Name: Abel Mohler
Location: Asheville, North Carolina USA
|
Interesting. Can't say I've ever heard anything about Scala until now.
2008... a blink of the eye historically, but decades in internet time.
|
|
|
|
07-15-2009, 06:12 AM
|
Re: What's the next big language?
|
Posts: 492
Name: Lashtal
|
Reason I ask about Ruby is i've seen it can be used to create GUI's, and that interests me to learn more about.
And that I haven't heard too many people super-excited about it, overall.
I've seen the people who make the vids and create the sites in Ruby that are all pro-Ruby-esque, but there doesn't seem to be a huge interest in it overall from the net-community. Everyone's been super-duper excited about PHP for some time, and that only seems to grow with time. (correct me if I am wrong)
|
|
|
|
07-15-2009, 01:35 PM
|
Re: What's the next big language?
|
Posts: 1,388
Name: Paul Davis
Location: San Francisco
|
Quote:
Originally Posted by Lashtal
And that I haven't heard too many people super-excited about it, overall.
|
You must be missing the Ruby advocacy that's been going on the last few years. It seems most of the Ruby developers are so excited it borders on fanaticism, some are definitely over the line.
However, I see Ruby, Python, PHP and other loosely typed languages in a different arena than things like Java, C#, Scala, Haskel, and other statically typed languages.
For small sites and intranet applications, loosely typed languages rule (and probably should) because of the speed of development.
On large scale enterprise applications, statically typed languages rule because of performance, lower cost of maintenance (and enhancement), and the ability to build static analysis tools.
|
|
|
|
07-15-2009, 05:42 PM
|
Re: What's the next big language?
|
Posts: 3,150
Name: Abel Mohler
Location: Asheville, North Carolina USA
|
The one thing I understand about Ruby, and Python, and to a certain extent PHP, is that they are very high-level languages. Java, on the other hand, is a sort of "medium level" language. So it takes 10-15 lines of code in Python to say what it takes maybe 40-60 lines of code to say in Java, and 150-200 lines of C. Of course I just pulled these numbers out of thin air, but that is my understanding. I'm certainly no Java expert.
So Ruby, Python, and PHP are "slow" languages, but faster to write with, Java is super-powerful, but not as fast as C/C++, which takes the longest to write code for.
Last edited by wayfarer07; 07-15-2009 at 05:44 PM..
|
|
|
|
07-15-2009, 06:23 PM
|
Re: What's the next big language?
|
Posts: 1,066
Name: Matt
Location: Irvine, CA
|
Quote:
Originally Posted by wayfarer07
Java, on the other hand, is a sort of "medium level" language. So it takes 10-15 lines of code in Python to say what it takes maybe 40-60 lines of code to say in Java, and 150-200 lines of C.
|
Take it from someone who spent a quarter writing assembly code, Java is a higher level language. I've never felt that java code was significantly larger than PHP code, and certainly not by a factor of 2 or greater. I think the biggest thing that seperates java from PHP is the fact that java is type-safe, which in some cases may cause you to write more lines of code. In spite fo this, for most purposes I tend to prefer type-safe vs non-type-safe.
|
|
|
|
07-15-2009, 07:35 PM
|
Re: What's the next big language?
|
Posts: 164
|
if you took perl or a better example is bash, and compare how to write something - you could write what a perl script would take 10 lines to do in say 1 long line of shell, and that 10 lines of perl would take 28 in php, and so on. But no one's going to pretend that shell scripting is less sophisticated than say php...
Code:
cat bigfile.txt | cut -d ":" -f 3 | sort | uniq
is how you take a file called bigfile, pull out the third column {the columns are split by a semi colon each}, arranges them in alphabetical order, removes duplicates and shows them to you
Code:
cat bigfile.txt | cut -d ":" -f 3 | sort | uniq > lessbigfile.txt
does all that except at the end writes it to a new file, rather than showing it on screen
Code:
cat bigfile.txt | cut -d ":" -f 3 | sort | uniq | wc -l
counts the lines resulting (but doesn't output them) - thus telling you how many unique whatevers (in column 3) there are...
even in perl, which is a lot "faster" than other languages, you'd have to do something like:
Code:
open (out,">lessbigfile.txt");
open (file,"<bigfile.txt");
while ($line=<file>){
@parts=split(/:/,$line);
print out "$parts[2]\n";
}
close (file);
close (out);
7 lines of perl vs 1 line of shell, and to do the other things with the perl you'd have to add more lines.
How would you write that code in php? i.e. how would you open bigfile.txt, go through each line and split it according to a : and then remove duplicates and save output to a new file...?
ah wait, my perl didn't remove duplicates... i'll just fix it:
Code:
open (out,">lessbigfile.txt");
open (file,"<bigfile.txt");
while ($line=<file>){
@parts=split(/:/,$line);
$bob{$parts[2]}=true;
}
close (file);
foreach $keys (keys %bob){
print out "$keys\n";
}
close (out);
9 lines of code in perl, vs 1 line in bash/shell.
So can anyone show me how to do that in php?
asp is just as bad as java, c++ etc, because you'd have to also declare lots of weird stuff at the top to do various things in those languages, all the time - i have my first bigtime asp scripts with me and was looking at them and the first thing i spotted was all that ugly stuff with %s at the top of every crapping script.
at least php doesn't do THAT! it's much more like a nice cool language like perl.
__________________
I acknowledge Parker out of Thunderbirds and Glaxo Industries.
|
|
|
|
07-18-2009, 08:50 PM
|
Re: What's the next big language?
|
Posts: 1,388
Name: Paul Davis
Location: San Francisco
|
think of it this way, when you write a bash script you are using lots of programs written in other languages.
cat, cut, sort, uniq, are all written in C. You're just using bash to glue them together. It's not much different than using a set of libraries in another language.
|
|
|
|
|
« Reply to What's the next big language?
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|