Hacker News new | ask | show | jobs
by charliesome 4619 days ago
Hi, I'm the author of Slash. I wasn't expecting Slash to show up here so soon - the website's pretty out of date and the language itself still needs a bit more polish before it's ready for use.

Slash is something I'm building out of personal need. I love Ruby, but there isn't much going on in the 'small web scripts' area. It's either frameworks like Rails or Sinatra that require app servers constantly running, or tools like Jekyll that can only do static websites. Slash is somewhere in between. It's not supposed to be a 'PHP successor' as much as it's supposed to be something that Python or Ruby fans can turn to when they just need to chuck a small script up on the web.

5 comments

If you did a python/ruby/node-javascript that would capture the best features of PHP, instead of inventing a whole new language, I'd actually be tempted to use it.

The features (or what others would call anti-features, but one man's "bug" can be another's "features" so lets ignore the long talk) would simply be:

1. Ultra-Ease of deloyment - I want to be able to just:

- load a module for my webserver of choice (Apache, NGINX etc.)

- drop code in a folder via ftp and have it "just work"

- have a shared nothing app model with no long running processes, PHP style, because this way I can ignore 99% of security and performance problems, both as a provider of dirt-cheap shared hosting and as the developer of a web application that doesn't need to scale that much and isn't that much of a target for hackers either (so I can have the following mindset: "I don't need to care about scalability/performance or security, because by the time I'll need to care about these I'll be already making enough profit from it to be able to hire some very smart guys to rewrite everything from scratch the right way or I will have already sold the company and be enjoying my $ while others care about this")

2. Ultra-Eease of app/site setup:

- I want to just drop files in a folder and have it work, just like that, just like magic

3. "Don't make me think" style of development:

- I want the same language in my controllers, in my db code AND in my templates

- plus points if it's in the browser too

- have all the component I and other might need in "one pack", "batteries included" style

4. Almost non-existent learning curve:

- someone should be able to go from A - "poetry major with no knowledge of what computers are" to B - "expericenced full-stack developer" withouth feeling any learning curve: yeah, it will take time to get from A to B, the first 10% of the road should be made as easy as possible

...and to "kill" PHP you'd still need to add a killer extra feature. I can imagine something like an object persistence feature (Maglev/Gemstone style) baked into the language/library/framework that would allow you to simply persist objects without even thinking about a database (it could be implemented as a very smart ORM underneath, but it should be as opaque/black-boxed as possible and 99.99% of users shouldn't need to know how it works) - this imho would be the kind of thing really enjoyed by PHP developers.

> drop code in a folder via ftp and have it "just work"

This is essentially what Zed Shaw was working on for Python:

https://github.com/zedshaw/fuqit (https://news.ycombinator.com/item?id=6039146) and here's another for Node https://github.com/ricardobeat/fuqit

I'd love something like this fully fleshed out for Ruby. Some things PHP did "get right" like how it "just works."

Isn't this asking for all the features that lead HN-readers to despise PHP?
There is a lot more wrong with PHP than these (anti-)features. It's loose comparisons for instance, with gems like 0 == "php" returning true, but 0 == "1" returning false [1] [4]

Having a function like nl2br [2], which converts newlines to br tags. The only reason this function would be useful is when you want text to HTML. The problem is, this requires a lot more than just replacing newlines with br tags.

A function like intval [3], which according to the documentation when passed a string "will most likely return 0".

And just about anything on http://www.phpwtf.org/

My main point is, that PHP is not broken because of these features. PHP is broken because the language has been hacked together from the start and there is no way to guess what built in functions will do if you haven't looked up the full documentation for them first.

[1]: http://www.decontextualize.com/wp-content/uploads/2010/01/ph...

[2]: http://php.net/manual/en/function.nl2br.php

[3]: http://php.net/manual/en/function.intval.php

[4]: http://i.imgur.com/pyDTn2i.png

All languages have odd quirks. One can cherry pick from any of them: https://www.destroyallsoftware.com/talks/wat
PHP is built on odd quirks. that's the difference.

It's only popular because it's easy to setup shared apache+php hosts and deploy scripts via FTP on it.

Yes, only ;)
...yes, but these are also the features that led people to use and keep on using PHP. one man's poison is another's drug of choice ;)

(to be honest I'd love to see PHP dead and buried, but there's still no other tool that fills its niche, and I hope that when one such tool gets developed, it's actually based on a sane programming language - PHP as a language means nothing, it was just "something" that grew organically into a language to fill an empty niche, and the only other alternative for this niche back then would've been Perl).

