Server-Side magazine interview, touches on D

2012-01-29 Thread Andrei Alexandrescu

http://www.serversidemagazine.com/news/10-questions-with-facebook-research-engineer-andrei-alexandrescu/

Andrei


Re: Server-Side magazine interview, touches on D

2012-01-29 Thread Andrei Alexandrescu

On 1/29/12 4:34 PM, Andrei Alexandrescu wrote:

http://www.serversidemagazine.com/news/10-questions-with-facebook-research-engineer-andrei-alexandrescu/


Should have looked first, it's on reddit already. Please vote up :o).

http://www.reddit.com/r/programming/comments/p229i/10_questions_with_facebook_research_engineer/


Andrei




Re: Server-Side magazine interview, touches on D

2012-01-29 Thread George Fekete
On Sunday, 29 January 2012 at 22:35:32 UTC, Andrei Alexandrescu 
wrote:

On 1/29/12 4:34 PM, Andrei Alexandrescu wrote:

http://www.serversidemagazine.com/news/10-questions-with-facebook-research-engineer-andrei-alexandrescu/


Should have looked first, it's on reddit already. Please vote 
up :o).


http://www.reddit.com/r/programming/comments/p229i/10_questions_with_facebook_research_engineer/


Andrei


:)



Re: Server-Side magazine interview, touches on D

2012-01-29 Thread Adam D. Ruppe
On Sunday, 29 January 2012 at 22:34:19 UTC, Andrei Alexandrescu 
wrote:
I wish I’d convince a serious hacker to bring things to the 
point where


could be inserted in a web page.


That's very easy.

About 100 lines of simple string manipulation makes it
happen: http://arsdnet.net/dcode/dhp.d

$ ./dhp
hello !

hello andrei!
$

Set up a shebang or htaccess rule or something like that,
and boom, you have it on the web.

But, I'd question the utility of it. I wrote that dhp.d script
over a year ago, and have never actually used it.


Re: Server-Side magazine interview, touches on D

2012-01-29 Thread Nick Sabalausky
"Andrei Alexandrescu"  wrote in message 
news:jg4hhb$kll$1...@digitalmars.com...
> http://www.serversidemagazine.com/news/10-questions-with-facebook-research-engineer-andrei-alexandrescu/
>

"we tried hard to make off-the-shelf tools work at the scale and quality we 
need them to, failed, and had to write our own."

Yea, I get tired very quickly of defending NiH. Anti-NiH sentiments soudns 
great in theory, but the rality is that most off-the-shelf software just 
plain sucks - *especially* off-the-shelf web software.

"I wish I'd convince a serious hacker to bring things to the point where  could be inserted in a web page."

God no. You'll never convince a serious hacker to do that, becuase if you 
*could* convince them, they wouldn't be a very serious hacker to begin with.

Web-front-end people learned a long time ago, from hard experience, that 
that's a terrible approach to server-side code on the web. No serious web 
software does that anymore, except maybe when limited to 
carefully-simplistic uses inside the "HTML templates" waaay off deep into 
the "view" section of MVC.

The whole industry's moved over keeping server-side code out of the HTML, 
and using plain-old-code to drive an HTML-template presentation system (and 
that transition started as long as about ten years ago - My first taste of 
it was the [now old and mediocre] ASP.NET). I'd argue that, even better than 
that, we should be replacing the "HTML templates" with Adam's brilliant 
approach of "Server-side HTML DOM" (primarily limited to a presentation 
module, of course).




Re: Server-Side magazine interview, touches on D

2012-01-29 Thread Walter Bright

On 1/29/2012 2:34 PM, Andrei Alexandrescu wrote:

http://www.serversidemagazine.com/news/10-questions-with-facebook-research-engineer-andrei-alexandrescu/


Nice, I enjoyed reading it.


Re: Server-Side magazine interview, touches on D

2012-01-29 Thread Caligo
2012/1/29 Andrei Alexandrescu :
> http://www.serversidemagazine.com/news/10-questions-with-facebook-research-engineer-andrei-alexandrescu/
>
> Andrei

Learn how to learn?  Could you elaborate, please?  How did you learn
how to learn?


