Environments/language choices



  • Hey folks, looking for a bit of advice on this one.

    Looking to build a web service of sorts. Will need to serve some static files, and handle dynamic endpoints. The backend is nothing special, it's largely a straight-forward CRUD application, and I don't need to worry about performance for the most part. The real work of the website will be in the JS/AJAX interface that consumes the web service, meaning that the backend is largely uncoupled from the front end.

    Ordinarily I'd build this in PHP because it's not exactly the most difficult thing but I want to do it in something that isn't PHP for once, mostly due to the clusterfuck that is the PHP frameworks. I was going to do it with Laravel but given the hours already burned just trying to install the dev environment, I figured I'd give it all a miss.

    It's a hobby project so there's no time budget or pressure and I'd like to learn something new for a change. Ideally something I can drop onto a $5 Digital Ocean droplet in the future, or maybe the $10 one.

    Thoughts and suggestions gratefully received πŸ˜„


  • FoxDev

    <Recruitment org="SockDrawer">

    You are a veteran of WTFPHP, as such can i interest you in NodeJS?

    </Recruitment>



  • I'm a veteran of both WTF and PHP, the two are not mutually exclusive πŸ˜›

    I did look at Node a few years ago and the entire thing felt like I was building it on sand - and lots and lots and lots of callbacks because the operations I was trying to handle were essentially a series of operations that couldn't really be handled out of order. I think I stopped after hitting 12 nested callbacks 😦

    Maybe it's gotten better or maybe if I looked again I'd realise I was doing it wrong. Maybe I should check out SockDrawer and see if it was me Doing It Wrong...

    At this point, though, I wouldn't even rule out something like RoR... *shudder*


  • FoxDev

    @Arantor said:

    Maybe I should check out SockDrawer and see if it was me Doing It Wrong...

    I'd suggest avoiding using the SockSite project as a model for how to do it..... I implemented that as one giant WTF.

    It's on my list to revisit to make it better.

    If you go the node route let me know and i'll be happy to help with your project. I'm told i make an excelent sounding board!



  • There's C# - you can run web apis in self-host mode on top of mono. I've never done it before, but it's definitely a possibility. No idea if it would be something you can put in a droplet though.


  • :belt_onion:

    @accalia said:

    I'd suggest avoiding using the SockSite project as a model for how to do it..... I implemented that as one giant WTF.

    QFT.
    Why do you think I haven't done anything for discopaedia.org?


  • FoxDev

    @sloosecannon said:

    QFT.Why do you think I haven't done anything for discopaedia.org?

    yeah.... i know...

    i really should have done a better job ther, but i was in a groove, and it was late at night, i may or may not have had a little rum and coke....

    i really should have started with a good web framework like express and just done a proper job of it, it's not like it was that complicated!

    tell you what, after i get v2.11 of @sockbot out the door i'll go back and do a proper job of SockSite.



  • @‍accalia has summoned me, and so I appear.


  • Winner of the 2016 Presidential Election

    Python+Flask would be my first choice for a simple backend



  • Looks like it might be doable to run Mono on DO but it's a lot of messing about from what I can tell, but will bear that one in mind πŸ˜„



  • Honestly with SockSite it looks like I at least can follow the basics of what it's doing - something I can't really do with Sockbot, because I looked at the repo and tried to have some semblance of 'wtf is going on here'.



  • Haven't done Python in years, never seen Flask before, thanks for the suggestion πŸ˜„


  • FoxDev

    @asdf said:

    Python+Flask would be my first choice for a simple backend

    a good choice, but lacking that subtle WTF factor of doing javascript serverside.


  • FoxDev

    @Arantor said:

    Honestly with SockSite it looks like I at least can follow the basics of what it's doing

    that's true. it's not a pretty architecture, and it's painful to develop in and i should totally have done better there, but at least it's easyish to follow what's happening.

    @Arantor said:

    something I can't really do with Sockbot, because I looked at the repo and tried to have some semblance of 'wtf is going on here'.

    yeah. there are two things that aren't helping there, one is the code is ES6 code which looks a lot different than ES5 code,

    the other thing is it's dealing with the fustercluck that is the discourse JSON api and trying to sanitize it for the plugins.

    unless you're talking about the legacy 0.xx releases which suffer from even worse design than SockSite!



  • I'll be writing enough JS for the front end that I won't want to write more than I have to.

    And yeah, I can tell dealing with the DC API is a clusterfucky world of pain, like using it is generally.

    I was looking at the current versions in the repos, and I have to say, JS is not my favourite language, I'm still not sure what's new and magical in ES6 to be honest, not like I've had time to study it 😦


  • Grade A Premium Asshole

    Why not give Ruby/Rails a try?


  • FoxDev

    @Arantor said:

    And yeah, I can tell dealing with the DC API is a clusterfucky world of pain, like using it is generally

    yeah it is. that's part of why SockBot does as much as it can to insulate the plugins from that.

    @Arantor said:

    JS is not my favourite language

    fair, i won't call you out on that.

    @Arantor said:

    I'm still not sure what's new and magical in ES6 to be honest, not like I've had time to study it

    there are a lot fo nice features: http://es6-features.org/

    the features i went to it for with SockBot were:

    and

    also it's coming and i wanted to learn.


  • FoxDev

    @Polygeekery said:

    Why not give Ruby/Rails a try?

    do not want!



  • Unfortunately given that part of the site will be spending its time doing evil with LocalStorage, with the server part being merely a repository of sorts for content and sync purposes, I will have to deal with JS a lot 😦 DO NOT LIKE

    ES6 looks like it has some interesting fun things coming, which is neat.

    Have been reading up on Python/Flask and RoR... Flask is currently winning that particular race and Node is in a close third place right now.



  • @Arantor said:

    Have been reading up on Python/Flask and RoR... Flask is currently winning that particular race and Node is in a close third place right now.

    I'm doing both node.js/express and python/flask ATM. IMO if you want a simple no-hassle web API, go with node.

    I found python to be pain in the ass when it comes to JSON handling. You have to decompose everything down to nested dictionaries and/or objects, can't just do JSON.parse() and have your object exactly as you had it in browser. Then just throw it into Mongo or whatever simple store you're using. Maybe a more experienced dev would have found a better solution, but as a relative python noob, I found myself pining for node all the time.

    Also, there's the whole fuckup with python 2/3 split. It'd make sense to brush up on Python 3 in a greenfield project. However, flask is ATM only officially supported for Python 2. So, it's annoying either way.

    Finally, you can use this as an opportunity to get into ES6, which will serve you well in your future frontend work as well.

    The other option I can sort of speak about is Ruby + Sinatra (not Rails), It's a neat little framework, inspiration for both .NET WebAPI and Flask. If you want to get into ruby, this is a solid choice. I wouldn't. Ruby seems to be losing steam lately.

    You can also look into Go (ask @benlubar about that) and Elixir + Phoenix, if you want the freaking bleeding edge, hot off hacker news. I guess java guys can recommend whatever lightweight-y thing they have too.



  • Hmm, interesting - would have thought it would almost have been the other way around (Python vs Node)

    I'm not really fussed so much as to which backend I go to, the programming aspect is more about being fed up with PHP and wanting to do something a bit different and wanting to get into it without too much headache.

    If I want to know about Go, I have the spirit of Ben L. at work with me, reads HN, programs in Go, and has been telling me about both Go and Elixir of late but there is a part of me that almost doesn't want to out of 'if it's on HN, it's probably too hipster for me' or something if that makes sense.

    Maybe Node is the way to go. Only downside is I pretty much can't talk to my buddy at work about it because it's, well, Node and thus EVIL because it's not Go/Elixir/Rust. Or whatever.


  • I survived the hour long Uno hand

    We use Hapi for our node backend, it's really easy to set up and pretty straightforward. I'm told Express is the same way. Once you get a framework to handle most of the overhead, it becomes pretty simple to make a lightweight api.



  • @Arantor said:

    Elixir

    yep, because elixir doesn't run on top of node....

    @Arantor said:

    I was going to do it with Laravel but given the hours already burned just trying to install the dev environment

    in linux it was pretty straightforward for me. while installing it on windows for "the junior" i had a couple of :wtf:s but no more than a couple of hours of google search and/or terminal-fu.



  • I spent 3 hours on trying to install it on Windows and decided it wasn't really worth my time and effort... because my experience is, if the installation is that much of a clusterfuck, the odds of everything else being the same are pretty damn high.



  • <obligatory strong typing fanboyism>
    Spring makes writing a simple java rest service pretty damn simple.



  • @Buddy said:

    Spring

    :do_not_want.sass:

    I'm currently dealing with an spring application made by morons. it hurts so bad.



  • @Arantor said:

    I spent 3 hours on trying to install it on Windows

    :wtf:
    git + composer + composer create-project laravel/laravel --prefer-dist

    didn't do it?

    anyway, ONT: a friend suggested me to try node + loopback
    i did a small rest API to test it, and it was pretty easy. might be worth a try



  • @Arantor said:

    I have the spirit of Ben L. at work with me, reads HN

    I don't read hacker news.

    @Arantor said:

    Elixir

    never heard of it



  • @Jarry said:

    @Arantor said:
    I spent 3 hours on trying to install it on Windows

    :wtf:
    git + composer + composer create-project laravel/laravel --prefer-dist

    didn't do it?

    anyway, ONT: a friend suggested me to try node + loopback
    i did a small rest API to test it, and it was pretty easy. might be worth a try

    Once I install Git somewhere, followed by installing Composer somewhere, that might have been a thing. On Windows this is not the easiest thing one can do.

    Followed by installing a dev environment on Windows that doesn't suck ass with 18-month old versions of crap. Technically WampServer is good enough - but only just. And from experience, trying to get Composer to play nice with the PHP install in WampServer is a nightmare. XAMPP includes Perl and has some weird issues playing nice at times with stuff that works out of the box everywhere else. EasyPHP ditto on the weird issues.

    Though this is a recently reinstalled PC, it doesn't have WampServer or anything else installed on it yet, hence trying to follow the Laravel Homestead deal which has all the dependencies pre-rolled. In theory. In practice, fuck only knows.

    There's a lot of frustration in this and I just wanted to get started so I could spin up what was supposed to be a simple backend (well... ish... there are a few interesting gotchas going on) without having to fart around with dependency management and shit.

    I've now spent half a day on this and if this were for work, I'd have already said screw-it and started building in framework-less PHP. I just want this to be more fun and learning something new... like a new framework or maybe in the worst case a new language, not to feel like the industry has left me behind and that I'm too stupid to do this.



  • @Arantor said:

    Laravel Homestead

    never worked for me =/

    https://chocolatey.org/packages?q=php may be useful.

    @Arantor said:

    I've now spent half a day on this and if this were for work, I'd have already said screw-it and started building in framework-less PHP. I just want this to be more fun and learning something new... like a new framework or maybe in the worst case a new language, not to feel like the industry has left me behind and that I'm too stupid to do this.

    symfony did that for me. :hug:

    I try to install each component of my dev enviroment alone, that way i have full control. the solutions like <*>amp always had their own quirks.

    honestly. i sound like a laravel apologist. I'm not, it provides solutions for problems we have, a doesn't create many new ones.

    the only thing i can say is that if you're going PHP use composer, it's one of the few things in PHP that doesn't suck

    anyway, i'm bookmarking this thread. i may need to do a "(not completely but almost) simple REST API" in a couple of months...


  • :belt_onion:


  • Winner of the 2016 Presidential Election

    @Arantor said:

    Haven't done Python in years

    I don't write a lot of python either, but whenever I do, I notice that it takes me way less time to quickly prototype something than in any other language. And even if I write a quick and dirty script, I can easily read and understand that script again a few weeks later. That's what I love about python. And I find both Python 2 and 3 okay, so I'm fine with using whatever version the libraries I currently need force me to use.

    @cartman82 said:

    Ruby seems to be losing steam lately.

    So people have finally figured out that this language is horrible? Good.

    @Jarry said:

    the only thing i can say is that if you're going PHP use composer, it's one of the few things in PHP that doesn't suck

    +1. Using composer and either Laravel or Symfony is the only way you can use PHP without hating yourself.



  • @asdf said:

    Python+Flask would be my first choice

    What's in the Flask? Trying for the Ballmer Peak?


  • :belt_onion:

    Spring's how-many-more-layers-of-XML-can-we-make-you-add is the antithesis of strong-typing (yes, I know you can use annotation-driven setups now, but I suffered through the older way). Dropwizard is definitely easier there, but I would personally go with Scalatra if I was going down the JVM route.

    However, I would not recommend going down the JVM route if you want something as a new side project. You'll spend far too much time trying to separate out the wheat from the chaff library-wise ... principally because the ecosystem is huge and everybody and their brother has an opinion (most of them copy-pasted from someone else's opinion) and they're all wrong.


  • :belt_onion:

    @cartman82 said:

    You have to decompose everything down to nested dictionaries and/or objects, can't just do JSON.parse() and have your object exactly as you had it in browser

    I'm curious ... what you were doing that json.loads wasn't what you needed (it parses to dictionaries and lists just fine and serializes everything that you'd expect to be serializable just fine).

    @cartman82 said:

    However, flask is ATM only officially supported for Python 2.

    Actually, Flask has supported Python 3 since 2013, πŸ˜„





  • @svieira said:

    I'm curious ... what you were doing that json.loads wasn't what you needed (it parses to dictionaries and lists just fine and serializes everything that you'd expect to be serializable just fine).

    I'm turning data into my own objects. Which means I have to have special deserializer for every little thing.
    Dunno, I just found the entire process tiresome compared to js.

    Maybe I would have been better off just using dictionaries.

    @svieira said:

    Actually, Flask has supported Python 3 since 2013,

    http://flask.pocoo.org/docs/0.10/python3/

    Recommendations
    Unless you are already familiar with the differences in the versions we recommend sticking to current versions of Python until the ecosystem caught up.

    This, combined with my own experience of flask blowing up on py3 tells me newbs like @Arantor and me should stick with 2.


  • β™Ώ (Parody)

    @cartman82 said:

    I guess java guys can recommend whatever lightweight-y thing they have too.

    I'm not familiar with any such thing. Go enterprise or go home.


  • Considered Harmful

    There's Apache Sling, if you like OSGi and hierarchical databases. It's heavy, but a much more cohesive model than you will get with Node.js currently.



  • After some battling with my computer, I got Composer to run and installed Laravel that way into a XAMPP setup, so I can build my app with that without too much future pain. Am liking it so far.

    Though I might still experiment with some of the other stuff here, I have other ideas that couldn't be done in PHP (e.g. WebSockets is not a thing you ever want to do in PHP)


  • Fake News

    On the JVM side I heard some praise for the Play framework. Granted, it's Scala, but it did figure out on-the-fly compilation.


Log in to reply