r/programming • • May 15 '15

A website coding itself live

http://strml.net
4.9k Upvotes

418 comments sorted by

View all comments

Show parent comments

164

u/cogdissnance May 15 '15

I think for most people it's just the that the front-end is a veritable mess. There's a real lack of standards, and while that may mean there's more experimentation and some sense of freedom (which makes it a bit fun for me), you end up with a million ways to do the same thing, and none of them work well with the framework you've chosen. It becomes even worse when you have to support multiple browsers and nothing every looks the same on all of them. It's just a sea of variability in frameworks, libraries, browsers and not one piece of solid ground to stand on if you catch my drift.

71

u/[deleted] May 15 '15

Front end is the wild west, frameworks are reproducing bare-back and finding one that will stick around is like throwing lawn darts in the air.

17

u/[deleted] May 15 '15

frameworks are reproducing bare-back

Such impossible perversion!

13

u/mikethecoder May 15 '15

Forget MVVM... that is so yesterday! Now it's all about MVCVM which is a take on MVC with a twist of MVVM packaged with Grunt. This is the correct way to do things :|

Knockout.js is Model-View-View-Model (MVVM) pattern. Seriously what the fuck does that really mean anyway? We make our framework better by simplifying it without the C and doubling up on your M's and V's.

2

u/[deleted] May 16 '15

Knockout is not so great, heading the way of dojo. React, backbone, marionette, ampersand are all pretty decent.

2

u/zynoda May 16 '15

What is it you don't like about Knockout?

→ More replies (1)
→ More replies (3)

3

u/BigTunaTim May 16 '15

Wild west, bareback and lawn darts in a single programming-related comment. I am so sorry to the futurists I mocked when they predicted the internet would change everything and make our lives better. God bless you magnificent bastards.

→ More replies (2)

47

u/LainIwakura May 15 '15 edited May 15 '15

