9 ms·
The Slash Programming Language
- blowski 13y agoWhy 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.
- tluyben2 13y agoWhat do you mean with 'come to understand'? You can use them or you understand why they are there? Because I wouldn't call the former understanding per se and if it is the latter i'm interested to hear about it. If it is something else than 'the developer of x(a,b) was someone else than who implemented y(b,a) and he was lazy or somewhat opinionated, but just not enough to fix the other functions as well' that is.
- blowski 13y agoI could have said "come to live with" instead. It works, it let's me do my job. PHP provides me with a good living (I primarily build boring CRUD apps, also using Python and Ruby). I think part of PHP's popularity is that it offers a good balance throughout a product lifecycle - prototyping (because of the number of libraries), production (because it runs on anything), maintenance (because it's stable and easy to hire for). The best analogy I can give is like someone selling me a car. Right now, I'm driving a 20 year old Ford because I'm more interested in saving money than going quickly. If somebody wants me to get a new car, they need to show how I'm going to save money, not just how quick the other car is. I guess 'Slash' could do that, but right now the copy is not focusing on the difficulties I have with PHP.
- tluyben2 13y agoYeah I thought you meant that. I did too :) But I just hoped you had some divine insight everyone missed here. Shame :)
- ofutur 13y agoAgreed. I've come to rely on so many different libraries, that I would need to see an API first.
- svoroval 13y agoI don't understand how you switch from “wow, guy wrote a language I can use in my projects” to “why should I switch from PHP, I need a more compelling reason” and stuff. And yeah, PHP sucks. And your career path is something you should not think about at all.
- dz0ny 13y agoIn 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 13y agoThat 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.
- camus2 13y agoYou cant rely on long running processes with PHP because of its error system. And PHP threads are a joke. PHP is definetly not a multipurpose language ,it's a string processor ,otherwise you would not have to begin your scripts with <?php
- ceol 13y ago> 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.
- bouk 13y agoNobody is forcing you to switch languages, this is just a hobby project made by someone
- blowski 13y agoI agree. I was more balking at the title ('replacement for PHP') than the page itself.
- aupajo 13y agoNeeds some instructions on how to install it, surely.
- bouk 13y agoThere's compilation and installation instructions here: https://github.com/slash-lang/slash https://github.com/slash-lang/slash
- denysonique 13y agoNode.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 13y agoI 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.
- interstitial 13y agoWe could hope Node becomes such a ubiquitous solution, but the love HN is no great predictor of the future. Often it seems if the early adopters of HN love something, it is doomed. It's got to grab the middle of the bell curve's attention and drag the tail of the HN crowd to it kicking and screaming.
- taspeotis 13y agoPHP 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.
- deleted 13y ago[deleted]
- jawngee 13y agoNo, 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 13y agoThere 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.
- minussohn 13y agoIs there a POC Interpreter for slash, or are these some ideas you had over night?
- bouk 13y agoThere'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
- evincarofautumn 13y agoI wonder why you were downvoted. Maybe people interpreted “POC” as “piece of crap” instead of “proof of concept”.
- dutchbrit 13y agoHow can I download/use it?
- svoroval 13y agoIt is written here: https://github.com/slash-lang/slash https://github.com/slash-lang/slash
- wildtype 13y agoSuccessing PHP's spaghetti?
- sebastianmck 13y agoGitHub project at https://github.com/slash-lang/slash https://github.com/slash-lang/slash
- jawns 13y agoOne 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 13y agoIn 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 13y agoOkay, 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 13y agoInstall 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 13y agoI'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.
- Qerub 13y agoI 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.
- tmikaeld 13y agoI 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.
- daraosn 13y agoWhy 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 13y agoIgnoring 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 13y agoWhat 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.
- ceol 13y agoReally, the only reason Python and Ruby have the same "noticeably higher" barrier to entry is because most cheap hosting services don't support Python and Ruby the same way they do PHP. Python and Ruby are just as easy, if not easier, for a beginner to get into outside of web dev.
- yeukhon 13y agoHave you heard of python -m HTTPServer There is your HTTP Server. What a little more dynamic? Sure. Download Bottle. A single file! Then write something in a separate Python module and you can write raw html too in the bottle response. No jinja is needed. Piece of cake. Lighter than what PHP would require you to setup.
- nercury 13y agoI 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; ?>
- vezzy-fnord 13y agoC-like delimiters are much more logical than the verbose Algol-like delimiters, in my mind.
- meepmorp 13y agoIs that because you are primarily a user of c-style languages?
- vezzy-fnord 13y agoNo, not necessarily. What is a "C-style" language, anyway? Most imperative languages today are descendants from the ALGOL syntax, it's just that C modified some of the more inelegant aspects and made them more terse. Whereas Pascal stuck directly with ALGOL operators and blocks. Just look at environments like Delphi and VB.
- code_duck 13y agoI don't use that syntax for control structures at all. It's like the worst take on Python ever. JavaScript uses curly braces. Any designer who knows anything about coding is going to have to learn JavaScript. How about one syntax?
- charliesome 13y agoHi, 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 13y agoIf 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.
- groovy2shoes 13y agoSure, but doing a new language is fun, and can be a learning experience.
- Skoofoo 13y agoI 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.
- charliesome 13y ago> 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.
- nercury 13y ago"Slap a script on a server and have it run". And then watch it grow over the years into unmaintainable mess :)
- sigfried 13y agolol, often rails sites are the ones that tend to be unmaintainable messes, specially if you use a few gems.
- stevoski 13y agoThe 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 13y agoAnother 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!"
- deleted 13y ago[deleted]
- bouk 13y agoWhat? Ruby works the exact same way. Pretty sure Slash doesn't make variable have an implicit value like PHP does
- rst 13y agoAnd 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 13y ago
- junto 13y agoReminds me of classic ASP.
- edem 13y ago<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.
- RossM 13y agoI think it's a pretty good example to show that it supports the same embeddable-ness of PHP (which is great for prototyping).
- Skoofoo 13y agoIf this project used Ruby, it would be an approachable tool for back-end web development neophytes to learn with before moving on to Sinatra and Rails.
- Segmentation 13y agoIt'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."
- codezero 13y agoI'm glad they mention this on the main page: HTML escaping by default Otherwise this example would make me even more uneasy :)
- peteretep 13y ago> 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'.
- svoroval 13y agoSee Ruby one point nine.
- etfb 13y agoPerl 6 has $x.bytes, $x.codes and $x.graphs, but no $x.length for this exact reason.
- recursive 13y agoAren't strings sequences of characters?
- peteretep 13y agoWhat's a character? A codepoint, or a grapheme? As the correct answer is "that depends", neither answer gets to qualify as "length", especially given that traditionally, a string is a sequence of bytes, which gives a third thing that 'length' could mean.
- e12e 13y agoInteresting 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 13y agoI'm glad it's so obvious to you. Here is a quick test: What is "ö".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?"
- etfb 13y agoNice. 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 13y ago> 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 13y agoDefinitely - 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).
- jafaku 13y agoDoes it have interfaces, abstract classes, and optional types like PHP? Or it is as lacking in OOP as Ruby and Python?
- camus2 13y agoRuby 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 13y agoSo 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-abstract-classes-in-ruby/ http://metabates.com/2011/02/07/building-interfaces-and-abst... 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 13y agoBy 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 13y agoI 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?
- deleted 13y ago[deleted]
- zekenie 13y agoOne 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)?
- misuba 13y agoYada-yada operator: genius.
- alkonaut 13y agoLooks 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 .
- EugeneOZ 13y agoAll the dirt of PHP and Perl + antipatterns in examples.
- andrewflnr 13y agoSeeing 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 13y agoYou’re thinking of Swym (http://swym.in/ http://swym.in/) and its “etc” operator.
- andrewflnr 13y agoYes, thank you. I'm adding it to my list so I don't forget it again. :)
- deleted 13y ago[deleted]
- brandonhsiao 13y agoIf 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.
- pan69 13y agoThe 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 13y agoHow 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 13y agoI 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.
- hayksaakian 13y agoWhat's wrong with rack or Sinatra?