Re: Server-Side magazine interview, touches on D

2012-01-29 Thread Walter Bright

On 1/29/2012 6:16 PM, Caligo wrote:

Learn how to learn?  Could you elaborate, please?  How did you learn
how to learn?


I can't speak for Andrei, but I discovered after 4 years of university that I 
had become much better at learning new things. I attribute it to becoming more 
efficient at what kinds of effort I needed to make to master new material - I 
knew what worked for me and what didn't.


One also cannot help but get better at anticipating what kinds of things will be 
on the examinations, so that's what you focus on.


Re: Server-Side magazine interview, touches on D

2012-01-29 Thread bearophile
Walter:

> On 1/29/2012 6:16 PM, Caligo wrote:
> > Learn how to learn?  Could you elaborate, please?  How did you learn
> > how to learn?
> 
> I can't speak for Andrei, but I discovered after 4 years of university that I 
> had become much better at learning new things.

It's meta-learning (second order learning). There is a page on Wikipedia, but 
it's too much short and its quality is too much low:
http://en.wikipedia.org/wiki/Meta_learning

I believe that learning how to learn better is probably the most important 
thing to learn at the University. If you get good enough at learning, then many 
other things in life become possible. There are situations were people change 
(learn) how they learn to learn (third order learning), but this is a bit 
psychologically painful (I have not found stuff on Wikipedia about this, so you 
need to search in primary sources, like books by Seymour Papert).

Bye,
bearophile


Re: Server-Side magazine interview, touches on D

2012-01-29 Thread Andrei Alexandrescu

On 1/29/12 4:52 PM, Adam D. Ruppe wrote:

On Sunday, 29 January 2012 at 22:34:19 UTC, Andrei Alexandrescu wrote:

I wish I’d convince a serious hacker to bring things to the point where

could be inserted in a web page.


That's very easy.

About 100 lines of simple string manipulation makes it
happen: http://arsdnet.net/dcode/dhp.d

$ ./dhp
hello !

hello andrei!
$

Set up a shebang or htaccess rule or something like that,
and boom, you have it on the web.

But, I'd question the utility of it. I wrote that dhp.d script
over a year ago, and have never actually used it.


The difficult part is integrating with Apache.

Andrei


Re: Server-Side magazine interview, touches on D

2012-01-29 Thread Adam D. Ruppe
On Monday, 30 January 2012 at 05:17:21 UTC, Andrei Alexandrescu 
wrote:

The difficult part is integrating with Apache.


Eh, it's not so bad. Make a .htaccess file:

.htaccess:
===
Action dhp-script /cgi-bin/dhp
AddHandler dhp-script .dhp
===

Drop in your files.

hello.dhp
===

===
NOTE: that is cgi.write, not writefln. This version uses
my cgi library so you have all those awesomesauce functions.


And in your cgi-bin folder, build dhp out of this
file:

http://arsdnet.net/dcode/dhp_cgi.d

And drop my cgi.d into your /tmp directory.
http://arsdnet.net/dcode/cgi.d

End result?

http://arsdnet.net/dhp/hello.dhp

works.


Of course, you'll see this is slow because it
runs the compiler every time. If it used rdmd instead
of dmd though, we'd get cache and it'd probably work
pretty decently. (My computer doesn't have rdmd set up
currently though.)


Re: Server-Side magazine interview, touches on D

2012-01-29 Thread Nick Sabalausky
>>
>> I can't speak for Andrei, but I discovered after 4 years of university 
>> that I
>> had become much better at learning new things.

>
> I believe that learning how to learn better is probably the most important 
> thing to learn at the University.

Bullshit, bullshit, bullshit. All you need to learn how to learn is a 
library, not a $100k debt payable to useless pompous windbags. The biggest 
thing colleges teach is that their existence is actually needed for 
anything. And even *that* much is pure grade-A bullcrap.

Yea, you *can* learn such things at college: just like how I can sell you a 
$5k device to help you convert ice into water.




Re: Server-Side magazine interview, touches on D

2012-01-30 Thread Bill Baxter
On Sun, Jan 29, 2012 at 10:35 PM, Nick Sabalausky  wrote:

