Georgian web for those, who listen

Georgian web exists for more than 10 years and we build it daily, whereis it builds important details of our lives. Unfortunately, there are still thousands of people, who cannot access its benefits.

If you would like to learn:
– How blind people use computers, internet, social networks, email..
– What technologies and problems exist in Georgia regarding this
– With what minimal resource can we make Georgian web accessible

Join us on 14 May, 2017 at 14:30 and share your opinion.
Together with IDIT and GITA, I’m organizing a small conference.

Our plan:
Kakha Tskhovrebashvili, Teacher at N202 School for blind and visually impaired, will introduce us to screen readers.

Giorgi Gvasalia, Head of IDIT, will present us a site with audio reading, accessibility standards and he will review Georgian web.

Beka Gozalishvili, Softare developer at Public Service Development Agency, will tell us about how to syntethise speech: What is a speech synthesizer and how can we create it. Beka is blind, but he actively uses internet and writes software on various programming languages. He is a main contributor for translating the screen reader to georgia and creating a Georgian speech synthesizer.

Aleksandre Khutsishvili, Senior software developer at Circle, will speak about one of audio interfaces in an OS and what are available for blind developers.

And me, Elene Latsoshvili will offer you a small experimental project – Georgian minimalistic blogging platform, where users can create their own blogs, write articles, use comments and messaging. Also, I will describe opportunities for making a web system accessible, how screen readers work behind the scenes, what is the purpose of semantic web and what problems we might face on the way.

If your web site is created in accordance to general web standards, sometimes it’s very easy, maybe even in one day, to make it accessible for large number of blind people.

For more information about the conference and registration, please, visit a fb page of our event.

Single codebase – multiple platforms: NativeScript and React Native

Lately we needed to rewrite a project with such framework, which could help us build common codebase for several platforms – web, Android and iOS. Currently, we write nearly the same logic for all three making it more expensive and time-consuming.

So, I had these three days for a research. As a result, we will still continue writing native, however I’d like to share this small research on my blog. If you have used any of them (NativeScript, React Native) in a public project, I’d gladly look at it and listen to recommendations.

Let’s dive in: hybrids were ignored from the beginning. Hybrid is a mobile app, which can written using html/css/javascript and is loaded in our app by web view component. Unlike an ordinary website, it can access API of the mobile OS, but it’s rendered just like a site. Native application is far more smooth and performant, user experience is different, so hybrids are generally used for small apps or prototypes.

There are lots of frameworks to create a hybrid: Cordova (ყოფილი PhoneGap), Ionic, Sencha Touch, Mobile Angular UI, etc.

I could find relatively small number of ones, which does not render a site, but map javascript code with native elements and create, in fact, native applications. For instance,

 

NativeScript

Telerik, which you may know from their hybrid library, created NativeScript – a framework, with which one can build a native mobile app using Angular, Typescript and JavaScript.

A virtual machine is started on a phone and using reflection, C++ and OS API it creates a bridge to connect to native components. More details can be found on this page: How NativeScript Works
However, despite of this bridge, you won’t notice a performance lag in comparison with a real native app.

Main pros of the framework:
– Native UI
– Extensible (Easily reuse existing plugins from npm, CocoaPods (iOS) and Gradle (Android) directly in NativeScript projects)
– Cross-Platform: Write and deploy native mobile apps for iOS, Android and (soon) Windows from a single code base
– Open source: Apache 2 license.

The learning curve was quite low, too. Recently, they took Angular framework and used the same naming and api, so if you have experience with the latter, it should be easy for you.

Unlike a website, in NativeScript and React Native we don’t create views with html, but with xml, which resembles views in Android.

<StackLayout>
	<Button ios:text="foo" android:text="bar"></Button>
</StackLayout>

We can specify different logic for different platforms. Button code above is one of examples. In case of a JS code, we can write if (page.ios) { … }

Part of the design – colors, font size, flex layout – is done with css. Clearly, not all css rules are available, but there are ones which could be mapped with native components.

The reason for my attraction was the possibility of sharing codebase with a web-app. However this turned out not so simple. Large part was still remaining separate. Some parts of javascript code can be shared if you export it as a npm module. (There also is another way, where you unite everything in a single project like this, but in my opinion it added too many if statements and complexity, so I didn’t really like it on the first look).

As far as mobile platforms are concerned, almost all code can be shared here.

