Live data from Hacker News

A Dead-Simple Web Stack in Haskell

williamyaoh.com

61–70 of 120 posts

Re: A Dead-Simple Web Stack in Haskell

#61

I think a simple web stack should aspire to the simplicity of the PHP stack, twenty years ago: 1) Create a directory "foo" on your server 2) Make a file called "bar.php" in that directory 3) Write "Hello World!" in the file 4) Open http://localhost/foo/bar.php in the browser and see "Hello World!" Lines of code or configuration so far: zero . 5) Add some actual code to bar.php 6) Reload the page and see the result Nu…

> Lines of code or configuration so far: zero. Yes. But by not having configuration, it delegates the configuration to the webserver. Which means that it(and even the language itself!) will exhibit surprising behavior (and even security vulnerabilities) if you deploy somewhere else.

Sometimes, having to be explicit about config pays off.

Re: A Dead-Simple Web Stack in Haskell

#62
post #44

This is a great tutorial for getting up and running fast. I started off with Spock too but grew out of it pretty quickly. It's painful in Haskell you're learning it but feel you're not able to generate anything real for the first month(s) with it. Unfortunately, there's not many up-to-date tutorials like these available for beginners.

Do you have any recommendations for next steps beyond Spock?

I learned Haskell at uni and am interested in going back to it for web work (instead of Erlang). Any insights you might be able to share would be really helpful!

Re: A Dead-Simple Web Stack in Haskell

#63
Not sure what's meant by "simple" here, but it looks quite complicated to me. Even though I use something similar at work (with Servant), but much simpler (FSVO "simple") approaches as a hobby:

- Those frameworks relying on built-in servers, including all their dependencies, are huge. If a program is linked statically (the default for GHC/cabal), that's also a very large codebase that doesn't get updated on system updates. Plain CGI (or FastCGI, if needed) is much more lightweight, and an external web server usually provides generic logging.

- postgresql-simple provides more than just protection against SQL injection; that is implemented in the C libpq, and usable with postgresql-libpq bindings (which are used by postgresql-simple) too.

- Database connection information, in case of PostgreSQL, doesn't require a fancy configuration: libpq reads it from environment variables. In many cases even those don't have to be set: by default it would try to connect to a local database, under current user, and to the database matching user name.

- PostgreSQL itself can compose XML (XHTML/HTML 5), which then can also be processed with XSLT, cutting out the blaze-html dependency.

- Custom logging facilities tend to be a pain to work with, and not necessary either; there are syslog and journald.

Using all that (and even more) instead of more lightweight/low-level/low-dependency alternatives seems like a sensible compromise in some situations, and I don't mean to say that it's somehow bad, but not seeing how it's "dead-simple". Maybe it's one of those "simple versus easy" cases, or just about different kinds of simplicity.

Re: A Dead-Simple Web Stack in Haskell

#64

Earlier quoted context omitted.

Haskell2010's definition is like 20 pages long and that includes the definition of the standard library. This core accounts for 90-99% of the code in project that isn't going out of its way to use fancy features for the lulz.

Name me a single company that uses Haskell 2010. It's completely irrelevant. But I'll leave you to argue with Vitaly Bragilevsky (speaking at Galois): "Haskell is a big language" -- https://galois.com/blog/2018/11/teaching-haskell-in-the-real... Or Paul Hudak, Philip Wadler, and Simon Peyton Jones: "Haskell is a big language" -- https://www.microsoft.com/en-us/research/wp-content/uploads/... (p.28) Maybe those guys k…

[deleted]

Re: A Dead-Simple Web Stack in Haskell

#65

I think a simple web stack should aspire to the simplicity of the PHP stack, twenty years ago: 1) Create a directory "foo" on your server 2) Make a file called "bar.php" in that directory 3) Write "Hello World!" in the file 4) Open http://localhost/foo/bar.php in the browser and see "Hello World!" Lines of code or configuration so far: zero . 5) Add some actual code to bar.php 6) Reload the page and see the result Nu…

