Sunday, August 21, 2016

Trying out ReactJS

This week I tried ReactJS. I was super exited to learn React with it's one way data-bindings. As I learned from couple of videos, React can be used with or without Babel ( a compiler) .

 I chose to use Babel as it gives a cleaner syntax.I found that much to my dismay, setting up Babel with Webpack was hard. I copied configs from over the net and finally succeed in setting up Babel + Webpack + React.

Finally I tried a sample project(link) to learn react. I ended up with hitting on obstacles after obstacles. One which I found very annoying was that when React failed it gave no errors, no display. Maybe chrome does provide errors but Firefox certainly didn't. Another snag was that Firefox react-Dev tools add-on has a memory leak which I found out after Firefox consumed 2GB ram and system got stuck.

I foolishly stumbled upon the dark because of ajax. Ajax requests updated the state objects after rendering but because I used mutable objects, React didn't recognize the change and re-render. I had to use jquery because I didn't want to try too many things at once .

Anyway I finished my project at last and I am satisfied with it. The code is a jumbled mess certainly but it works well enough. I haven't learned flux or redux or router or other things related to react, so I have a lot to learn. I think the React syntax is easy to learn and because it's javascript easy to implement. In my opinion I like React better than Angular from the looks of it.

Yesterday I tried for a SASS+Babel + React + Dev-server webpack config. And it was worse than just trying for react. As webpack only recognize javascript entry files I have to include a require statement in js to import css or sass. Though I got it to work after a couple of hours.

Friday, August 19, 2016

Text Editors vs familiarity

As I was trying Vim, I was frustrated to figure out that Vim has lousy keyboard bindings.

    1. Vim doesn't support some keybindings such as Ctrl + /

    2. Vim doesn't offer Tab completion for autocompletion + emmet like Sublime or Atom.

Which I think is because the plugins conflict with each other. Therefor I was interested to find if Vim competitor Emacs offered it. I spend the last day and a half trying to wrestle Emacs but alas Emacs also fails.

Though it was futile in the end I learned something profound about text-editors.
Even though I disliked the theme I used for emacs at first, when I went back to Vim, Vim suddenly looked strange.

Vim                       ---------------                Emacs

 Many have debated about merits of text editors, Vim and emacs being the most heated argument. They claim that some editors are more efficient and powerful.
While I agree that some may be more powerful ( more than Notepad :-) ), I don't think they have a huge impact on efficiency.
The familiarity is the key here. The more familiar you are with a particular editor, more efficient you become.
 And in the context of web development I think Atom,Sublime Text, Brackets have the same practical capabilities as Vim or Emacs. In other situations they may have a slight or huge advantages but not in Web development.

PS: I was a utter failure at figuring out emacs. It was more harder than Vim configuration. I was surprised as I thought emacs would be easier.
And yes emacs have better keybinding support than Vim.


Monday, August 15, 2016

Vim - A old school text editor

I have been using Atom as my editor for the last 6 months. It was easy and it has lots of plugins for lots of functionality. And it is open source. But I have found it takes a lot of memory , so the computer becomes sluggish when opening a couple of browsers.

So I tried Vim as a replacement for Atom. I had heard it was lightweight and fast. And it is. But it don't have much functionality out of the box. Installing themes and correcting colors was frustratingly difficult. The shortcuts are different from Atom. And you need to spend literally days to optimize Vim to your standards.

Still, yesterday I wanted to create a new snippet, but found that it didn't work with emmet for whatever reason. So I installed snipmate.vim and tried to create a new snippet. "Tried" being the keyword here. After spending an hour trying this I finally realized you have to use hard tabs instead of spaces in the snippets file. I know , I should have read the manual first. But it was very easy in Atom and keybindings were more streamlined, not a jumbled mess as with my Vim setup.

So here is my Vim setup.
It looks cool and now I am addicted to the new interface. I use a bunch of different plugins : -
                Vim-plug , Emmet, lightline, Nerdtree , ctrlp , CSExactColors , And bunch of themes.

Anyway Vim works alright overall,  and I will try it until I would be fed up with it. :)