Getting started with Hive app development

in STEMGeeks3 years ago (edited)

image.png

I've been asked quite a few times lately on how to get started developing on Hive. So here yo go, here's a brief intro to get your started.

First off, this guide is for people who want to build an application or game on Hive and not intentended to those who want to do blockchain level development.

The majority of apps and games built on Hive use Javascript or Python. I will briefly describe both of them and how to get started.


Javascript

Javascript is a very popular language and primarily the only language you will use in a browser. Even if you choose to go the Python route, you will likely need to know some Javascript if you want to build a user interface (UI) to your application or game.

There are primarily two directions you can go in with Javascript, NodeJS for backend development and scripting and Javascript for front end development, usually using a framework.

If you want to build an application that works in a browser you will likely want to use React or VueJS web frameworks.

Javascript is more difficult and verbose than Python but specializes in asyncronous code, code that runs while your main code continues running. Asyncronous coding is a lot more complicated to code and understand but potentially can create faster code.

Javascript traditionally executes a lot faster than Python but many Python libraries have been built in C to make up for this.

If you want to learn Javascript, I recommend checking out this 2 hour crash course. If you want a little slower pace, check out this 7 hour course.

You will most likely need NodeJS to start using Javascript even if you plan on only doing front end development. Instead of downloading NodeJS directly, I recommend you use node version manager to install the latest version of node nvm. This will allow you to easily switch versions and upgrade your install of NodeJS.

If you want to do front end development, I would recommend VueJS, but many older apps on Hive are done in React, most of the newer ones have moved to VueJS.

To work with the Hive blockchain in Javascript you will need to use HiveJS, there are other libraries for Hive in Javascript but HiveJS is the most supported and maintained.


Python

Python is considered the most popular language in the world and is considerably easier to work with than Javascript. If you are going to do front end development your choices are limited with Python, although there is Django, you will still need Javascript for some parts of your site.

Python is easy to learn and is what I would recommend to most people (especially children) to learn first. Python while easy to use is extremely powerful and has an amazing collection of packages that support it. In fact, nothing touches Python for working with data science and machine learning. While Python is considered "slow", speed rarely becomes a problem in most applications, and packages that require better performance likely have been written in C to greatly improve the performance to be even faster than NodeJS.

If you want to do anything with Machine Learning or Deep Learning, Python without a doubt is your first choice.

If you want to build a web application or game with Python, I recommend checking out Django. You will still need to learn Javascript for some interaction and layout development. Django is a very powerful framework for development applications but you still can use a web framework like VueJS while using Django.

If you want to build an API for the backend of your application, have a look at Flask which is similar to Django but much simplier and ideal for building API interfaces.

To learn Python, I recommend this 1 hour crash course or a slower paced course like this 5 hour Learn Python Course.

To work with Hive in Python, you will want to use Beem, it is the most supported and maintained Python Hive library. Beem while doesn't get maintained as much these days, is the best library on the Hive blockchain as it includes many helper functions that do a lot of the leg work.


It is not uncommon to use Javascript for your front end development and use Python for your backend development or even just for some scripts that work with your existing backend. There is no harm learning either of these languages and neither is the wrong choice.

With all new developers, I recommend learning the language you want to use and then do a few tutorials. I don't recommend spending too much time doing tutorials as you will end up in tutorial hell where you just do tutorials but have no idea how to build something. As soon as you possible can, think of a project to build and build it. If you need to, break it down into smaller pieces. All good developers will break larger problems down to smaller components.

If you have any questions on your journey, check out HiveDevs Discord where you will find other developers at various skill levels that may be able to help you. Also check out Stackoverflow if you have a question you cannot solve.

Always try to solve your own problems, that is the only way you will learn but if you find you are wasting a lot of your time, seek help. Just remember to phrase your question in a way that most directly relates to your problem and always try to minimize the code you provide as an example to the smallest amount of code to represent your problem. No one wants to dig through your application to find the problem you are running into.