To do some experiments, I selected out one relatively complex page and started to build it with this framework. Some things were pretty easy to do, but when I needed a bit more demanding UI, I got stuck. One example was a bottom tab bar of Android, which is currently impossible to use with this NativeScript. Actually, I was a bit skeptical from the beginning, when I saw their showcase. The apps seemed too simple. But this is still a new framework. Probably it will be much better in couple of years.

 

React Native

This one had a far more impressive gallery. It has been used in thousands of apps. React Native framework comes from Facebook and looks like React. When I tried it out, I definitely agreed to some articles, stating that unlike NativeScript, here you have far more control over the UI, so you are free in your designs, but more control requires more code.

React Native also tries to have a shared codebase, but it still focuses on differences among various platforms. As they say, in case of large apps, you won’t be able to share 100% of code between iOS and Android. Sure, you can use third-party plugins and make them lookalike, but if you ‘respect’ the features of different platforms, you will have to write some code separately.
A simple example would be a date picker, as its visual and ux is radically different on iOS and Android.

React Native tries not to strip off these specific traits of the platforms.
Some people nag about the licence as its published with BSD, however I could not see much constraints.

 

Conclusion

If I were starting a new project with a complex UI and not rewriting one, probably I would go with React Native. However, it’s not like you will easily start coding the next day. Even for only those few pages I still had to go through lots of trial and error, because of some version compatibility and also the framework was new to me. Android skills go hand-in-hand with both of these frameworks as the process of building UI looks similar.

There is one more – Xamarin, and you need C# here. It was a Windows world, so at this time – not for us. By the way, Xamarin acts a bit differently. E.g. iOS project is directly compiled into assembly. For Android it uses a Mono .Net framework. More details can be found here: Understanding the Xamarin mobile platform

I could not find other similar frameworks. Do you know any?

JavaScript Tricks

Photo from jstips

jstips-header-blog

Some time ago, I needed to dive in a JavaScript library which was minified and in the process I found out some ways which are used by the minifiers to reduce a code size. Clearly, the most optimal way is to set 1-2 characters as a variable name. Apart from it, there are some more, which no programmer would do on a clear mind, but just for fun 😀 I offer few of them to guess:
(And then also some nice ones, too)

1. How would you write false with 2 symbols? and true?

!1 false, !0 true

2. How would you reduce this code?

if (a) b();

What about these?

if (!a) b();

if (a) {
b = 1;
c = 2;
}

In JavaScript && and || are short-circuit operators, like in other languages. So, when the result of expression is clear, the rest of the expression, including function invocations, is not evaluated. Instead of if, we can write a&&b().
In the second case, we could have a||b().
The third case is nothing much. Sometimes minifiers just combine everything in one expression and then no blocks are necessary.
if (a) b=1, c=2

3. How would you check something like this with shortest code: If variable is undefined, 0, false, “”, null or NaN – return false, else return true.
(This was not in a minifier, I just often use it).

By converting to bool: result = !!a

4. How would you reduce this part? Let’s say we are validating some arg and if it’s not defined, we set a default value. This one is not from the minifier either.

var options = (arg) ? arg : [];

In case of JavaScript && and || act a bit differently – they don’t return boolean, but a first operand, which determines the expression result. E.g. 1 && 0 && false will return 0.

Consequently, we can write the given expression nicely like this:

var options = arg || [];

4. Minifier does not do this, but, let’s say we need to round number (towards zero). What is the shortest and fastest way to do this?

Let me write the logic. We have a function Math.floor(), but this rounds the number towards negative infinity. So 12.6 will be rounded to 12, but -12.6 will be rounded to -13. This is not the case with our question (Generally, I need rounding towards zero more often than the other).
So we get:

foo > 0 ? Math.floor(foo) : Math.ceil(foo)

If we are not sure that foo is a number and don’t want to recieve NaN, than we’ll need to add another check:

typeof foo === 'number' && !isNaN(foo) && foo !== Infinity
? foo > 0 ? Math.floor(foo) : Math.ceil(foo) : 0;

So the question is, how would you write this with only 2 symbols 🙂 (apart from foo)

We will need some binary operations here. We have two options – double binary division or binary ‘or’ with zero.
~~foo
foo|0

If you’d like to see more details of binary operations, this article has some of them.

5. How would you reduce symbols in numbers with lots of zeros – 1000000, 0.0000023?

1e6, 23e-7 – Counting zeroes is bad 😀

My Summer Booklist 2015

