syntactic sugar

ooooh time for a rant. lest¬†i write “how to curb-stomp your macbook Part 2.” I’m also writing this before I’ve figured out the solution so should be emotional ūüôā

So. syntactic sugar…fucking a.. is basically syntax within a language that makes it easier to read, so instead of having to type out

array.[](1)

you can just type

array[1]

which can be nice, but there are more “magical” examples that make it pretty FUCKING_IMPOSSIBLE for you to figure out what’s going on from existing code because the code randomly doesn’t follow the same rules in some places. And probably what’s worse, they flat out just omit code¬†ALL_FUCKING_OVER the place.

When passing a parameter into a function, you enclose it in parentheses. Except FUCK PARENTHESES, let’s have it work without em! Sometimes!

This is at least somewhat manageable in Ruby, where you’re dealing with functions and objects etc, ¬†but when you’re building Rails apps, the problem is an order of magnitude worse, cuz not only is¬†more shit is hidden but¬†it sets up half the shit for you when you run rails commands and you have no idea why some stuff works because it references code you DIDNT EVEN FUCKING HAVE TO WRITE IN THE FIRST PLACE SO YOU DONT KNOW IT EXISTS!

mother….fucker.

and while I’m ranting, would it be possible to NOT have the same FUCKING word for completely different things in a project? So I’m looking through this sample code for an app that stores a db of movies.

In it is a model file, movie.rb, with a class Movie, a controller file, movies_controller.rb, with a class MoviesController that has an instance variable @movies. Also in the functions on the view file, |movie| is used to iterate on and used as a parameter for the search functions.

So in the routes file when it says:

root ‘movies#index’
resources :movies

what do you think it’s referencing there? controllers? models? classes? variables? pizza toppings?

YEAH I DONT KNOW EITHER!

……. 5 hours later…..

okay think I got a handle on this. sidenote- another thing I hate about rails is that most of my programmer friends hate it and not only can’t help but get elitist and refuse to even try. so i have to ask coworkers, which I really hate.

okay lesson 1- root/resources versus GET

The single most helpful first thing I learned is that this:

¬†get ‘/’ => ‘main#index’

is the same as this:

root ‘greeter#hello’

I don’t think anyone has ever written a rails routing guide IMMEDIATELY after figuring this stuff out from scratch and it becomes so second nature that they forget what stuff can trip you up in the beginning. So then they go, oh root is your main landing page, so just use root. Well fuck you, it’s super helpful to think in terms of the URL path which is literally just ‘/’

Now that we have that, the rest of the explanation follows much more naturally.

So all the routes file does is map 3 things together:

HTTP Methods (GET, POST, PUT, DELETE) :: URL pathways (/, /movies, /movies/new etc.) :: the right controller and method ON that controller.

so¬†get ‘/’ => ‘main#index’ in english means, when the page is requested send them to ‘myapp.com/’¬† then go to the main controller and run the index function.

the long way of writing a routes file for a single page looks something like this (but with all the HTTP methods and 7 standard controller methods)

GET¬†‘/’ => ‘main#index’

GET¬†‘/movies’ => ‘movies#index’

GET¬†‘/movies/:id’ => ‘movies#show’

GET¬†‘/movies/new’ => ‘movies#new’

POST¬†‘/movies/:id’ => ‘movies#create’

and then you’d have index, show, new and create as methods in the movies controller.

BUT rails decided you’re lazy and don’t want to type that so:

resources :movies 

will do the exact same thing. The end.

 

Lesson 2: just kidding you don’t actually need a method in your controller, cuz you’re lazy and you hate parentheses and typing and don’t want to do any fucking leg work to get your app working.¬†

so this:¬†¬†root ‘greeter#hello’¬†¬†means that the ‘/’¬†¬†is requested, points to the¬†greeter controller and runs the hello function.

BUT what there WAS NO hello function on my controller. so how did it know? and why if i changed it to greeter#index then added an index function, did it break? feels like that should be MORE right? right? rightrightright?

well, sneaky rails, turns out that if there’s no function in the controller, it sort of implicitly goes to the view files, finds the ¬†folder with the same name as the controller and magically knows to renders the “hello.html.erb” file.

so here’s how I broke it down:

This is what I have:

Screen Shot 2015-04-24 at 11.45.20 AM