It is intriguing that nobody's replicated PHP's ease of deployment. Every other language does require downloading some sort of runtime and setting up some sort of templating/page serving system. Would be an interesting experiment to start with essentially an HTML generating DSL like PHP, but with more modern language design.

Re: A Dead-Simple Web Stack in Haskell

#66

I think a simple web stack should aspire to the simplicity of the PHP stack, twenty years ago: 1) Create a directory "foo" on your server 2) Make a file called "bar.php" in that directory 3) Write "Hello World!" in the file 4) Open http://localhost/foo/bar.php in the browser and see "Hello World!" Lines of code or configuration so far: zero . 5) Add some actual code to bar.php 6) Reload the page and see the result Nu…

The steps you listed work in any language, that's just the browser rendering a text file :).

Re: A Dead-Simple Web Stack in Haskell

#67

I think a simple web stack should aspire to the simplicity of the PHP stack, twenty years ago: 1) Create a directory "foo" on your server 2) Make a file called "bar.php" in that directory 3) Write "Hello World!" in the file 4) Open http://localhost/foo/bar.php in the browser and see "Hello World!" Lines of code or configuration so far: zero . 5) Add some actual code to bar.php 6) Reload the page and see the result Nu…

Did you forget the “A” in LAMP? It’s hardly zero configuration.

On centos it was pretty near zero config. With Wamp it was a windows install file and had a neat stack together.

Back on my c64 I turned it on, no booting and could just start writing code.

We've moved away from this sadly.

Re: A Dead-Simple Web Stack in Haskell

#68

I think a simple web stack should aspire to the simplicity of the PHP stack, twenty years ago: 1) Create a directory "foo" on your server 2) Make a file called "bar.php" in that directory 3) Write "Hello World!" in the file 4) Open http://localhost/foo/bar.php in the browser and see "Hello World!" Lines of code or configuration so far: zero . 5) Add some actual code to bar.php 6) Reload the page and see the result Nu…

Doing PHP programming was my first programming job, lasted for about 3 years. While I agree with you about the allure of PHP, to be honest, I will never choose PHP again or touch any projects that uses PHP. PHP is an awful, obsolete language, patched again and again to make it more modern. It's like wearing an old leather jacket that has been patched repeatedly, yet it still has a nasty smell. This is entirely subjec…

Varnish? Wow I remember that.

Maybe your opinion could use some refreshing. Even Javascript is very different nowadays.

Re: A Dead-Simple Web Stack in Haskell

#69

I think a simple web stack should aspire to the simplicity of the PHP stack, twenty years ago: 1) Create a directory "foo" on your server 2) Make a file called "bar.php" in that directory 3) Write "Hello World!" in the file 4) Open http://localhost/foo/bar.php in the browser and see "Hello World!" Lines of code or configuration so far: zero . 5) Add some actual code to bar.php 6) Reload the page and see the result Nu…

While you can theoretically get to this level of simplicity with various tools I think the difference isn't so much "can it be this simple?" so much as "does this level of simplicity fit my needs?" and that can be harder to quantify. The same thing you wrote in PHP done in Node.js in an arbitrarily named file served from root: require('http').createServer((_, res) => res.end('Hello World')).listen(80); Zero configura…

[deleted]

Re: A Dead-Simple Web Stack in Haskell

#70

I think a simple web stack should aspire to the simplicity of the PHP stack, twenty years ago: 1) Create a directory "foo" on your server 2) Make a file called "bar.php" in that directory 3) Write "Hello World!" in the file 4) Open http://localhost/foo/bar.php in the browser and see "Hello World!" Lines of code or configuration so far: zero . 5) Add some actual code to bar.php 6) Reload the page and see the result Nu…

1) Install node js 2) npm install express 4) Define handler Seems simple enough ?

For what it's worth, I agree with you. I associate installing node and installing LAMP/WAMP with similar levels of "difficulty."

Sure, `http.createServer` is a few more lines of code compared to the equivalent PHP `hello world` but I don't see it as an insurmountable hurdle.

Post reply on HN