me
I had a vacation for these two weeks to rest and breath in 🙂 When I leave internet, more time appears to read and that is my favourite activity after swimming. I write small book reviews here and there, so I decided to group the books from this vacation in this post, maybe someone finds any of them interesting…


Surely You’re Joking, Mr. Feynman!

A famous physicist and nobel prize winner, Richard Feynman, tells us very funny and adventurous stories – childhood memories, working on the atomic bomb, cracking safes, evil jokes, papers in biology, participating in musicians’ festival at the Brazilian carnaval, selling own paintings, giving lectures, researches and ‘aha!’ moments. How did he found time for all this I have no idea :)) I even became interested in physics.

Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future

A dream is unreal and unreachable, isn’t it? Lately, I had one to build an electromobile factory in Georgia. This book ruined it :)) as I clearly saw how much non-human work and finances are required.

The book itself is a great source of motivation. It contains lots of stories about creation and development of SpaceX, Tesla and SolarCity – failures, lucky events and overcoming difficulties. Building and launching the SpaceX rocket with huge technological and managerial leaps is especially impressive. I think not only programmers, electronic engineers and managers will enjoy this adventurous book.

Zero to One: Notes on Startups, or How to Build the Future

The author of this book is Peter Thiel, co-founder of Paypal. This and good reviews were the reasons to select it, but I could not even reach the middle. It was a bit disappointing. Maybe it had nothing new for me about startups. Also, I could not agree on several points (e.g. when he says that competition on market only ruins everything). Rework by Jason Fried still remains my favourite book about this topic.

fahrenheit 451 Fahrenheit 451

Bredbury and also this book in particular have been on my list for a while. I saw it now, but to tell the truth, it was a bit disappointing, too. While reading I always had a feeling of lacking information about that world. I could not see what replaced the books and what problems those people were facing. They would not have been able to move totally to verbal communication. 1984 by Orwel was far more realistic for me.
By the way, as time passes, I’m abandoning fiction more and more. It’s sad. I don’t know why, but I often get angry about the characters :)) or maybe the real stories are so interesting, that I cannot stop reading non-fiction.

why-zebras-dont-get-ulcers-big Why Zebras Don’t Get Ulcers

I love medical books, where complex topics are explained in simple language for us, mere mortals. This book is my most favourite. Mr. Sapolsky writes not only clearly, but also with humour and describes how our brains and body work.

creativity incCreativity, Inc.: Overcoming the Unseen Forces That Stand in the Way of True Inspiration

Pixar and Disney are two unique and superior companies for me, where superior people create superior films.
Ed Catmull is a co-founder of Pixar and currently is a president of Pixar and Disney. He, as a software developer, played a great role in the development of computer graphics and moved this field into the movie industry. (E.g. he is often attributed for inventing the Z-buffer concept, which now is in every computer and mobile device.) Catmull writes about under-the-hood stuff while working on animated movies – difficulties they faced, how they started and what does the culture look like in a company, whose every movie is better that its previous one. I think a half of this book is unnecessary, but there are good pearls here and there.

ios8 fundamentals iOS 8 Programming Fundamentals with Swift

I mentioned in my previous posts, that lately I had been working on iOS and their new programming language. Apple has a good book published – The Swift Programming Language which describes the language in depth, but after reading it I was lacking the best practices part and I was still struggling for writing good code. Generally, I don’t like wasting time like this and that is why I start learning a new language from books. Let me introduce Matt Neuburg. He fills his books with real project examples and personal experience, so he made lots of things easier for me. If you are starting this language, I would recommend his books.

programming_ios_8_deep_dive Programming iOS 8: Dive Deep into Views, View Controllers, and Frameworks

This is a Matt Neuburg book, too, (with relatively advanced topics) and he describes the basics in depth. This one also contains real project examples and lots and lots of solutions. I haven’t yet completed all thousand pages, but I already regret not reading it earlier.

Programming a CNC machine with JavaScript

Two days ago I received my Masters degree at the Tbilisi State University. My research of the last semester was about CNC machines and their programming language. The topic is not quite near to my specialty, but it was still interesting. Especially, the experiments with a new programming language of this machine, which is described in the paper.

As far as I know, there are several companies in Georgia, which use these machines, but I did not receive feedback from them.

Have you carried out experiments or built the machine at home? My paper is published on this link (but it is in Georgian) 🙂

lcamtuf_robot1

Making a mold for robot parts. The photo is taken from lcamtuf.

othermill

Othermill by otherfab