But this also works, meaning the method can be anything as long as it’s the same as the filename in the views folder.

 

 

Screen Shot 2015-04-24 at 11.50.59 AM

OR if it’s not the same name, you have to¬†define the method that renders the file.

Screen Shot 2015-04-24 at 11.51.19 AM

 

 

I cannot tell you how much better I feel after finishing this entry. Sometimes it feels like I’m going backwards. I’m simultaneously building complicated shit that would assume I know how this all works, then in trying to replicate someone else’s code and it doesn’t work, and i can’t figure out why, I end up spending 5 hours peeling back all the layers of all this “sugar.”

Fuck sugar. And fuck rails as a first framework. One really should¬†do things the hard way before having the luxury¬†of shortcuts. Tho I guess you could call what I’m doing to learn this almost worse than the hard way?

oh well, I will defeat you rails, if I end up accidentally learning an unnecessary amount of computer science along the way…

 

 

Advertisements

The F-Word

as i get closer to becoming a programmer, my entries are becoming less tech-heavy and more topical, which I think is a good thing. if a terrifying life change doesn’t bring up some internal philosophical debates then you’re doing it wrong. one thing that’s becoming clear, is that I have to get my head straight on how i feel about “women” in “technology.” a topic I’ve long since avoided. but here goes…

earlier this year, a friend of mine suggested i consider helping with the efforts to recruit more female engineers as part of my branding efforts. and I had two very clear, very strong reactions:

Immediately, I thought, “hell if it lands me a programming role, i’d {insert radical feminist action} , i don’t care.”

Followed immediately by, “ew, what if i get a role then suddenly people think **I’m** a diversity hire?? i don’t want my name attached to that. I want my gender to be as invisible as possible when it comes to my career. so no, fuck that… and a half.”

But I was so intrigued by my violent polar reactions, I had to know more. So, I had long talks with friends, I watched Ted talks, attended conferences, read articles and blog posts. all the while dutifully not blogging publicly on the subject until i felt I had something, if not unique, at least organized to say.

In summarizing my thoughts I want to preface with a really important point that I don’t think is made enough. There’s a huge selection bias in what ideas I connected to in my research, so these are only **my** opinions¬†on the subject.

h’okay, so here’s my list of epiphanies:

1. radical feminism != feminism

The first thing I wanted to explore was why the word “feminism” made me cringe and want to change the subject. Having adopted a svelte avoidance of gender topics, my definition of feminism was limited to a pretty perennially loaded concept. Defined most strongly by the loudest that make the best media.

Once I started digging in, I realized I’d missed and a decade of my generation on a quest to define things for themselves.¬† This is an important starting place because if you’re going to have an open-minded conversation about any subject, you need to first recognize your own biases. then you need to ask yourself why you had them in the first place. which brings me to…

2. my background defined my relationship with gender more than I realized. a lot more.

I¬†am an only child, with absurdly supportive parents. my father has a PHD in engineering and my mother used to be a jet engine mechanic. growing up, there was nothing BUT drive to get me into a STEM field. i went into college to be a writer because i WANTED to. there was no one telling me i couldn’t/shouldn’t do it. so i didn’t easily relate with the notion that “society tells girls they can’t be in STEM” even tho it’s definitely there in more subtle ways.

I also grew up as a white middle class military brat, mostly in the states and parts of Europe. After reading stories about girls¬†in other countries being subject to actual formalized rules and laws that forbade them from leadership roles, I realized I had nothing remotely similar to compare to. If I had, I would have had much more to say on the subject before today. But I didn’t grow up in a time or place where oppression was explicit and black and white.

Lastly, I grew up without any siblings, which I think defines gender roles earlier and more personally for people.¬† I talked a lot to women who¬†were told they shouldn’t live alone or stay out as late, when it was acceptable for their male siblings to do so.

3. There *are* ¬†circumstances¬†when it’s okay to entertain¬†gender-bias as a cause for inequality.

Okay, this one was always my biggest hang-up. One mantra, that’s a big part of who I am, is that blaming failure on something you can’t control or change is weak. “I didn’t get the job because I’m a women,” or “I get paid less because I’m a woman.” Hearing things like this always made me want to shake people and scream “take responsibility for your own shit! if it’s a boy’s club, then go make friends with the fucking boys!”

