frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

What does it mean to use C++ in the front end?

6•AliceHe2003•4h ago
I’ve been working on a browser-based image editor written in C++, and when I tell my friends about it, the most common reactions I get are “Huh???” and “Why???” ...Let’s break it down.

First: Wait, how does C++ run in the browser? I’m not just tossing raw C++ into a browser tab. The browser only knows how to speak 2 languages: JavaScript and WebAssembly. WebAssembly (WASM) is a bytecode language that is interpreted in the browser. The trick is to write C++ functions and compile them to WASM using Emscripten. Javascript still controls the DOM, so WASM can’t do everything - you’ll have to call the C++ functions from JavaScript.

If Javascript and WASM need to work together, they’ll need a way to communicate and transfer data! To do this, JS allocates shared buffers, writes data into it, then calls into C++ using ccall. The C++ function processes the data and returns control to JS, which can then read from the shared buffers.

C++ compilers typically mangle function names by encoding additional information—like parameter types—to support features like function overloading and prevent naming conflicts. To make C++ functions accessible from JavaScript, I used “extern C”, a directive that tells the compiler to preserve the original function names and disable name mangling.

And yes, if you mismanage memory allocation or forget to free, you can cause undefined behaviours your browser app

Second: Why go through all this trouble? Image editing—especially with real-time filters, frequent canvas updates, and support for dozens (or even hundreds) of layers—is computationally heavy. JavaScript alone may not keep up, especially when you're pushing for high performance and smooth UX.

Why? Because JavaScript is an interpreted language—it’s read and executed line by line at runtime, which adds overhead. WebAssembly, on the other hand, is a lower-level bytecode. When you compile C++ to WASM, you get the benefits of LLVM's compiler optimizations along with the portability of the web.

So even though WASM is still technically interpreted, it's much closer to machine code and runs at near-native speed. That means complex image processing operations—like applying custom filters or merging high-resolution layers—can happen fast, without freezing the browser or dropping frames. The end result? A frontend that feels like a native desktop app, but runs in your browser.

For anyone who's interested, here's the GitHub repo! https://github.com/alicehe2003/ImageEditor

This project was inspired by how Figma is built!

https://www.linkedin.com/posts/alice-he-95406b293_github-alicehe2003imageeditor-web-based-activity-7340407818077859842-r3FK?utm_source=share&utm_medium=member_desktop&rcm=ACoAAEcFpZABjEOydMovU7l8KMPjazq9tzhE9Rc

Comments

gus_massa•3h ago
Clicky https://github.com/alicehe2003/ImageEditor

Trying Out the AMD Developer Cloud for Quickly Evaluating Instinct and ROCm

https://www.phoronix.com/review/amd-developer-cloud
1•mfiguiere•5m ago•0 comments

The Promised LAN

https://notes.pault.ag/tpl/
1•ecliptik•11m ago•0 comments

Music as a Gradual Process [Reich, 1968] [pdf]

http://musicgrad.ucsd.edu/~dwd/2014_music14/reich.pdf
1•brudgers•12m ago•0 comments

The Nuanced Reality of Throttling: It's Not Just About Preventing Abuse

https://blog.joemag.dev/2025/06/the-nuanced-reality-of-throttling-its.html
2•Bogdanp•16m ago•0 comments

Helsing valued at €12B to become one of Europe's most valuable tech groups

https://www.ft.com/content/cdc02d96-13b5-4ca2-aa0b-1fc7568e9fa0
2•jamesblonde•19m ago•1 comments

Virtual Cells

https://udara.io/science/virtual-cells/
1•surprisetalk•20m ago•0 comments

Blasnake: Snake but now the snake is a weapon

https://abagames.itch.io/blasnake
1•memalign•21m ago•1 comments

A Surprising Route to the Best Life Possible

https://www.nytimes.com/2025/03/27/opinion/persistence-work-difficulty.html
1•gregorvand•31m ago•0 comments

