

The Slash Programming Language - svoroval
http://slash-lang.org/

======
charliesome
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.

~~~
rst
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.

~~~
charliesome
> 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.

~~~
mgkimsal
>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.

~~~
sitharus
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.

------
nercury
I am PHP developer, but that first "Overview" example looks all sorts of wrong
to me.

I know this is just an example, but programming without view/controller
separation, view models, writing queries inside views, mixing business logic
in views? No no no I saw so much horrbible stuff like this I can't unsee aaaah
God help me...

:D

Ok, on serious note: I think this language looks interesting. But I do not
like built-in templating, for various reasons. The fact that you have implicit
"out" channel for printing stuff means clunky ways to control it, like
"ob_start" and friends. In my humble opinion, templating should be turned on
only explicitly. Then you could use the same language for views (excelent!),
without a risk of outputing strings where you shouldn't.

Also "{" and "}" in templates are not very elegant. I know us programmers got
used to them, but a designer would be much better with simple statements like
"if", "else", "endif", like Twig templates do, or even like we used to do in
php:

<?php if (x): ?>

<?php else: ?>

<?php endif; ?>

~~~
benastan
View/controller separation, view models and query abstraction are framework-
level features. The author of this language is seeking to take the qualities
of PHP that make it a 'hypertext preprocessor' and mixing in the no-frills
syntax and vocabulary of ruby or python.

I don't understand why you wouldn't just use a framework like Sinatra. It's
simple in every way that qualifies it to contend with a 'hypertext
preprocessor'. Add it to your gem file, bundle, git commit, push to heroku,
deployed! It even has inline templates[1].

You could argue it has a learning curve, but is resistance to learning a good
argument against a solid & simple, versatile framework?

[1]
[http://www.sinatrarb.com/intro.html#Inline%20Templates](http://www.sinatrarb.com/intro.html#Inline%20Templates)

~~~
nercury
I am a big supporter of building applications in consistent way, and the big
part of that is being able to code components which do not know anything about
the presentation layer. Building these components on _hypertext preprocessor_
is exactly the thing I would not want and would avoid at all costs. We already
have it with PHP, and we have learned to follow some practices to live with
it.

Well, you may say, this is just for small stuff to run some scripts easily.
Well, the reason behind the PHP was the same. And look what it has become :)

Please don't assume I will not use Sinatra just to plug Sinatra here :). I
might.

------
taspeotis

        PHP is a great tool that is virtually unmatched in its domain - ie. ‘slap a script on a server and have it run’.
        The problem is that PHP’s idiosyncrasies make it awkward and sometimes even painful to program in.
        ... [Slash] is a language that lets you achieve results quickly while being a joy to use.
    

You can slap a script on a server and have it run because of PHP's ubiquity.
This language has none of that.

It seems like a non sequitur to say "PHP is really easy to get started with
... but my language is cleaner!"

It could be said that PHP's biggest feature is its install base. Nothing is
going to "succeed" it until it gets past that.

~~~
jawngee
No, you can slap a PHP script on a server because of how easy it is. I mean,
there's a reason its ubiquitous right?

    
    
        > sudo apt-get install php5
        > *slap script on server*
        > ???
        > profit

~~~
Macha
There are many cheap shared hosts that allow you a server to slap PHP scripts
on without giving shell access. That is why PHP is popular. And setting up a
secure shared environment is more work for the hosts than apt-get install
php5.

