473,545 Members | 2,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Running an existing C program on a web application?

5 New Member
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 8711
dev7060
639 Recognized Expert Contributor
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,456 Recognized Expert Moderator Top Contributor
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.opti ons.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 New Member
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 New Member
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
1643
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 about Zend Engine 2. Also the PHP-GTK page mentions that there is no memory deallocation. But how can one write a GUI program without memory control ?
0
1367
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 runs, Internet Explorer crashes and I get the generic error message window with DEBUG, SEND ERROR REPORT & DON'T SEND buttons. I checked the event...
0
1475
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 runs, Internet Explorer crashes and I get the generic error message window with DEBUG, SEND ERROR REPORT & DON'T SEND buttons. I checked the event...
5
1721
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 .NET version 1.1 you will be unable to run ASP .NET web applications or services" what can cause this error message? Thanks,
1
1568
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 Lable control, "task 1 starting...", "Task 1 completed.", etc. However, the text for the label is not being updated/showed. I understand that the...
0
232
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) and just add a few new user controls to it. I do not want to copy the entire reusable application (solution, projects, etc) and add my new user...
0
1822
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 the same application second time, it is not working. First time the setup willbe installed through CD-ROM. If any version increase then the new...
1
3945
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 application you can add a reference to that class library in the project by right clicking the Windows Application and selecting "Add Reference" and you will...
2
4702
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 available. The dll performs the communication beteween the computer and a external device (using a RS232) line.
7
4836
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 application : http://localhost/MyApp/Default.aspx My existing Win Application : existingWinApp.exe New Parent WinApp :...
0
7496
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7428
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7784
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6014
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5354
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1916
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1039
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
738
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.