But- I had not considered¬†a small, but important, benefit to finding balance here, and it’s all about maintaining your confidence. If you feel like everything is in your control, failure will drive you insane (I can personally attest here).¬† If you think gender-bias is within your control, it can cause weird sense of self issues and paralyze you from kicking up shit that needs to be changed. Granted, I still think people abuse this… a lot, but I’m slowing coming around to the idea that maybe I’ve been subjected to some unfairness that was just out of my control and I shouldn’t always blame myself or try to “learn how to better myself” from it.

4. Anyone is entitled opinion on this subject

This seems obvious but it’s the main reason why I never explored things until now, and I have to imagine other women feel the same. Most literature you read on “women in tech” are written by¬† successful women who have amazing stories and nestle their opinions behind their accomplishments. Who wouldn’t want to know Sheryl Sandberg’s stance on gender equality? And every blog post I read on the subject seems to preface with a “here’s why I’m qualified to talk about this subject.” And, I never thought I was. Yes, I’m a woman and yes, I’m in tech, but I also don’t have this shit figured out.

There’s also a zeitgeist of “kill the messenger,” especially on the internet. Can I even say “woman” or do I need to say “person who presents as a female?”¬† Does my experience represent anything useful? Where do I actually stand on the issues?

5. role models are hard to find and the mainstream pretty much sucks.

Another idea I had to get my head around was that not only was I going to disagree with a lot of popular theory, but it was going to be downright hard for someone like me to find a person, in whom I could believe and model myself after.

Mainstream feminism makes it feel like money and sex are the only things that matter for women and it’s also extremely bias toward white, western women. “Lean In” basically criticizes everything women naturally do in the workplace and tells us to act more like men. And even tho I worship artists like Madonna and Margaret Cho, the sex-positive movement doesn’t help me at work.

6. i can benefit from sexism, and so can you!

there’s a fascinating pressure for women to divorce themselves from femininity, that i subscribed to very early on. to not be one of “those” girls. so many who claim¬†“i get along with guys better” and “all my best friends are guys.” i grew up hearing men¬†complain about all the things, both annoying and wonderful that make us women. being “one of the guys” made me fearless to compete in areas that can be intimidating. at every job, i’ve always been friends with more engineers than finance people. and i’ve always secretly enjoyed how just doing “guy things” like riding motorcycles, playing the drums or drinking scotch makes you a “bad ass.” because i like those things. and it’s worked out well for me. and this idea doesn’t just come from men. female leaders who advise anti-feminine behavior as a success tactic at work add to the pressure.

one of the things that makes sexism so complicated is that it’s so easy to point to the tangible benefits of being a woman. i got a fairly decent scholarship in college that was only given out to women. and I¬†hesitate to admit this, but i think since¬†there’s a stereotype around women being less technical, sometimes¬†it helps ¬†because my accomplishments are¬†weighted differently. i guess i’m arguing¬†that a low bar is easier to cross¬†and¬†no one seems to care where the bar is, it just matters whether you get over it or not.

but probably the most i benefited, and with almost no¬†guilt, was being the lead singer of my band. the music industry is as male-dominated as most STEM fields. and being a female-fronted punk band gives you a competitive edge when you’re marketing yourself. we got more gigs just because i was a girl. and how am i to feel about sexism¬†when the status quo seems to be giving me a huge advantage?

7. sexism is fucking eeeeeverywhere once you start paying attention

the final epiphany I had, a pretty sobering one, was just how rampant sexism is when you start paying attention. Gender roles are defined all over the damn place. and i’m not just talking about exploiting sexuality for marketing purposes.

just like… sigh, this:

Barbie ht_barbie_engineer_2_FLOAT_kb_141119_4x3_992

and this:

image

and this:

lrgscaleKANTY302_plastic_cleaning_set_2

and this

Screen Shot 2015-04-21 at 4.14.24 PM

okay now I’m just having fun googling sexist products ūüôā THERE’S SO MANY!

okay, that was a long entry. but now that it’s out of the way, i can move on and continue ranting about stupid, frustrating nerd things that make me want to curb stomp my macbook(again), like rake routes, keyboard elitism, syntactic sugar and why I’m mad at Yelp.

so until the next hot button issue,

night nerds