Heh, I spend about 80% of my working life writing PHP, I use it for some of them!
I think most people hate the language itself but recognise its strength of crazy-easy-to-get-started-with.
PHP has some ugliness, but in what way are any of these specific features bad?
"- I want the same language in my controllers, in my db code AND in my templates"

I read that as "let me mix them together like a PHP spaghetti app". The original poster may not have meant that, but after 13 years of writing PHP, the common complaint I still hear from newbies is "but structuring my code/using a framework has such a steep learning curve!". I'd rather like separation of concern enforced at the language level :)

And no, I don't have a clue how that'd work ;)

Their complaint is valid imho. They can use PHP to learn the basics of programming, and after this, as the next logical step, learn to structure their code. PHP is a bad language to get started with to learn programming for a number of different reasons (much worse than Python or Javascript), and this is why it would be cool to have the "PHP way" but based on a different language.

...now, I first learned coding by solving algorithmic math problems in C, but if someone would've tried to make me learn C++ or Java and OOP at that point I would've had the same complaint your newbies are having about "why learn so much just to 'structure' my code?!" :)

He didn't say implementing those functions in the same code, but using the "same language". To me, PHP's use in templates is pretty much its core idea. I think it's a good idea, and basically defines what a ruby/python version would be like.

Unfortunately it also makes possible the abuse you note - hopefully there's better solutions than requiring a different language in those 3 places.

Would love to know where the downvotes came from :)
Awesome job. I'm impressed how many interesting and complex open source projects you created / contributed to. And you are only 19! What age did you start coding? And how did you learn? By yourself? Early CS degree? I'm a bit envy. Github hired you for a good reason probably. Slash looks really interesting, will keep a watch on it. I have some constructive remarks but it was all said already in other comments. Are you using it somewhere in production? What is the runtime? How is concurrency handled? Do you have performance benchmarks? Great stuff overall. Keep it up.
I wish this was top. There's merit in creating a new language, even if it's just for learning. I'm not saying we shouldn't constructively criticize the language itself. I'm just glad the merit is recognized as well.
If deployment is the key issue, you don't necessarily need to change the language. What you need is glue code that hooks Ruby (or Python, or whatever) into the web server at the same level as PHP hooks in, the way the ancient mod_perl does for Perl. (Which is also probably a bit less implementation work than doing a whole new language --- and also gives users the benefit of a much larger set of libraries right off the bat.)

EDIT: as pointed out below, mod_python for Apache already goes pretty far in this direction.

> What you need is glue code that hooks Ruby (or Python, or whatever) into the web server at the same level as PHP hooks in, the way the ancient mod_perl does for Perl.

The problem with this approach is that MRI Ruby has tonnes of global state, so unless you restart the interpreter for each request, you're going to end up with state leaking between requests.

Slash is designed so that many VMs can be quickly created in the same process without any shared global state. This way each request runs in its own isolated context and can't affect any other requests.

>The problem with this approach is that MRI Ruby has tonnes of global state, so unless you restart the interpreter for each request, you're going to end up with state leaking between requests.

So what? That's how PHP works, and it's still pretty fast for most things. Would a mod_ruby be that much slower? Should still be faster than a CGI-style invocation.

PHP only works like that because Apache's default process model is process-per-request. Anything event based requires moving PHP in to multiple fcgi worker processes, and then you get limited by that.

A fast, non-shared interpreter could work very well in a threaded server, or a threaded backend to an event-based server.

Just for the record there are a huge differences between how mod_perl and mod_php work. One of the main reasons that PHP got so popular in the first place was that mod_perl was really boring and complicated to work with because it was keeping all the scripts and modules and globals loaded and shared between requests.
I second this. The language appears to be a Ruby with a slightly modified syntax, and most programmers won't be excited about keeping track of the differences. Use Ruby for this and everyone will benefit.
Sure, but doing a new language is fun, and can be a learning experience.
What is the actual benefit of slash, compared to python or ruby with a templating engine? Something like http://slim-lang.com/ which is ruby templateing for example.

The PHP approach seems kind of messy in jumbling together (1) a programming language and (2) plain HTML notation

Also:

Are you just feeding through the HTML parts or are they parsed/validated/inspectable? Can one work with DOM nodes? (This is what I like about https://github.com/weavejester/hiccup/wiki/Syntax )

I love the name "yada-yada operator" :D
That comes from Perl (which was added at 5.12 however it originated from the Perl6 spec).

See http://search.cpan.org/~jesse/perl-5.12.0/pod/perlop.pod#Yad...

And search for "yada" in the following links:

- http://perldoc.perl.org/perlsyn.html

- http://perl6.org/archive/doc/design/apo/A12.html