Show HN: I recreated 90s Mode X demoscene effects in JavaScript and Canvas

https://jdfio.com/pages-output/demos/x-mode/
2•gneissguise•31m ago•0 comments

Show HN: Frozti.io instantly turns design into live UI and production ready code

https://frozti.io/signin
1•amarneethi•36m ago•0 comments

The grim reality of assisted dying

https://thecritic.co.uk/the-grim-reality-of-assisted-dying/
2•Brajeshwar•42m ago•1 comments

William Langewiesche, the 'Steve McQueen of Journalism,' Dies at 70

https://www.nytimes.com/2025/06/16/business/media/william-langewiesche-dead.html
7•rsingel•48m ago•1 comments

3D Printing Research at EPA

https://www.epa.gov/chemical-research/3d-printing-research-epa
2•bicepjai•50m ago•0 comments

Dungeon Rampage code rescued from a child's laptop and is relaunching on Steam

https://www.pcgamer.com/games/action/dungeon-rampage-interview/
3•chris_overseas•59m ago•0 comments

Social media overtakes TV as Americans' top news source

https://www.niemanlab.org/2025/06/for-the-first-time-social-media-overtakes-tv-as-americans-top-news-source/
3•thm•1h ago•0 comments

Paper ECG: An open-source application for digitizing ECG image scans

https://github.com/Tereshchenkolab/paper-ecg
1•teleforce•1h ago•0 comments

Missiles That Destroyed Air Defenses from Inside Iran Were Remotely Operated

https://www.twz.com/news-features/spike-missiles-that-destroyed-air-defenses-from-inside-iran-were-remotely-operated
2•nradov•1h ago•0 comments

Show HN: Wheretowatch.stream – See where movies/shows are streaming globally

https://www.wheretowatch.stream
4•ericrenan•1h ago•1 comments

Enabling enhanced security for your app

https://developer.apple.com/documentation/Xcode/enabling-enhanced-security-for-your-app
1•transpute•1h ago•0 comments

Atproto OS – Web Desktops on the AT Protocol

https://github.com/atproto-os
2•dxlliv•1h ago•1 comments

GPT-4.5 preview in the OpenAI API will be shut down on July 14, 2025

https://platform.openai.com/docs/deprecations#2025-04-14-gpt-4-5-preview
2•peterdavehello•1h ago•0 comments

Waymo recalls more than 1,200 automated vehicles after minor crashes

https://www.latimes.com/business/story/2025-05-14/waymo-recalls-more-than-1-200-automated-vehicles-after-minor-crashes
4•andsoitis•1h ago•2 comments

Cross-social networks

https://yeldar.org/blog/cross-social-networks/
2•yeldar•1h ago•0 comments

Sound Static Data Race Verification for C [pdf]

https://patricklam.ca/papers/25.toplas.data-race-empirical.pdf
1•luu•1h ago•0 comments

Show HN: Kabit – A habit tracker

https://apps.apple.com/us/app/habit-tracker-kabit/id6511250768
3•iamrahulrao•1h ago•0 comments

Is embracing AI intellectual or anti-intellectual?

https://hollisrobbinsanecdotal.substack.com/p/is-embracing-ai-intellectual-or-anti
2•HR01•1h ago•0 comments

ECG-Image-Kit: A toolkit for analysis, synthesis, and digitization of ECG images

https://github.com/alphanumericslab/ecg-image-kit
1•teleforce•1h ago•0 comments

Rules, Not Renewables, Might Explain the Iberian Blackout

https://spectrum.ieee.org/spain-grid-failure
3•pseudolus•1h ago•0 comments

Mind Donation

https://blog.ayjay.org/brain-donation/
1•blueridge•1h ago•1 comments

California bill targets masked officers

https://www.msn.com/en-us/news/us/officers-who-cover-their-faces-could-be-charged-with-a-misdemeanor-under-california-proposal/ar-AA1GPMyt
1•eligrid•1h ago•0 comments