> >>
> >> I can't speak for Andrei, but I discovered after 4 years of university
> >> that I
> >> had become much better at learning new things.
>
> >
> > I believe that learning how to learn better is probably the most
> important
> > thing to learn at the University.
>
> Bullshit, bullshit, bullshit. All you need to learn how to learn is a
> library, not a $100k debt payable to useless pompous windbags. The biggest
> thing colleges teach is that their existence is actually needed for
> anything. And even *that* much is pure grade-A bullcrap.
>
> Yea, you *can* learn such things at college: just like how I can sell you a
> $5k device to help you convert ice into water.
>
>
> Libraries don't give you deadlines (except for when to return your books)
or feedback on how well you are doing.
Some people need that.

--bb


Re: Server-Side magazine interview, touches on D

2012-01-30 Thread Jesse Phillips

On Sunday, 29 January 2012 at 23:25:36 UTC, Nick Sabalausky wrote:
The whole industry's moved over keeping server-side code out of 
the HTML


So the whole industry has moved away from php? Sure templating is 
used so mixing php and html is as common, but if I'm not mistaken 
 used a lot, I don't know how to use PHP without it.





Re: Server-Side magazine interview, touches on D

2012-01-30 Thread Nick Sabalausky
"Jesse Phillips"  wrote in message 
news:ictwgryawpavhnrnq...@dfeed.kimsufi.thecybershadow.net...
> On Sunday, 29 January 2012 at 23:25:36 UTC, Nick Sabalausky wrote:
>> The whole industry's moved over keeping server-side code out of the HTML
>
> So the whole industry has moved away from php?

I wish! No, it's moved away from using PHP in an ASP-classic-style. Ie, 
scattering a bunch of  throughout an HTML document.

> Sure templating is used so mixing php and html is as common, but if I'm 
> not mistaken  used a lot, I don't know how to use PHP 
> without it.
>

Typically now, a PHP file will start with "" - this ensures no stray whitespace is printed, which can 
screw things up (for instance, if you're expecting that HTTP headers are not 
to have been sent yet.)




Re: Server-Side magazine interview, touches on D

2012-01-30 Thread Nick Sabalausky
"Bill Baxter"  wrote in message 
news:mailman.202.1327961928.25230.digitalmars-d-annou...@puremagic.com...
> On Sun, Jan 29, 2012 at 10:35 PM, Nick Sabalausky  wrote:
>
>> >>
>> >> I can't speak for Andrei, but I discovered after 4 years of university
>> >> that I
>> >> had become much better at learning new things.
>>
>> >
>> > I believe that learning how to learn better is probably the most
>> important
>> > thing to learn at the University.
>>
>> Bullshit, bullshit, bullshit. All you need to learn how to learn is a
>> library, not a $100k debt payable to useless pompous windbags. The 
>> biggest
>> thing colleges teach is that their existence is actually needed for
>> anything. And even *that* much is pure grade-A bullcrap.
>>
>> Yea, you *can* learn such things at college: just like how I can sell you 
>> a
>> $5k device to help you convert ice into water.
>>
>>
> Libraries don't give you deadlines (except for when to return your books)

Having deadlines doesn't need to cost $100k.

> or feedback on how well you are doing.

If you're relying on the tests to tell you how well you're doing, then 
you've already failed.

*You* are by far the best person to know whether *you* understand something 
or not. A school's evaluation is *NOT* for the student's sake - it's purely 
for the school's/teacher's own accountability. It's inherently innacurate, 
but needed anyway simply because they can't read your mind for an "I 
understand" or "I don't get it" - but you *can* read your own mind, so for 
the student, test results are extra time, extra money and *less* accurate, 
all for no benefit.

> Some people need that.
> 



Re: Server-Side magazine interview, touches on D

2012-01-30 Thread Jacob Carlborg

On 2012-01-30 23:51, Jesse Phillips wrote:

On Sunday, 29 January 2012 at 23:25:36 UTC, Nick Sabalausky wrote:

The whole industry's moved over keeping server-side code out of the HTML