I highly recommend using VS Code as your editor. It is the only thing Microsoft has done right in the last 10 years and is an amazing free editor which will save you hundreds if not thousands of hours of work in your development career.

Posted with STEMGeeks

Sort:  

What about the Ruby library on hive? Is it still maintained?

Yep, those libraries are maintained and I use them every day.

https://developers.hive.io/tutorials/#tutorials-ruby

I believe @inertia does maintain it as he uses it for all his tools, but it isn't as popular as Python and JS.

If one chooses Javascript, I highly recommend to use Typescript.

I tried to give it a go, and it still feels a bit weird as compared to a native statically typed language(plus I can mix JS in between whenever I want?), any advice advice on how to make the typescript experience a bit better?

You will spend more time at the beginning but the learning curve is worth it.
Typescript + Eslint makes you a better developer I reckon. Forces you to code cleanly following standards so it's easier for someone else to join in later on or even for you to revisit old codes. As for Typescripts it will help reducing silly bugs such as passing the wrong parameter to a function or sending incomplete object to a method.

Everything becomes stricter, which can be annoying but in the long run you'll discover their usefulness.

Typescript is Javascript + types, so the code itself is Javascript and you have an additional syntax for declaring types. It's also recommended to add ESLint into the mix.

For example this JS code:

Would be come this in Typescript:
~~~ embed:328a0e93005dabf0d015819bc9c13840 gist metadata:cXVvY2h1eS8zMjhhMGU5MzAwNWRhYmYwZDAxNTgxOWJjOWMxMzg0MA== ~~~


Or this in JS:

Becomes this in TS:
~~~ embed:5b95ba862fb6dc5d534b0c8a1c0658af gist metadata:cXVvY2h1eS81Yjk1YmE4NjJmYjZkYzVkNTM0YjBjOGExYzA2NThhZg== ~~~

It may be worth knowing HAF ( Hive Application Framework ), it will simplify build the applications with blockchain microforks support: https://gitlab.syncad.com/hive/psql_tools/-/blob/master/src/hive_fork_manager/Readme.md

I've very recently finally managed to contribute a little bit of code to hive, or at least one of the tools used by witnesses anyways. :D

I really need to refresh my skills with Javascript, But I'm also thinking I should get in on python as they both have their uses.


Communities I run: Gridcoin (GRC)(PeakD) / Gridcoin (GRC) (hive.blog)| Fish Keepers (PeakD) / Fish Keepers (hive.blog)
Check out my gaming stream on VIMM.TV | Vote for me as a Hive witness! and Hive-engine witness!

thanks for sharing. I'm planning to develop more games on Hive blockchain

Nice. I'm improving my noejs Skills and who know a hive bs new game pops out

Good point on keeping node and npm updated. When I started messing with java script apps I mistakenly installed an old version of node. And it caused all kinds of problems. Once I updated to the current stable version all of the problems were gone. So always check your node version and use nvm to update if needed.

Sometimes upgrading to latest version causes problems as well. This is why many apps freeze versions of packages and test upgrading them as a single commit.

Ah yeah, I tend to follow whatever version the dev says their app runs on when I can.

A lil' heads up for others ( like me ) who are really bad with backend stuff ... you don't really need nodejs for make a front-end/website for hive ... client-side works perfectly fine !

Python is really easy to learn and understand compared to JavaScript, cz c++ etc.

I'm when it comes to web design it not so easy, tho I'm just started learning Django tho. Because HTML and CSS is better for web site front end.

I like it.

That is the content we need. Build our own devs on hive.

Would be really awesome if you build an dapp step by step. With the basic shit that needs to be done.

I've been contemplating developing some things on Hive mainly for educational purposes so this is a great starting point. Thanks for sharing

I highly recommend Codium over VS Code. It is the same application, except with all of the telemetry (report home to Micro$oft) removed.

