понедельник, 25 декабря 2017 г.

Prolog ideas

Here is my list of Prolog ideas:

  1. JSON parser
  2. HTTP requests parser
  3. Declarative UI
  4. Validation rules for UI
  5. Business logic in C\C++\Java
The idea of declarative UI I borrowed from the Turbo Prolog 2 User guide and Turbo Prolog Toolbox. It could be useful to have some intermediate UI form representation  in order to be able to translate it into different languages.

As for the last topic it turned out to be easy embed tuProlog in Java. And I had a prototype where I call java methods from Prolog.

The later topics need to be researched further.

Turbo Prolog 2.0. Changes from 1.x.

 Turbo Prolog 2.0 change list

- external database support with protected memory access

- BGI interface support

- improved text editor

- ability to save trace to file

- integers overflow check

- stack check

- error level

- ability to call prolog predicates from Turbo C

- conditional compilation support  (ifdef, ifndef, elsedef, enddef)

- standart trap predicate

- build with Turbo C 1.5

четверг, 21 декабря 2017 г.

W.F. Clocksin, C.S. Mellish. Programming in Prolog

Hi everyone.

I have just read "Programming in Prolog" and wonder why this book is recommended for beginners?

The most useful tip in this book is located at the end of it in appendix C:
This book describes Prolog version which is not related to any particular existing version. The idea was to create the description of "general" Prolog which applies to all systems at once.
 The best way to learn Prolog system you have -- is to read user documentation supplied with it.

Wow! Such a wonderful advise. Why I have to read all the book till the end in order to find out this?
Beginners  will suffer a lot and will complain about Prolog. This shouldn't be like this.

Please treat the book as an approach to explain ideas behind Prolog, not a tutorial.

пятница, 24 ноября 2017 г.

Adventure in Prolog

Ever wanted to learn logic programming?
Wanna know how to program in Prolog?

Wanna know how to integrate Java with Prolog?

A lot of questions arise when we face with a "new" language such as Prolog.
After Java, Prolog looks like a fresh air. It has simple syntax, small number of concepts comparing to the OOP. For me the main advantage that it is a declarative language, not imperative.

If you deal a lot with business rules in your programs you know how ugly imperative implementations look like. This could be the opportunity for Prolog and constantly changing business world.

A lot of information exist about Prolog. What to start with?
IMHO Adventure in Prolog could be a good introduction to Prolog. All concepts are introduced and presented with examples and small tasks.

Examples could be run on almost any Edinburgh compatible Prolog. I use tuProlog. It runs on top of the JVM. Also it has a simple IDE, so you can just move straight to executing your code.

I also started a new repo on https://github.com/chernykhalexander/PrologExperiments for Prolog experiments.

четверг, 5 октября 2017 г.

Blog promotion

Hi everyone!

It is been a while since I wrote here. But in order to give some excuse I would like to present you the blog of a programmer:  http://www.yegor256.com/.

Why do I post it here? Well, I like that this man has his own opinion and he express it. A lot of computer topics are described - not only programming techniques, but management also. What is more - his opinion could be against with what everyone silently agree on. I like it. The more different angles of view we have at the topic the faster we can improve ourselves.

The same thing could be applied to the project. I do not like when everyone is silently agreed on something in a project. If all the team is agreed on it means that either no one doesn't care about the project or there is no atmosphere where each member can express their opinion safely.

Let's improve our projects.

среда, 30 августа 2017 г.

My top Android applications



I was disappointed that Microsoft doesn't produce windows phones any more and Nokia was sold. I have bought recently an Android phone Motorola Moto G4 plus and discovered Android and Play market.

Android seems to be very attractive and positive. I use version 7. I like fingerprint authentication very much. But... Why by default a lot of settings are turned on considering information sharing and statistics gathering? I need to go through  the settings of Android and apps and turn off spy features.

Play contains a lot of apps but a lot of them are a crap. I have also a concern why actually some applications asks for a permissions not related with a purpose of application? That is why it is better not to install the application but instead use web site.

But anyway I decided to create my own top of applications I use.

Productivity and entertainment:

  1. Skype
  2. Whatsapp
  3. Google Chrome
  4. Google Gmail
  5. Google Maps
  6. Google YouTube
  7. Google Photos
  8. Google Calendar
  9. Google Translate
  10. RAR
  11. micro Mathematics
  12. TuneIn Radio 
  13. Aviasales
  14. Gazeta.ru
  15. Moto File Manager
  16. Pocketbook
  17. FM Radio
Technical apps:
  1. Speedtest
  2. CPU-Z
What are your favorite apps on Android?

среда, 23 августа 2017 г.

понедельник, 17 июля 2017 г.

How to generate Sprint Boot project

Each time you need to create the Spring Boot project you start to search for your previous projects and copy paste the needed files. This is tiresome and error prone. Here is the solution: https://start.spring.io/. On this site one can just choose the necessary Spring Boot modules and generate the project with a click of a button. You then can just open up the generated project in IDE and start coding. :-)

суббота, 15 июля 2017 г.

Vsevolod Dyomkin. Lisp Hackers. Interviews with 100x More Productive Programmers.

Fantastic book. Can be found online at http://leanpub.com/lisphackers. It is a collection of interviews with 14 developers who use Lisp in real life.
After reading this book I have a new look into Lisp. I need to look at it more closely. :-)
It's disadvantages:
  1. lack of static typing
  2. difficult to work with in a big projects code bases (around 500 kloc)
Advantages:
  1. DSL support
  2. protocols
  3. ability to run partial programs
  4. Having fun
  5. extend your mind 
  6. can be used in projects where customer doesn't care about the tools but getting job done.
Productivity tips:
  1. Start from minimal running code and move forward in a long series of very small steps.
  2. Learn new languages  to meet new people, to think in a new way.

четверг, 1 июня 2017 г.

Java 8 WatchService. Windows Implementation note.

WatchService in java is service that allows to monitor the directory for changes. Here is the important notice from javadoc:
"For example a file manager may use a watch service to monitor a directory for changes so that it can update its display of the list of files when files are created or deleted. "

But what if you need to know  which file was actually renamed. What is the old name of a file and what is the new name?

On windows there is a native support from the OS to monitor such changes. Well, take a look how this possibilities were mapped in Java. For jdk8 see the link http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/windows/classes/sun/nio/fs/WindowsWatchService.java#l464. For lazy ones here is the method:
<code>
// Translate file change action into watch event
        private WatchEvent.Kind<?> translateActionToEvent(int action)
        {
            switch (action) {
                case FILE_ACTION_MODIFIED :
                    return StandardWatchEventKinds.ENTRY_MODIFY;

                case FILE_ACTION_ADDED :
                case FILE_ACTION_RENAMED_NEW_NAME :
                    return StandardWatchEventKinds.ENTRY_CREATE;

                case FILE_ACTION_REMOVED :
                case FILE_ACTION_RENAMED_OLD_NAME :
                    return StandardWatchEventKinds.ENTRY_DELETE;

                default :
                    return null;  // action not recognized
            }
        }
</code>

You see, renamed and new file events mapped to ENTRY_CREATE event. The only question comes to my mind is -- why? Why it was done like this?
I think they were trying to make a universal solution, but.. why they didn't make it extensible?