So the whole industry has moved away from php? Sure templating is used
so mixing php and html is as common, but if I'm not mistaken  used a lot, I don't know how to use PHP without it.


This is used in Rails as well. I mean, you need a way to get a value 
from the controller into the view.


--
/Jacob Carlborg


Re: Server-Side magazine interview, touches on D

2012-01-30 Thread Nick Sabalausky
"Jacob Carlborg"  wrote in message 
news:jg84d8$1ea5$1...@digitalmars.com...
> On 2012-01-30 23:51, Jesse Phillips wrote:
>> On Sunday, 29 January 2012 at 23:25:36 UTC, Nick Sabalausky wrote:
>>> The whole industry's moved over keeping server-side code out of the HTML
>>
>> So the whole industry has moved away from php? Sure templating is used
>> so mixing php and html is as common, but if I'm not mistaken > ?> used a lot, I don't know how to use PHP without it.
>
> This is used in Rails as well. I mean, you need a way to get a value from 
> the controller into the view.
>

Right, but that's the extent of it. It's used for the HTML templates and not 
much else.




Re: Server-Side magazine interview, touches on D

2012-01-31 Thread Adam D. Ruppe

On Tuesday, 31 January 2012 at 07:14:48 UTC, Jacob Carlborg wrote:
This is used in Rails as well. I mean, you need a way to get a 
value from the controller into the view.


Interestingly, a lot of PHP devs don't even use PHP for
this!

There's stuff like smarty in fairly wide use:

http://www.smarty.net/why_use


Though, of course, many PHP devs *do* use php for their
templates too. (including me when I do php w/o D. I like
the {$foo.bar} syntax in smarty but not the rest of it.)


Re: Server-Side magazine interview, touches on D

2012-01-31 Thread Jacob Carlborg

On 2012-01-31 16:51, Adam D. Ruppe wrote:

On Tuesday, 31 January 2012 at 07:14:48 UTC, Jacob Carlborg wrote:

This is used in Rails as well. I mean, you need a way to get a value
from the controller into the view.


Interestingly, a lot of PHP devs don't even use PHP for
this!

There's stuff like smarty in fairly wide use:

http://www.smarty.net/why_use


Though, of course, many PHP devs *do* use php for their
templates too. (including me when I do php w/o D. I like
the {$foo.bar} syntax in smarty but not the rest of it.)


It seems like Smarty is used mostly because of PHP being quite verbose. 
This is not the case with Ruby and specially not with the help of the 
many view helpers the Rails framework provides out of the box.


Note also that Rails provides many different template languages as 
plugins. There could well be a smarty plugin.


Looking at the syntax comparisons: http://www.smarty.net/syntax_comparison

Late's make a comparison with two Rails template languages, Erb (the 
default) and HAML.


smarty:
{$foo}

erb:
<%= @foo >

haml:
= @foo

php:


smarty:
{$foo.bar}

In Rails you would most likely pass an object instead of an array/hash.

erb:
<%= @foo.bar >

haml:
= @foo.bar

If you actually do pass a hash it will like this:

haml:
= @foo[:bar]

Or you can implement "method_missing" (like opDispatch) in the Hash 
class and get this syntax:


haml:
= @foo.bar

smarty:
{foreach $foo as $bar}

{/foreach}

erb:
<% @foo.each do |bar| %>
<% end %>

or

<% for bar in @foo %>
<% end %>

haml:
- @foo.each do |bar|
# indent

smarty:
{for $x = 1 to 20 step 2}
  {$x}
{/for}

haml:
- (1 .. 20).step 2 do |x|
= x

{$foo|lower|escape}

haml:
=h @foo.downcase

To me it looks like HAML wins in every example.

Don't know if Smarty has this feature but this is so cool in Rails:

= render @posts

What happens is @posts is an array of model objects of the type Post. 
Rails will look in the directory containing all view files for a 
directory called "posts". Then it will look for a partial named 
"_post.html.haml". It will render that partial passing in the element in 
the current iteration to the partial as "post".


In Rails you are free to do whatever you want in the views (not sure if 
you can access everything you need). But you are encouraged to keep the 
Ruby code to a minimum.


--
/Jacob Carlborg