473,320 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Running an existing C program on a web application?

5 Nibble
I have a set of C programs for data analysis that take an input of files and display desired output via the command line.

How do I make these programs accessible in a web application without having to code them up again in a web programming language?

Can i use the existing C code?
How would i do this?

Thanks
Jan 3 '21 #1
4 8677
dev7060
630 Expert 512MB
Have the backend language execute em via shell providing the required input data. Then redirection of the output can be done to the web application.
Jan 4 '21 #2
Niheel
2,460 Expert Mod 2GB
As dev7060 said that is one approach and probably the easiest if you are already familiar with a web-programming language that has functions that can execute code on the server.

Another is to use Web Assembly also known as WASM.

It really comes down to your existing code-base, your ability and the need for application to perform.

What is Web Assembly?
Web Assembly is a specification for a virtual machine that runs in the browser. Compared to the highly dynamic JavaScript, Web Assembly can achieve much higher performance. Contrary to popular misconception though, Web Assembly doesn't completely replace JavaScript. You will probably use the two together. Web Assembly is based on LLVM (Low Level Virtual Machine), a stack based virtual machine that compilers can target.
Why use it?
Typically, when people talk about the advantages of WebAssembly, it’s from the standpoint of performance. But WebAssembly brings another advantage to the table—code reuse. Rather than writing the same logic multiple times for each target environment (desktop, website, and others), WebAssembly lets you reuse the same code in multiple locations.
Here's a doc on dev.mozilla that helps setup a basic C++ module to Web Assembly.

The jist of it is:
Compiling C++ code into Web Assembly using ( Emscripten )
Emscriptem is a LLVM to JS compiler which results in
  • The binary wasm module code (hello.wasm)
  • A JavaScript file containing glue code to translate between the native C functions, and JavaScript/wasm (hello.js)
  • An HTML file to load, compile, and instantiate your wasm code, and display its output in the browser (hello.html)
Call the HTML file in a browser that supports Web Assembly
  • Web assembly is enabled by default in Firefox 52+ and Chrome 57+/latest Opera
  • You can also run wasm code in Firefox 47+ by enabling the javascript.options.wasm flag in about:config
  • Chrome (51+) and Opera (38+) by going to chrome://flags and enabling the Experimental WebAssembly flag.

Some intriguing points about both methods.
Server:
  • Security - because it's server code, the inputs should be strictly validated and contained to keep arbitrary from code executing on your server.
  • Server Performance - also it might have an effect on the performance of other users of your service depending on if you run as a service or execute on demand.
Web Assembly ( Client ):
  • Local performance - test it for performance on various machines before deploying it ( memory leaks etc )
  • Security - It's contained in a VM on the client browser, regardless input should be validated.
  • Feature access - The compiled WASM binaries will have access to the same features that the browser has on the client machine.

Other languages that WASM supports
  • C/C++
  • C#/.NET
  • Elixir
  • Go
  • Java
  • Python
  • Rust

References:
Compiling a New C/C++ Module to WebAssembly
Introduction to Web Assembly with C/C++
Reusing your existing C++ codebase
Emscripten - compiler toolchain to WebAssembly, using LLVM.
Jan 4 '21 #3
SwissProgrammer
220 128KB
Easy does not always equate to safe.

I think that about a few of years ago I was researching WASM as it related to security and I think (if I recall correctly) that I found at least one reason to avoid it.

Maybe. But, I think that it might be on my list of what to not use. Maybe. For some reason I seem to be avoiding using it. I do not recall if or why.

As some radio talk guy says, "I am not saying anything. Just saying."
Jan 14 '21 #4
zilmubufye
1 Bit
data analysis that take an input of files and display desired output via the command line
Feb 12 '22 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Lothar Scholz | last post by:
Does console programs free memory during the execution ? Until now i thought that a script never releases memory until the end is reached. But now i found the term GC a few times while reading...
0
by: Florin M | last post by:
I am running a custom application developed with ASP.NET 1.1, C# and Visual Studio 2003. I recently installed SP2 for XP Professional. When I close the Internet Explorer window where the app...
0
by: Florin M | last post by:
I am running a custom application developed with ASP.NET 1.1, C# and Visual Studio 2003. I recently installed SP2 for XP Professional. When I close the Internet Explorer window where the app...
5
by: Dafna | last post by:
while trying to open an Asp .Net application ' I get the following message (the IIS on my computer is running) "Visual Studio .Net has detected that the specified web server is not running ASP...
1
by: James Li | last post by:
I have a windows form application (C#) that launches multiple external batch files to do various installation tasks. I want to show some status on the win form, say simply update the text on a...
0
by: Amil | last post by:
I have a reusable web application (e.g. portal). I often do a project copy to create new virtual apps. This works fine. Now I want to take that reusable app (not the solution and it's projects)...
0
by: Uma | last post by:
Dear all, I have a problem while running a smart client application which was installed through CD-ROM. After installing the smart client setup the application is running properly. When running...
1
by: =?Utf-8?B?d2lubGlu?= | last post by:
Hello Using VS 2005 VB.net when a class library gets created you can right click the project and add a Windows Application and then set it as the "startup project" then in the Windows...
2
by: =?Utf-8?B?SmFuIExpbmRo?= | last post by:
Hi Is there a preferable way to write a C# dll that should be called from an existing application (running native code). It is not possible to change this application and its source code isn't...
7
by: =?Utf-8?B?U2hpdmEgUmFtYW5p?= | last post by:
I have a windows application with multiple forms & another web application. Now I need a parent EXE or Application which need to act as a container to these application. Example : My existing Web...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.