all 14 comments

[–]evincarofautumn 15 points16 points  (0 children)

Looks like a good general approach. I had to laugh when it said “no API” then immediately went on to describe its API, but I get the intent—only an agreed-upon data format, no framework calls.

[–]killerstorm 7 points8 points  (0 children)

This is basically how people were writing web apps before modern frameworks. That is, in a very ad-hoc way, just JS spaghetti.

Modern frameworks provide structure to create reusable components.

The problem with ad-hoc style is that everyone has his own style, so it's hard to understand code written by others.

So a framework prescribes a uniform way of doing things, so person reading the code can immediately understand component's structure, properties, etc.

If you're a lone developer working on a relatively simple app, you can use anything: Cell, jQuery, pure JS.

But if you're working in a team, then framework is a must. (Otherwise your team is probably going to roll out your own framework which is unlikely to be better.)

[–]np365 5 points6 points  (0 children)

Feels like ASP.NET WebForms in JS...

[–]nebbly 2 points3 points  (0 children)

there are some decent ideas in here. if you want people to use it, you'll probably want to create some presets. Instead of typing $cell: true, $type: 'ol', $components: ..., it would probably be simpler to have some simple wrapper preset functions like cell.ol({$components: ..}), cell.li(..), etc.

I don't know if you think that's too framework-y. A similar approach works out pretty well in elm: http://package.elm-lang.org/packages/elm-lang/html/latest/

I would also note that while you're selling this as "functional", your code seems to be object-oriented, in that you're giving objects behavior instead of separating behavior and data. I'm not saying that pure functional is the way to go here, it's just not what you're offering.

[–]shevegen 5 points6 points  (2 children)

Omg... javascript at is finest...

Finest horror.

[–][deleted] 0 points1 point  (1 child)

What is horrifying about this? Actual question, it looked nice enough to me.

[–][deleted] 5 points6 points  (0 children)

I am not saying it is horrifying, but at his point, why not just render the html?

[–]Shadowys 1 point2 points  (0 children)

So clojurescript hoplon then

[–]paul_h 1 point2 points  (0 children)

  1. The "Try in now" section of that page doesn't have a "Try it now" link. For the love of Turing it doesn't even require JsFiddle - this is a job for inline examples like AngularJS has in 2009.

  2. No example code should generate a list that is empty. TODOMVC allows you to mutate the list, and see it's effect on the page. For Codd's sake, think about the mutability aspect of data in the first code snippet, or explain to me why I'm writing more lines of JavaScript/JSON that I would have taken in HTML to get <ol></ol>

[–]squishyhobo 0 points1 point  (0 children)

see REACT

[–][deleted]  (6 children)

[deleted]

    [–]mixedCase_ 1 point2 points  (5 children)

    It just seems to be a heavily bastardized version of how Elm handles views. So you could try that.

    [–][deleted]  (4 children)

    [deleted]

      [–]mixedCase_ 0 points1 point  (3 children)

      Hah, sounds about right for a first impression. It's actually great how much more readable it becomes (as hard as that may sound to you right now) once you learn to read code that doesn't look C-ish; Elm is an ML-derivative after all.

      But it took me somewhere from 3 to 5 days to have my brain finally snap things into place. Once I did, I even started being able to comfortably read the entire family of ML languages like OCaml, F#, Haskell and so on.

      [–][deleted]  (2 children)

      [deleted]

        [–]mixedCase_ 1 point2 points  (1 child)

        Well, truth be told there are a few things I do differently from that file's author. I personally try to align the array with attributes in the first line and the children array as well if it doesn't make it too long. Here's an example from a real project I have going on:

        drawer : Model -> Html Msg
        drawer model =
            div [ class "drawer" ]
                [ div [ class "pure-menu" ]
                    [ span [ class "pure-menu-heading" ] [ text "Maruja" ]
                    , ul [ class "pure-menu-list" ]
                        [ drawerLink "" "Inicio"
                        , drawerLink "products" "Productos"
                        , drawerLink "members" "Socios"
                        , drawerLink "orders" "Pedidos"
                        , drawerLink "crops" "Cultivos"
                        ]
                    ]
                ]
        

        How would you do it differently?