Last active
August 29, 2015 13:59
-
-
Save robotlolita/10975931 to your computer and use it in GitHub Desktop.
Java web vs Phemme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package something; | |
import javax.servlet.ServletException; | |
import javax.servlet.ServletConfig; | |
import javax.servlet.http.HttpServlet; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; | |
import javax.servlet.annotation.WebServlet; | |
@WebServlet("/") | |
public class FeedServlet extends HttpServlet { | |
public void doGet(HttpServletRequest req, HttpServletResponse res) { | |
res.setStatus(HttpServletResponse.SC_OK); | |
res.addHeader("Content-Type", "text/html; charset=utf-8"); | |
String name = req.getParameter("name"); | |
res.getWriter().write(...); // You'd have this in a separate layer, e.g.: JSP | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Nodes are first class, all of these stuff are objects | |
let hello = |name| => | |
<html> | |
<head> | |
<title>"Hello, " name</title> | |
</head> | |
<body> | |
<h1>"Hello, " name</h1> | |
</body> | |
</html> | |
`/ get: |req| => | |
-- This is not text, it's all objects, it'll yell at you if you get anything wrong | |
Headers: | |
Status: 200 | |
Content-Type: "text/html" Charset: "utf-8"; | |
Body: hello req/params/name | |
-- Since all those headers are the default, you can just have: | |
-- `/ get: |req| => Body: hello req/params/name |
The cool of Phemme is that we now can write HTML inside the own language, no need to specify a block for it. We can just mix both them, different of PHP, where we always must to close the current block '?>' and write the HTML or give an 'echo'|'print' to the code. Whitespace strictness is good for me 😄 But you can't forget about multiple inheritance! Traits, Mixis, both them are valid ^^
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Which one to choose? That's so difficult!11!1! hahaha :v