There was a reason I don't use this, I think certain modules don't work with this version. I can't remember off hand.

There shouldn't be any reason that modules / addons don't work with it as it is exactly the same code base minus telemetry.

Every addon I've used so far works just fine.

You can disable telemetry in the settings, just comfirmed mine is off. Although I am not too concerned with what is sent (it's all open source so you can confirm what is sent) and in fact it maybe good to run it as it helps them know what modules are most popular and where problems lie.

Naaa... I'll stick to Codium. I like it, works very well for me. 😀

 3 years ago  

Great overview and recommendations! Thanks for the links.

Are there any Node.js / Javascript libraries available for Hive development?

Edit: I might have answered my own question.

https://gitlab.syncad.com/hive/hive-js

There is HiveJS and DHive. Dhive was better, but isn't maintained so most people use HiveJS.

Cheers, I was looking at those, but neither seem to make much or any reference to the internal market. Or have I overlooked something?

Is there perhaps any documentation for API endpoints for the market?

Hive internal market or Hive Engine?

I've only used the internal market, so I was referring to that one.

Hive Engine is for all of the other tokens built on Hive correct?

Hive Engine is for all of the other tokens built on Hive correct?

yes

What made DHive better than HiveJS?

It had more functionality and was structured more professionally. I would recommend comparing the documentation and you will clearly see what I mean.

OK it hasn't been updated in a while, how has it fallen behind Hive.js or is out of date?
Has there been much change to the Hive API?

Almost all the Hive libraries are not really maintained much, except when there is a hard fork and there is an emergency update, someone will usually dig in and figure out what needs to be fixed.

Thanks for the clarification.

a lot of knowledge thanks mate

When you begin exploring Hive, the first thing that comes to mind is how to build an application with it. After all, there are a lot of things for you to consider before you get started on creating a product. In this article, we'll go over what it takes to get up and running quickly with Hive app development. You can get PureWL help to solve your vpn issue easily. Hive is a web app framework built on top of Django. It provides simple tools to build and run HTML5 apps using Python and Django, making it easy to get started with developing your first app in minutes without having to write any code.

Thanks Marky

Very informative post. Thanks mate

great, wish I could contribute!

Thank you! I’ve been looking for more and more info on this stuff.

The amount of work put into hive’s eco system is really impressive. Proud to be here


The rewards earned on this comment will go directly to the person sharing the post on Twitter as long as they are registered with @poshtoken. Sign up at https://hiveposh.com.

excellent post friend actually touched informative points that is within the reach of the knowledge of many and good necessary to start thanks

Excelent post. I am exploring this new ecosystem and I want to contribute code. This post is a great place to start.

Best piece of advice I see here and can give myself, don't get into tutorial hell. You will learn more with one real project that with 100 tutorials

A few questions for you @themarkymark...

  1. What do you think of LightHive? For some reason, when I have used Beem for posting, I have experienced issues. LightHive, I have had no issues with it. LightHive is a Python module/library.

  2. If I wanted to build a non-blogging platform with exclusivity and an associated side-chain token (like a forum) would I be able to do so?

  3. I'm blacklisted by a certain someone who has given themselves too much authority and opened the door for abuse, would their harassment bots follow me into this more exclusive non-blogging app I'm creating?

  4. Just so it is 100% clear to me, I would self-host the app and connect to the Hive Blockchain API? I can literally have it hosted wherever I want, correct?

  1. I am familiar, I believe it was forked off beem. I have no issues posting from beem. It is likely user error.

  2. I would think so, others have (minus the token part).

  3. if it uses rewards on the base layer (hive) then yes, potentially

  4. yes

Excellent, that's good to know. I wanted to know about these things before I planned the build and started coding this thing.

Very possible the Beem issues are on me!

Downvoted due to @hakeemshah96's insincere copy-paste spam compliments.

Downvoted due to @hakeemshah96's insincere copy-paste spam compliments.