This is why I hate it. I'm even trying to get into it a bit more at the moment but it's like where do I start? There is angularjs, backbonejs, emberjs, reactjs, etc., I thought about looking at ember but then I saw you install it through node!? wtf?? It seems weird to install a front-end library through the node package manager (I thought that was server-side tech?)
There seems to be no standard way to do anything- not just with JavaScript but CSS too (just try figuring out how to center something- half the time it might be margin: 0 auto; the other half it's 'lol who knows?'). So as a result of all of this everyone made up 50 different things to fit their own special use case and for some reason this madness has caught on!

EDIT: Woah I should have worded this a bit differently. I'm not looking to start front-end web-dev in general, I was around when jQuery was the hot new thing and we didn't have CSS3. I'm just looking to move beyond my late 2000's level knowledge of front-end development. Thank you everyone for all your recommendations though, I just got a new macbook pro for development (I heard the cool kids do it) so I'll be playing around a lot =)

13

u/[deleted] May 15 '15

Oh boy, I have been in the same boat for a while now. I got into front end development about six months ago, and it's just daunting how much there is to learn, how many ways there are to do everything, how many frameworks there are, etc. This is where I am right now (still early on though, I only do this for fun projects in my spare time):

I'm using Bootstrap and Font Awesome for the bulk of the HTML, CSS, JS, fonts, glyphs, etc. I love how I can build a UI that pretty much automatically works across all devices. Not perfect, but cuts out a TON of work and gets me most of the way there. I think this is a great place to start and could probably work for most projects (that I would do anyway).

I've heard great things about KnockoutJS, plus their site is amazing. I've been going through their tutorials and everything seems rather logical to me. AngularJS totally blew my mind because of how complex it was and now Google is doing a bunch of backwards incompatible changes in 2.0 anyway, so I'd be even more hesitant to learn it now. I will likely go with KnockoutJS for now, but I'm still nervous about whether or not this is the right choice.

Of course, I use jQuery for some stuff as well.

I'm looking at doing some websocket stuff too. I will likely go with Autobahn and Crossbar.io because I'm a Python guy. I've toyed around with Socket.IO as well, which is pretty cool too.

I'm still trying to reduce the complexity of all of this, but so far this is the stack that's working for me.

8

u/[deleted] May 15 '15

I also jumped from backend to frontend long time ago. I love the web and yes it can be confusing with all the frameworks / libraries / etc. If you try to keep up with all the frameworks you will be frustrated, that's for sure. If you like a framework / library and want to play and learn it, then go for it. And Knockout is solid!. However what i have learnt in all the years i've been doing Frontend is that the most useful things to learn are the core technologies and maybe a few libraries/tools. Time spent learning a framework and forcing a project to adopt framework structure has been mostly wasted.

  • Understand Js ( scopes, prototype, closures..)

  • If you can solve the problem easily with JQuery don't be afraid of doing it. No need to add complexity just because it's not a "pure" solution.

  • Understand how the DOM works.

  • Feel comfortable writing CSS

  • Practice with CSS layouts ( there are multiple ways to solve a problem with CSS, some hacky ways, other more "elegant" )

  • Jump to a better language for writing Stylesheets ( LESS is simple and powerful, but SASS works fine )

  • Improve your toolchain. Bash scripts are fine for a lot of cases, but some people like Gulp/Grunt for automating workflow tasks.

  • Live happy with the fact that it's not possible to know all the cool libraries released every week.

  • Most importat for me: Do fun things! Even if they are not super engineered. Play with ( Canvas / SVG / WebGL ) and you will have lot's of fun.

Good luck!

→ More replies (1)

4

u/d00d1234 May 15 '15

I'm learning jQuery right now and it seems super powerful. Loving it.

2

u/[deleted] May 15 '15

It is!. You can do a lot of cool things with it.

2

u/flying-sheep May 15 '15

Well, i don't think there are right or wrong choices:

Enough people are invested in all the individual alternatives to keep them updated and viable.

I personally like react for its simplicity (unidirectional data flow instead of a tangle of messy stuff going up and down the DOM hierarchy).

But I'm sure knockout and angular are just as good if you get into the mental model.

2

u/ericl666 May 16 '15

Bootstrap changed my life. I make web apps 10x faster now without having to deal with with all the cross browser issues, sizing for various resolutions, etc.

→ More replies (2)

11

u/protestor May 15 '15

At very least, you should begin with some minimal CSS reset that brings you into sane defaults (the best being Normalize.css). On this same vein, you could do worse than beginning with HTML5 Boilerplate.

But actually I think you should start with a "responsive" CSS framework. They normally include their own CSS reset (or points you into which one you should use), plus default styling like better buttons and headings. But they are actually useful to get great layout in both cell phones and desktops, from day one. No more CSS hacks for getting layout right: it just works. Life is too short. This is usually done with something called a "responsive grid". The idea is that you make a two-column (or three-column) layout, with a "sidebar" and the "content", and you get it to automatically collapse into a single column for devices with small screens. This site compares responsive websites in different screen widths.

The design choice here the max width of your base layout (this normally is decided by your framework) and the proportions between the columns (this is up to you to decide, but the framework will give you something like 3 or 10 choices). I think this approach was popularized by Bootstrap, a CSS framework made by Twitter. I don't actually recommend you begin with Boostrap, it's a big thing full of stuff.

I think the best CSS framework for your use case is Skeleton. A second contender could be Purecss, but even it does too much.

I'm talking "CSS framework" as if it were a very involved thing but in reality it is (or should be) a single CSS file you add to your page. At least at first, you don't interact with it except by using the classes provided for the responsive grid. Other than that, it just provides better defaults that will make you worry less about how your site looks like shit. You can change those defaults in your own CSS file.

About Javascript: nothing wrong about using jQuery (or Zepto. But jQuery is okay). If you move around a lot of things in your page, your performance might suck and your code will be overcomplicated (since you're changing elements by hand all over the page), and moreover some people may say that jQuery itself sucks, and they might be right, but other than that it's fine.

A templating library like Handlebars may make your code simpler. And even though it's slower, it's okay to do templating on client-side. I actually use ICanHaz. I think it's great. Also, if you do a lot of Ajax or otherwise have a lot of callbacks, make sure to read about promises, they make your code much easier to read and reason about. Actually, getting rid of nested callbacks is half of the battle.

Indeed, for all those things you may add, you need to think: does it make the code simpler? Easier to modify? Does the code get too bloated? You can do everything with raw Javascript - would it be better?

If you don't understand (or agree with) the need for a framework, don't use this framework. Said that, my understanding, jQuery isn't really the best thing for building "web apps". With "apps", you should really have components that are responsible for rendering themselves, that's for your own sanity when you need to debug the monster. But jQuery suggests a different discipline, in which every part of your code can directly change the DOM from everywhere, and it's a mess. This mess is okay for simple "web pages" though (Or even simple apps. Or even complex apps if you feel like it).

So at this point, we have one or two third-party CSS file (either your CSS framework, or Normalize.css, or both if your framework don't embed a CSS reset and suggests you use both -- or something else to make CSS less crazy). We also have something like jQuery. Also a templating library because we're cool. So that's 3 files or 4. Do we need Npm? Bower? Browserify? Require.js? Grunt? No we don't. Do we need a build step at all? No. Well not yet.

Now, those things are great, but after you get yourself started and is building stuff. You can use them later.

We just get the minified (or not) version of those files and put it our directory. The HTML ends up looking like this:

<!doctype html>
<html lang="en">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="css/normalize.min.css">
  <link rel="stylesheet" href="css/skeleton.css">
  <script src='zepto.min.js'></script>
  <script src='ICanHaz.min.js'></script>

(the viewport stuff is part of the responsive design)

Well the response ended up bigger than expected, but that's probably because I didn't trim it to the essentials.

→ More replies (1)

15

u/davechiu May 15 '15 edited May 15 '15

The learning curve has become really steep with all these new frameworks, some are frameworks for your app (in the browser) others are for your local development environment, others are for the server, some can be used across the board.

You don't have to install it with node, you could always just include the necessary package as you would any other JS file: //cdnjs.cloudflare.com/ajax/libs/ember.js/1.12.0/ember.min.js

The reason to install it via NPM or Bower would be for dependency/package management if you're working on a larger project across multiple developers. Or even portability of your project across multiple machines.

There's a difference between running node as a server for your application, and using node (via Grunt or Gulp) as a task runner for front end development so you don't have to write in straight HTML/CSS.

For example: on some of my projects I will use Node (Grunt) so that I can use Handlebars, SASS/SCSS, etc... and build static web apps really easily while taking advantage of more programatic features while delivering regular HTML and CSS.

Edit: I would also say that as a Front End Dev your gripes are exactly why I stay away from Back End Development as much as possible, it seems like the same mess to me only more complex: http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks#Java_2

8

u/gfixler May 15 '15

The learning curve has become really steep

I haven't tried to make a web thing since 2000, but I've been getting more interested in the last year or so. I finally [think I] learned what routes are this week, so I should be caught up again by 2032. Hopefully they won't change anything else before then.

3

u/davechiu May 15 '15

haha, I hear you, I'm just now starting to get really comfortable with Grunt and Gulp is the hot new thing. But, the whole grunt/bower/yeoman trifecta was worth it in my opinion.

20

u/gfixler May 15 '15

See, as far as I can tell, you're just making up words right now.

4

u/elZaphod May 16 '15

One year ago I was with you- spent the past dozen years mostly on back end Enterprise Java.

Something snapped and I have since taught myself Node, Knockout, Angular, npm, Bower, Grunt, underscore, Bootstrap, Jade, Famo.us, Stylus...

2

u/gfixler May 16 '15

Man, you rage-learned.

2

u/elZaphod May 16 '15

I'll show them. I'll show them ALL!

2

u/[deleted] May 15 '15

Grunt & Gulp are build tools. Just like Make, except written in javascript.

Bower is a package manager, except written in javascript.

Yeoman allows you to generate barebones for your applications (depending on the framework). It's probably written in javascript too.

→ More replies (1)
→ More replies (10)

4

u/dacjames May 15 '15

I thought about looking at ember but then I saw you install it through node!? wtf??

All of the modern tooling for web development is written in javascript, so you need node on your workstation to run it. It's a little bit of a pain to set up, but the results are amazing if you haven't done web development in a while: tools will do dependency management for you (bower for front-end, npm for tools), yeoman can generate stuff for you, and grunt/gulp allows you to set up automated builds that apply any pre-processors (sass/less for css, typescript/coffeescript/es6 for javascript), inject everything into your html and serve a development page that automatically reloads when you save it a file! Testing has improved tremendously as well.

Things are a bit wild and rapidly changing but there has been immense progress on tooling in the past year that you can tap into with node, even if you don't use it for you backend development.

→ More replies (4)
→ More replies (12)
→ More replies (2)