Platform independent feature with Go Language

Hi,

The JAVA coders always come up with answers like JAVA code is platform independent. They have the JIT compiler, They can connect with SQL, Mongo DB etc. Various libraries are available and you get lot of help from community, so you can build project like IOT just in days.

Being an Embedded C developer (and using Keil compiler most of the time), I do not find such capabilities. Although I am happy that C codes are pretty fast, more close to the hardware (and hence easy to develop low level drivers) and robust compared to JAVA code. But the biggest issue is the development time. People also say JavaScript and Node.JS are far better.

Hence I though of learning Go Language which I suppose has advanced features, close to C / C++. But I am not sure whether Go has something similar to JIT, and what answer should I respond back to JAVA developers, when they talk about it.

I want to understand both the strong and week points of Go Language when I compare it with C, C++, Java, JavaScript, Node.JS, and .NET

Where do I find details of libraries that help me build projects for IOT, robotics, Oil & Gas pipe welding, BLDC motors, Tilt sensors etc.

How do I ensure that the code I developed in Keil (with RTX RTOS) for a 8051, ST10xxx, STM32F4xx, STM32F1xx processors is easily portable to processors like i.MX6 (with Ubuntu 14.04 as RTOS running on it). I understand that parts of the code need to be rewritten because there is change in RTOS. How do I debug the code for / on the platform it will run on? The code development will mostly take place on a Windows 7 or Ubuntu-14.04 running Laptop (with i5 or i7 processor). The code will execute on the i.MX6 processor (Quad core).

How do I ensure that the project that we once built using Visual Studio 2013 (C++) can easily be ported to i.MX6 and that the developer community does not come back and ask me to code it in JAVA / JavaScriot etc. to make it platform independent.

I want to use C, C++ and Go Language and come up with the solution for issues I have talked about.

Please help.

Thanks and regards,
Rajeev Arora

1 Like

Go compiles to native machine code for the target platform, just like gcc.

That’s a big question, IMO if this is core to your application, you should invest engineering time in wiring your own libraries.

Go does not support 8051, ST10xxx, STM32F4xx, STM32F1xx architectures. As a rule of thumb, it has to run Linux.

printf

I answered this in your previous thread.

You’re mixing the language (Go, C++), the development environment (VS Studio 2013) and the processor architecture (ARMv7 and intel). This makes it hard to give a useful answer to your question.

Go can compile natively and cross compile to several platforms, https://golang.org/doc/install/source#introduction, and provides conventions to allow developers to write portable code. Your hardware platform, i.MX6 is a supported hardware platform, but you will have to run linux on it.

You can use Go to write userspace applications that will run your iMX system. I would caution you against trying to link C and C++ code to your Go application, especially in a cross compilation environment without developing expert competence in house to maintain your build chain.

2 Likes

Reference for using build tags for conditional compilation, https://dave.cheney.net/2013/10/12/how-to-use-conditional-compilation-with-the-go-build-tool

Reference for cross compilation, https://dave.cheney.net/2015/08/22/cross-compilation-with-go-1-5

Cautionary note about avoiding cgo, https://dave.cheney.net/2016/01/18/cgo-is-not-go

Thanks for the above information. Those processors were used on our legacy systems / hardware. We are moving to i.MX6 based hardware which will run Linux (Ubuntu-14.04).

I believe there is a way for calling C functions via Go code. I want to understand this. I also want to understand how to convert (legacy) C functions to something (like libraries) which can then be called or used from Go Language.

This is called cgo, https://blog.golang.org/c-go-cgo

Thanks Dave for quick replies.

I understand that Linux should run on i.MX6 and probably I should be able to create a .so for my code that then executes on Linux.

Below is insight into my query wherein I talked about various languages:

In past we were coding in C and compiling code for our legacy processors (like ST10, STM32F4xx etc.) that were present on our custom made Embedded boards / PCBs. We had to connect to a external server that runs Windows 7 (on Intel Quad core 1.5 GHz chipset based mini computer / server) and executed a (Visual Studio compiled C++) EXECUTABLE that took care of the logs received from the embedded hardware (over RS232).

As time passed, there arose needs to move away from the mini computer / server. Hence some members suggested to convert the C++ code to JAVA / Java Script / Node.JS code, so that it becomes portable. Also they informed that the development time will be significantly less and that various Libraries are available for IOT, JSON, HTML parser(s) etc. with JAVA / Java Script / Node.JS. Hence, this was taken up as a separate activity. This team also started using SQL for record keeping / data storing. New features were also added as and when needed.

We did not try building the C++ code with Mono Develop

We wanted to use a system with better capabilities and of industrial grade. We also wanted to decrease the gap between what we considered embedded hardware and what we considered as server. Hence we though of porting everything to i.MX6.

Henceforth the two hardware (namely the embedded hardware and server) will no longer be two different entities.

As on day one team is using i.MX6 (Quad core processor) and coding the server part in Java Script, Node.JS, JAVA. They may then copy / use parts of legacy Embedded C code as is or with some modification.

Out of the Four processors (present with i.Mx6) Two of the i.MX6 processors will run critical C code and RTOS Kernel (Ubuntu 14.04). One processor will run JAVA / Java Script / Node.JS based server and may use the left processor if need be. The non critical functionality running processors will also fetch and write data from and to the database.

On i.MX6, I believe both SQL and MonoDB will be too bulky.

I know Go Language is closer to C and efficient in many ways compared to other languages I talked about.

I however as on day do not have statistics or links to information that indicate benefits of using Go Language over JAVA / Java Script / Node.JS and thus have a product which is coded using C, C++ and Go Language. For critical tasks, I cannot compromise on the performance and efficiency of the system.

I am not sure what answers to give back to others when they talk about JAVA being superior to C / C++. I know their JDK9 is going to have many features similar to what C++ has currently. I know JAVA does not use pointers. I know JAVA will not help me write device drivers, but it does help develop the IOT, JSON parser, and some other things within no time.

We do have expertise with the legacy C code, but we are building expertise with i.MX6 processor, Ubuntu and Go Language.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.