News for hackers. Stuff that matters.
Re:Why Learning to Code Is So Damn Hard by SilasX on Wednesday February 04, 2015 @02:47PM (#8999205)
Unless you're doing Rails, in which case it'll be read as a magic method and guess what you meant :-P

Seriously, that was a major sticking point for me having programmed for a long time: going from "if you have not declared that identifier, game over" to "magic happens".

Re:Why Learning to Code Is So Damn Hard by cblock811 on Wednesday February 04, 2015 @04:26PM (#8999959)
I've been teaching myself off of online resources and 'magic' was what I hated most along the way. I can't debug magic. I've ended up digging so deep to understand things that I'm covering assembly now. It's painful, but going so far has made everything else make a lot more sense. Data structures are easier to conceptualize and will be easier to work with (for example).

But most people I know don't get this far when they self teach or do a bootcamp. They just know that, given a framework, they can build things but not how anything was really built. Sure it's effective to push out a product, but it makes diving into real programming pretty difficult. That's just my perception though.

Re:Why Learning to Code Is So Damn Hard by Padding on Thursday February 05, 2015 @06:48AM (#9002740)
You need to keep in mind that "magic" is only sufficiently "advanced" (or rather obfuscated) technology, but omeone somewhere said something along the line of "Things that work as if by magic also break as if by magic" .. I've been looking for the reference ever since.
Re:Why Learning to Code Is So Damn Hard by AtmaScout on Wednesday February 04, 2015 @04:40PM (#9000094)
Nicely put. Not enough people dive to the lower levels.
Re:Why Learning to Code Is So Damn Hard by carapace on Wednesday February 04, 2015 @05:06PM (#9000297)
We should start at the lower levels. It is all easy to understand if you build up from first principals: Binary, logic gates, cpus and assembly, then it splits with compilers on one branch and LISP and Smalltalk on two others and a bunch of brush and shrubs and time to retire that metaphor.

Unlike climbing Everest or understanding how the human body works the challenges in learning to program are entirely man-made! (Except for recursion, of course.)

Re:Why Learning to Code Is So Damn Hard by shostack on Wednesday February 04, 2015 @09:19PM (#9001400)
I'm in a similar boat. Started with the training wheels of Codeacademy and such after having a basic working knowledge of HTML/CSS/JS and wanting to build database driven projects and grow my skillset.

Picked up RoR and was quickly overwhelmed with a million unfamiliar concepts as pointed out in the excellent (and very similar) article "This is Why Learning Rails is Hard."[1]. That knowledge tree they show is one I didn't formally stumble upon until later, but throughout my progress I realized "hey, this concept is really part of the much broader topic of X." Then I'd go down a rabbit hole on X.

Before I found that tree though, I had already given up on Mike Hartl's tutorial once, and decided I really needed to have a functional grasp of Ruby and core programming concepts. From there I realized "Ruby/RoR on Windows is not ideal." Then went down the whole devops path and learned about things like Vagrant/Chef/Virtualbox, etc.

I also started picking up books on much deeper computing concepts to understand the lower level mechanics of the magic. Like you I went down to first principles and even a bit of assembly. I couldn't write any to save my life and knowledge is still fuzzy, but I now grasp how the concept of data structures came to be, and more importantly WHY.

I recently tackled Mike Hartl's Rails Tutorial again. His updated version is a great improvement, and this time I actually understand the concepts he goes through. When a new one is introduced, I have enough of the underlying knowledge to at least have a sense of what/why something is, or what I need to Google to learn more.

I wish more classes online provided "deep dive" resources/links on things. Like, if CodeAcademy has an exercise on Ruby covering types, an eager student might really benefit from a deep dive sidetracking into dynamic vs. statically typed languages, and a high-level of what they should know.

My biggest gripe with the tutorials that are out there these days is that they cater to either absolute beginners or competent users. Wish they did a better job of trying to bridge the gap from absolute beginner to intermediate.

Another great example of that is the concept of design patterns. I haven't found many great beginner/intermediate resources on this, but as I've started learning more, I found myself saying "hmm, seems like lots of people do this a similar way--I wonder why." Turns out some approaches to problems are largely solved issues for a majority of use cases, hence: design patterns. This got me down the whole path of software architecture and starting to grok some of the higher-level abstractions and way of thinking in the abstract which was tremendously helpful compared to just being given specific examples with no broader context.

[1] https://www.codefellows.org/blog/this-is-why-learning-rails-...

Re:Why Learning to Code Is So Damn Hard by lelandbatey on Wednesday February 04, 2015 @02:59PM (#8999307)
That is absolutely something that irritates me. I've just inherited a large RoR application, and the amount of "magic" and things by convention is driving me crazy. There should be answers to questions like "why is this the way it is?!"

On a side note, if anyone has some great resources for RoR, I'd love to have them linked. I suspect my inexperience is the source of my problems, and I'm welcome to any assistance any one would like to give.

Re:Why Learning to Code Is So Damn Hard by grey-area on Wednesday February 04, 2015 @03:27PM (#8999492)
The guides on the ror website are pretty good:

http://guides.rubyonrails.org/

Which bits did you find were magic? The bits of convention I can think of you'd have to know about are:

DB naming conventions - these are used so that it can do joins etc easily behind the scenes, they're pretty simple so not a huge problem I find.

Rendering at the end of controller actions - it'll render the template with the same path as your route - again relatively straightforward.

Class loading - lots of things are loaded at startup time, so that you don't have to include files - I have mixed feelings about this, it feels easy and simple at first, but could leave you unsure where code comes from or which methods you can use in which files (e.g. view helpers). Definitely more magic.

One other area which does lead to real problems is that rails sites often use a lot of libraries in the form of gems - this leads to unknown, sometimes poorly maintained or inappropriate code being pulled in at runtime, and makes it far harder to reason about things like say authentication if using a gem. This is my biggest complaint with rails - lack of transparency of code paths when using gems like devise, paperclip etc but it is unfortunately quite common in web frameworks

They actually got rid of quite a few bits of method_missing madness I think recently so that magic is gone at least (all those magic find_by_ methods are deprecated or removed, not sure which as I never used them). I haven't found the conventions get in the way much as it's something you learn once and can apply anywhere, but completely understand why someone might object to some of the magic setup for helpers/rendering.

Re:Why Learning to Code Is So Damn Hard by epochwolf on Wednesday February 04, 2015 @03:52PM (#8999674)
The routing system and associated view helpers can really get confusing.

For example:

    link_to @story.title, @story
You have to know that rails has some automatic routing based on the class of an object. If @story is a Story class, rails basically does this underneath:

    link_to @story.title, send("#{@story.class.name.downcase}_path".to_sym, @story.to_param)
There's implicit conversion of class names going on under the hood in a few places. It's all documented but it's not easy to find the documentation when you don't know what you are looking for.

The thing that really screws up people starting with rails is not understanding the various layers (html, views, controllers, models, http, etc.) and how rails puts those together. If you don't know how to do web programming with basic html and php, rails will eat you alive with it's seemingly magical behaviors.

Re:Why Learning to Code Is So Damn Hard by troels on Wednesday February 04, 2015 @06:11PM (#9000697)
I have to agree - The path helpers are very opaque. It would probably do Rails well to generate a app/helpers/path_helper.rb file with the actual implementations in them.
Re:Why Learning to Code Is So Damn Hard by hwhelchel on Thursday February 05, 2015 @02:09AM (#9002106)
`rake routes` will output the routes and paths. Appending _path or _url to the path will generate appropriate methods.
Re:Why Learning to Code Is So Damn Hard by troels on Thursday February 05, 2015 @02:59AM (#9002201)
Sure. But that still doesn't tell me exactly which arguments they take. Or give me an opportunity to debug the code when it doesn't do as I expect. I realise that it just-works (tm). It's when it doesn't, it gets problematic.
Re:Why Learning to Code Is So Damn Hard by epochwolf on Thursday February 05, 2015 @02:36PM (#9005383)
It's actually pretty easy to tell the parameters they take if you look at the url for the route.

For:

    story GET   /story/:id(.:format)  story#show
You get

    story_path(id)
    story_path(id, format)
    story_url(id)
    story_url(id, format)
In practice it doesn't cause as many problems as you think, even in large applications.
Re:Why Learning to Code Is So Damn Hard by ufmace on Wednesday February 04, 2015 @05:58PM (#9000610)
When learning Rails, I found the DB naming conventions confusing enough that I wrote a blog post summarizing how everything is supposed to be named when I figured it out, since nobody else seems to have:

https://shinynuggetsofcode.wordpress.com/2013/09/30/conventi...

Like a lot of the Rails stuff, it feels like amazing cool magic when things just work. But then when they don't work and do something weird instead of what you expected, it feels like it takes forever to figure out why, what was named wrong, and what it's supposed to be named.

Re:Why Learning to Code Is So Damn Hard by quetzthecoatl on Wednesday February 04, 2015 @03:12PM (#8999395)
Convention over configuration is awesome, if you know the conventions. If you don't, it's all magic. At least with configurations, you can read them and get some pointers.
Re:Why Learning to Code Is So Damn Hard by sonnym on Wednesday February 04, 2015 @07:35PM (#9001048)
Aside from the things others have mentioned, which are all really good, there are some really good books on the subject.

Jose Valim's Crafting Rails Applications[1] is a wonderful resource, since it deliberately sets out to peel back the layers of magic. A lot of the techniques are ones I probably would not use in practice (storing views in the database and rendering them!), but they serve to elucidate the operation of the entire view stack. Really good stuff.

Two other good books are Rails Antipatterns[2] and Objects on Rails[3]. Neither of them has been updated in a long time, but the general principles will still hold. The former is more practical, the latter more theoretical; precscriptive and fanciful food for thought, respectively. Both solid.

1. https://pragprog.com/book/jvrails2/crafting-rails-4-applicat...

2. http://railsantipatterns.com/

3. http://objectsonrails.com/

Re:Why Learning to Code Is So Damn Hard by sciurus on Wednesday February 04, 2015 @09:47PM (#9001475)
If you're not an experienced Rubyist, I'd recommend reading David Black's book The Well-Grounded Rubyist. Unlike many introductory books on programming languages that focus on making you productive in that language quickly, it focuses on building a deep understanding of the language. When I later read the book Metaprogramming Ruby, which uses parts of Rails for many of its examples, I already knew many of the techniques thanks to David.

http://www.manning.com/black2/

Re:Why Learning to Code Is So Damn Hard by troels on Wednesday February 04, 2015 @06:13PM (#9000705)
Ryan Bates' Railscasts are great. Unfortunately he stopped producing new ones, but they are still a great resource:

http://railscasts.com/

Re:Why Learning to Code Is So Damn Hard by dwd on Wednesday February 04, 2015 @09:03PM (#9001347)
Just wondering whether a distinction should be made between learning a framework (RoR, jQuery) and a language (JavaScript, Ruby). Frameworks do magic, languages generally don't.