------
Qerub
I wish statically-typed multi-tier/stratified languages for the web like Opa
([http://opalang.org/](http://opalang.org/)) and Ur/Web
([http://www.impredicative.com/ur/](http://www.impredicative.com/ur/)) got
more attention; they actually bring something new to the table.

------
peteretep
> print("你好世界".length); # => 4

NO NO NO NO.

'length' is ... not right, and I don't want to know why it returns 4 for the
above, because that's not right. If you want to provide a 'length' function
for a Unicode string, you need to know what you are measuring: graphemes,
codepoints, bytes? Whichever you decide to use, is inappropriate for 'length'.

~~~
e12e
Interesting objection.

To me it is rather obvious that a _text-oriented_ language would treat any
"string" as a) an atomic string _and_ b) a sequence of the "next-lower"
logical unit. I do just now realize that "An English sentence.".length _could_
by this reasoning return 3 or 4 (3 words, one punctuation mark...).

~~~
peteretep
I'm glad it's so obvious to you. Here is a quick test:

What is "ö".length?

It's one grapheme, an o with a diaeresis. It's two codepoints, an o (0x006F)
with a combining diaeresis (0x0308). It's several bytes, depending on
encoding.

How about if you reverse it first, so that the diaeresis doesn't have anything
to combine with, and you have a bare letter 'o'? What's the length now? If you
answered _one_ to the above, you've got a string whose length doubles when you
reverse it. Is that what you want?

Too easy for you?

Let's take the Thai consonant "ก", which is a sort of a g, sort of k sound.
One grapheme, one codepoint. Sorted. We'll add a vowel to it: "กอ". Two
codepoints, but how many graphemes? One or two? Let's say two, but then let's
point out that there is no logical difference there between that and a
different vowel: "กี". This is a little more complicated? What's the length
now? Is that one or two graphemes? It's clear as day that that's a single
consonant + a single vowel, but how long is the string? How about: "เกียะ"?
That's still a single consonant + a combining single vowel, only this time
it's a compound vowel. One consonant, one vowel, how many graphemes? Are you
using vertical slicing to determine what is and isn't a grapheme? Is that
right?

To see this taken to its logical end by The Masters of Unicode:
[http://www.unicode.org/faq/char_combmark.html](http://www.unicode.org/faq/char_combmark.html)
\- "How are characters counted when measuring the length or position of a
character in a string?"

~~~
e12e
TL;DR -- I generally fall in the category of counting graphemes, as per the
second FAQ you linked -- when talking about user-facing text processing. I'm
don't think it makes sense to try and have one api that tries to both appease
(low level) programmers and end-users.

Perhaps I wasn't entirely clear - I certainly see that there are
complications. I think you're overcomplicating your examples _within the
domain of text_ \- I'd say composed characters counts as one, and reversing a
string with a composed character, shouldn't reverse/destroy the compositon.
The reverse of "õ" isn't "o~", but simply "õ" \-- and the length of "o" and
"õ" should both be one -- even if they aren't coded similarly.

Now, this won't work for lower level work on "computer language" strings -- so
for your unicode-library or whatever you'd have to count differently.
Obviously you have to do some magic when converting a multicode-encoded string
from big-endian to little-endian and vice-versa -- but that's hardly the same
operation as reversing a string.

I'm not familiar with thai, but to me it looks like your "กอ" and "กี" is
equivalent to the Norwegian vowel "æ" which used to be written/typset as "ae"
(and can still be considered a composition in some input locals). So the
length of "ae" is 2, the length of "æ" is 1 as is the length of "a". That
would mess up "ae" if reversed -- but I would consider that a
"special/archaic" use-case. I'm not sure if that would be similar in Thai -- I
don't know for example, if typewriters and computers have been wildly used for
comparable time in Norway and Thailand (I'm guessing Thailand have a few
thousand more years of printing/literacy).

As mentioned in my comment above, I also find it interesting that if we're
taking length to mean "number of things in a sequence", the length of a
sentence would be the number of words, the length of a word would be the
number of graphemes and the length of a grapheme might either be the number of
bit/bytes, or there might be a level in-between of composites.

So we might have:

    
    
       "This is an example.".length => 4 (or 5 or 8 depending
          on how we define spaces and punctuation)
       "This".length => 4
       "T".length => 1 byte,7 or 8 bits, or maybe even 2 in a
         prefix-based encoding (capital-transform t).
    

The _logic_ would be that the full sentence is treated as a sequence of words
that's treated as a sequence of graphemes that are treated as a sequence of
codepoints that's treated as a stream of bits...

------
edem

      <ul>
          <% for person in db.query("SELECT * FROM people") { %>
              <li><%= person["name"] %></li>
          <% } else { %>
              <li><em>No people found!</em></li>
          <% } %>
      </ul>
    

I don't think that mixing view and model code in an example is a good idea.
The reason is that it encourages mixing different concepts / abstraction
levels which will result in confusion and maintainability issues in the long
run.

For example if you happen to change the table name from people to humans you
will have to change _all_ code which uses people. It is not probable but it
might happen.

If your language is not intended to be used for more than a few lines scripts
then just ignore my comment.

~~~
Segmentation
It's just a concise example to demonstrate template and logic at the same
time. Introductory PHP looks like that.

No where is he writing "Okay, let's start with an example on how you should be
coding."

------
jawns
One valid point the intro makes is that PHP's "slap a script on a server and
have it run" has made it the go-to web scripting language for a lot of folks
whose goal is to just get something small, maybe a single page, up and running
quickly. For larger projects, you will likely be better served by other
languages, but I still find myself going back to PHP when I need to do
something small, quick, and without much regard for performance or elegance.

~~~
kayoone
In todays development world i dont see any reason why to use python/ruby
instead of php (which was different when Rails came out), even for large
projects. The frameworks are very mature and the community is huge.

I see a point in using JS on the server instead of PHP though, still the
frameworks have some catching up todo.

~~~
Spidler
Okay, I'll bite. I'm a nice guy.

Please tell me the deployment steps for a single-file python script.

With PHP, it's "install php mod_php, place files in directory" .

With Python it is... what?

~~~
nkuttler
Install python, mod_wsgi, and add two lines in the apache config.

The last step is just removed in PHP because of the "place files in directory"
model, which is fundamentally broken and used by default. Application code
shouldn't be in a place where the entire world can read it if for some reason
your httpd doesn't parse it.

~~~
simpleigh
I'm not a pythonista but would question your recommendation of mod_python -
the (current) top post at
[https://news.ycombinator.com/item?id=6616550](https://news.ycombinator.com/item?id=6616550)
(also on the front page right now) states that "mod_python has been dead for
so long now that its death has gone from a liability to a potential asset".

I totally agree that application code shouldn't be in a web-accessible
directory - but that's a hosting/configuration problem, not a PHP (or even
mod_php) problem. It's trivial to set up an index.php which bootstraps an
application stored elsewhere on the server.

~~~
nkuttler
My bad, you're absolutely right. I meant mod_wsgi.

With regard to code location, I mentioned that because of Spidler's question.

------
blowski
Why should I switch from PHP, a mature and stable language with an enormous
support base, many libraries and an obvious career path? I need a more
compelling reason than "it fixes PHP's idiosyncracies", most of which I have
come to understand.

~~~
dz0ny
In your case you shouldn't. :) PHP is string manipulation language, it's
really hard to do anything else with it. (binary manipulation, network
programs, binary streams, long running apps...)

~~~
benatkin
That isn't true. PHP is a general purpose programming language. Binary
manipulation is done about as often with PHP as it is with ruby. PHP has pack
and unpack functions. Binary data can be stored in a PHP string with little
overhead.

Also in practice PHP has been weak at certain types of string manipulation,
because the template language doesn't lend itself to capturing the output in
order to filter it. Intermediate PHP developers know how to save buffered
data, but it isn't as straightforward as manipulating output data with rack or
wsgi middleware.

~~~
ceol
_> PHP is a general purpose programming language._

No no no no no no no. Nonono. No.

It's a web framework and template language built around a handful of C
wrappers and awkward database interactions. It can't even represent unsigned
64 bit integers. Any complex math requires you to convert the numbers into
_strings_.

PHP is an advanced template language for HTML.

~~~
benatkin
> PHP is an advanced template language for HTML.

PHP is a template language for HTML that's prone to CSRF.

------
denysonique
Node.js seems to be becoming a PHP successor. In regards of easy web
development. With JavaScript you can both write for the front-end and the
back-end. One language to rule them all. Very appealing to newcomers who want
to learn webdev.

~~~
tmikaeld
I agree, the one issue i have with node.js is handling security. PHP has had
many years to become exploited and matured because of that. node.js don't have
broad adoption yet and thus haven't attracted the same amount of hackers.

------
nercury
"Slap a script on a server and have it run".

And then watch it grow over the years into unmaintainable mess :)

~~~
sigfried
lol, often rails sites are the ones that tend to be unmaintainable messes,
specially if you use a few gems.

------
alkonaut
Looks nice. Some feedback

1\. For the love of god, don't allow a Nil value! Pattern matching is so much
better (Maybe/Option type) 2\. I didn't see anything about the runtime, but if
you can optionally compile to something ubiquitous like php initially it will
ease adoption. 3\. even though you target small scale, so did javascript. I'd
throw in some rudimentary namespace/package/module/version/dependency things .

------
etfb
Nice. I wish it well. Sadly, it has one feature I hate from PHP (the ability
to interweave PHP and HTML, instead of using the HTML as a template or
generating it in code) and lacks one feature I absolutely need, which is all
the code I've already written in PHP and can require_once and reuse whenever I
want to start a new project.

But I hate PHP, even though it's the main thing I use now. So I want this to
succeed. Good luck!

~~~
peteretep
> Sadly, it has one feature I hate from PHP (the ability to interweave PHP and
> HTML

Which is arguably the one reason for PHP's popularity.

~~~
etfb
Definitely - but then, McDonalds Big Macs are more popular than hamburgers
with beetroot and pineapple on them, and my tastes are again at odds with the
mainstream. I can't help it - I'm a geek hipster (and a burger snob).

------
stevoski
The first (or second, maybe) line made me cringe...a specific object for
MySQL, rather than a database-agnostic SQL engine, a la old-school ASP or
middle-school JDBC.

Perhaps better:

    
    
        db = DatabaseConnection.new("MySQL", "localhost", "my-user", "s3cr3t");

~~~
stevoski
Another reason I cringed is the implicit creation of the db variable. This is
just asking for beginners to bang their head against the table in frustration
trying to work out why their variable alongvariablename is equal to 0, even
though they just assigned it to alonggvariablename to 7.

"Oh, it was just an extra g, and I've been stuck for hours because of that? I
hate computers!"

~~~
bouk
What? Ruby works the exact same way. Pretty sure Slash doesn't make variable
have an implicit value like PHP does

~~~
rst
And it's the one thing I really dislike about Ruby. The problem with this is
that the interpreter can't tell the difference between declaring a new
variable, and misspelling the name of an existing one --- which means that
there's a very common class of simple errors which it can't automatically
check. Even Perl (with -w) gets this right, and it doesn't really make the
language more verbose; declarations are preceded with a 'my ' which is useful
punctuation. (Humans also find it useful to see when a new variable is being
introduced.)

And you could come up with ways to preserve the distinction while making it
even less obtrusive --- ':=' instead of '=' in a declaration, for example.

~~~
klibertp
It's the same in Python, and it's mostly solved by external static code
analysis tools. The trick here is the assumption that misspelled variable will
be used only once in a file - exactly where it got misspelled - and tools like
pylint or pyflakes warn about such names. If you're running these tools
sufficiently often and have them integrated with your editor (my Emacs runs
pyflakes once in 3 seconds, after enter is pressed and on save, whichever
comes first) this kind of error is essentially eliminated.

OTOH, having a language which doesn't need external tooling to eliminate such
errors is an obvious win. Smalltalk, with it's code browsers, refactoring
tools and similar does this really well, for example - if you use a new name
inside a method definition you are asked if you want to declare new instance
or block variable, or turn it into selector, or if you want to rename it (and
then it gets renamed throughout the method) and so on. And that's at compile
time!

------
daraosn
Why having this if you have Ruby, Python or even Node.js... and why having PHP
at all! all I can think of is dinosaurs and extinction. Move on guys, PHP was
cool several years ago, and I enjoyed it a lot, but now it should be buried
already and you're trying to create a zombie here.

~~~
Solarsail
Ignoring Node for a moment, Ruby and Python currently have a noticeably higher
barrier to entry for the kind of personal home page that PHP was named for.
<html-stuff><html-otherstuff> <?php $todays-date ?php> <making-up-the-syntax-
as-I-go-because-Ive-forgotten-it-all>

AFIAK, in either Ruby or Python the equivalent of that would be far harder.
You'd need a program made of several separate files, have to grab Rails from
somewhere, have some concept of responding to requests somewhere and a bunch
of stuff other than the one time stamp above. Though I suppose you could use
client-side JS here too.

~~~
daraosn
What are you talking about? This is the problem of why PHP is still being
used, because developers think that Ruby or Python don't allow you to do
several stuff you actually can... look at this example (ERB lets you run Ruby
code the same way):

    
    
      $ cat test.erb
      Hello there! Today = <%=Time.now%>
      $ erb test.erb
      Hello there! Today = Sat Oct 26 16:42:36 +0200 2013
    

Plus you still need to run PHP over a server (Apache, Nginx, or what so ever),
so I don't see so much difference with Rails, Django or Express, except that
PHP is an old and stinky language.

------
brandonhsiao
If you want to combine code with markup, I personally think something like
web.py's Templetor looks the sexiest/most natural. Here's a sample:

    
    
        <table>
            $for i in range(10):
                <tr>
                    for j in range(10):
                        <td>$(i*j + 1)</td>
                </tr>
        </table>
    

which prints out a table of the numbers from 1 to 100 in a 10x10 table.

More information here:
[http://webpy.org/docs/0.3/templetor](http://webpy.org/docs/0.3/templetor)

I would also imagine it being a pleasure to represent html as Lisp lists.

------
andrewflnr
Seeing the "yada-yada" operator reminded me of a language I saw once that was
designed to actually let you say the equivalant of "yada yada" or "and so on",
and it would actually try to figure out what you meant. It wasn't quite a
general "do what I mean" language, and was a research project in progress.
Does anyone remember in more detail what I'm talking about? I can't figure out
how to search for it.

~~~
evincarofautumn
You’re thinking of Swym ([http://swym.in/](http://swym.in/)) and its “etc”
operator.

~~~
andrewflnr
Yes, thank you. I'm adding it to my list so I don't forget it again. :)

------
zekenie
One thing PHP has going for it is its ubiquity. Despite all its problems, its
an accessible, server side scripting language. Slash looks really cool for
small, easy projects that PHP would be good for. In fact it looks better. But,
it doesn't have PHP's ubiquity. I think it'd probably have to be 10x better to
overcome the ubiquity problems. Maybe it is. How easy is it to install? (sorry
if that was covered somewhere on the site)?

------
tmikaeld
I don't see how this "language" would make it a better language, there is
frameworks in every type of language - a quick look at frameworks like Yii
makes this look similar and more powerful even as an abstraction layer, to
this language described.

Also, a new language would not be compatible with current PHP modules... I
think this is just not thought through.

~~~
bouk
Note that the creator of slash doesn't claim to be the 'PHP successor' that's
just what the OP made the title

~~~
Too
Thanks for the clarification. This is one of those few cases where i actually
agree that the moderators should change the submission title.

------
sebastianmck
GitHub project at [https://github.com/slash-
lang/slash](https://github.com/slash-lang/slash)

------
pan69
The power of PHP isn't really the language but the way it integrates with
Apache web server. If web server integration doesn't exist for your language,
or doesn't exist on the level that PHP has it, you can design cool languages
but it won't replace PHP ever.

~~~
PeterisP
How about not integrating with apache at all?

With tools such as Node.JS (or Python Bottle, Haskell Yesod, etc) you simply
pull your code from git, run it, and it has its own webserver included that
handles routing w/o looking at a filesystem and direct execution of code
instead of passing a file; which all is nice for performance.

~~~
pan69
I know. I understand. The reason for the success of PHP is that it runs on
cheap shared hosting. If you want to replace PHP you need to fill that gap
first, or, make it at least as "convenient" as PHP.

------
wildtype
Successing PHP's spaghetti?

------
dutchbrit
How can I download/use it?

~~~
svoroval
It is written here: [https://github.com/slash-
lang/slash](https://github.com/slash-lang/slash)

------
minussohn
Is there a POC Interpreter for slash, or are these some ideas you had over
night?

~~~
bouk
There's an intepreter here: [https://github.com/slash-
lang/slash](https://github.com/slash-lang/slash) and you can execute code
online here: [https://eval.in/1471](https://eval.in/1471)

------
misuba
Yada-yada operator: genius.

------
junto
Reminds me of classic ASP.

------
EugeneOZ
All the dirt of PHP and Perl + antipatterns in examples.

------
aupajo
Needs some instructions on how to install it, surely.

~~~
bouk
There's compilation and installation instructions here:
[https://github.com/slash-lang/slash](https://github.com/slash-lang/slash)

------
hayksaakian
What's wrong with rack or Sinatra?

------
jafaku
Does it have interfaces, abstract classes, and optional types like PHP? Or it
is as lacking in OOP as Ruby and Python?

~~~
camus2
Ruby is more Object Oriented than PHP will ever be. You dont need interfaces
or abstract classes in a dynamic language. Unless you want to feel "safe" as a
developper.

~~~
jafaku
So you don't know what design by contract is? At least other Ruby and Python
devs recognize this lack of features and try to solve it instead of ignoring
it or making up excuses:

[http://metabates.com/2011/02/07/building-interfaces-and-
abst...](http://metabates.com/2011/02/07/building-interfaces-and-abstract-
classes-in-ruby/)

[http://docs.python.org/2/library/abc.html](http://docs.python.org/2/library/abc.html)

Learn some OOP and design patterns before filling your mouth talking about
PHP.

Also, Clojure is a dynamic language too and yet it craves for explicit types:

[http://www.indiegogo.com/projects/typed-
clojure](http://www.indiegogo.com/projects/typed-clojure)

But this is only for noobs who "want to feel safe", according to you. What a
joke. You probably can't even get past an introductory tutorial of this
subject.

~~~
interstitial
By safe he probably means "enterprisy." OOP is pretty much a joke when your
realize every "pattern" ends up being the singleton with a dozen levels of
inheritance by the time a web app development team gets through with it. Every
other pattern will fail by the times the marketing and executives get hold of
it. It should be called the Fox & Tramp bowl of Singleton pattern. But I
digress as I step on the enterprisy toes of team developers.

~~~
jafaku
I don't understand what you are saying. Why everything ends up being a
Singleton? Why do marketing and executives have a say in any of this?

