News for hackers. Stuff that matters.
Re:Lithium ranked the highest performance web application pl... by matt42 on Saturday August 29, 2020 @07:20AM (#24315309)
Link to the lithium homepage: https://github.com/matt-42/lithium
Re:Lithium ranked the highest performance web application pl... by ponytech on Saturday August 29, 2020 @08:07AM (#24315531)
Thanks for the link.

A web search for "lithium web framework" gave https://li3.me as the first result, which is a PHP framework.

Why did you pick such a name if already taken by a similar product?

Re:Lithium ranked the highest performance web application pl... by matt42 on Saturday August 29, 2020 @08:23AM (#24315613)
I was not aware of li3.me and when I realized it, I was too lazy to find a new name..
Re:Lithium ranked the highest performance web application pl... by Flow on Saturday August 29, 2020 @07:41AM (#24315390)
It's Linux only apparently.

Is it the use of some Linux only kernel API that enables it to be slightly faster than the other frameworks?

Re:Lithium ranked the highest performance web application pl... by matt42 on Saturday August 29, 2020 @07:57AM (#24315476)
It is linux only because it's based on epoll. It could be easily ported to macos and windows but my focus was to get the performances right first.
Re:Lithium ranked the highest performance web application pl... by jeremyjh on Saturday August 29, 2020 @10:55AM (#24316510)
There are still a lot of people who develop on MacOS and deploy on linux, so a kqueue port would be valuable even if it were not as well tuned.
Re:Lithium ranked the highest performance web application pl... by matt42 on Saturday August 29, 2020 @01:08PM (#24317588)
a kqueue port should be ok. I'll add an issue for it.
Re:Lithium ranked the highest performance web application pl... by hinkley on Saturday August 29, 2020 @11:42AM (#24316848)
There are a few libraries that wrap epoll and friends to work more cross platform.

How widely do you use it? Everywhere? A few spots?

Re:Lithium ranked the highest performance web application pl... by matt42 on Saturday August 29, 2020 @01:06PM (#24317571)
The epoll code use is very small, few hundreds of LOC (but is at the very center of the framework since it runs the event loop), actually writing it from scratch was better to understand the mechanism, to optimize it and to adapt it for non blocking sql.
Re:Lithium ranked the highest performance web application pl... by giancarlostoro on Saturday August 29, 2020 @11:31AM (#24316774)
One could argue if it works on WSL then it works on Windows for development use cases to deploy on Linux.
Re:Lithium ranked the highest performance web application pl... by fluffy87 on Saturday August 29, 2020 @07:41AM (#24315394)
Can you do an AMA? Why did you create lithium? How long have you been working on it? What do you do professionally? What are your plans for it?
Re:Lithium ranked the highest performance web application pl... by matt42 on Saturday August 29, 2020 @07:55AM (#24315463)
Can you do an AMA? of course!

Why did you create lithium?

To see how much C++ can get closer to dynamic langagues typically used for web programming and at the same time make absolutely no compromise on performances.

How long have you been working on it?

8 months on lithium, but I already wrote another framework (silicon, which I rewrote from scratch because of slow compilation time).

What do you do professionally?

I worked for several company, doing different things including, real time image processing, neural nets for photography, web programming, robotics

What are your plans for it?

No big plans yet, just having fun for now, but I'd like to keep implementing the features if the users ask for it, improve the doc. In the more long term, building websockets would be nice too, and other services on top of it.

Re:Lithium ranked the highest performance web application pl... by sitkack on Saturday August 29, 2020 @11:15AM (#24316634)
Given that the whole framework is in roughly 31kloc of C++ written mostly by you and this not your first framework. Can you talk more about your design choices, what the architectural patterns are and how metaprogramming plays a role [1] ?

Besides your experience from writing Silicon [2], what other frameworks do you like the design of? What C++ codebases do you like or find interesting from a design perspective?

[1] https://github.com/matt-42/iod (merged into Lithium)

[2] https://github.com/matt-42/silicon

Re:Lithium ranked the highest performance web application pl... by matt42 on Saturday August 29, 2020 @11:56AM (#24316976)
I think I need to write a blog post to do a retrospective on what I learned writing iod, silicon, lithium (and vpp, a small image processing lib). There is so much to tell.

Just to be short, here is my phylosophy:

   - don't think too much when you write it the first time, just do it quick. Do all the mistakes and ugly code first and then rething/rewrite things when it can actually simplify the codebase. Big refactors are much more productive and successful than big premature design thinking.
   - Only expose the complexity that the user need. Simple things should stay simple even if we can do more complex stuff. Look for simplicity everywhere.
   - Profile before optimizing, the bottleneck is never where you think it is.

For you question about metaprogramming, it is used yes. The core of the framework is build around a compile time key/value map that unroll json and get/post parameter de/serialization at compile time [1] so no dynamic dictionary involving costly malloc is needed.

[1] https://github.com/matt-42/lithium/tree/master/libraries/met...

Re:Lithium ranked the highest performance web application pl... by ilovelearning on Saturday August 29, 2020 @08:33AM (#24315650)
Impressive! Two questions. What’s your opinion regarding Rust versus C++? And what robotics stuff have you worked on?
Re:Lithium ranked the highest performance web application pl... by matt42 on Saturday August 29, 2020 @08:51AM (#24315730)
For Rust vs c++: - I never used rust but I like the language and the safety it provides.

  - a mainstream package/dependency manager is missing in C++ so rust is clearly better on this point. This is a big problem for the C++ community where code is much less shared than in the javascript community for example.
  - The other big problem I have with C++ is compile time, I heard that Rust is slow too but I never compared the two.
And what robotics stuff have you worked on?

I'm building a offline programming tool for industrial robots: http://stara-robotics.com/

Re:Lithium ranked the highest performance web application pl... by altcognito on Saturday August 29, 2020 @08:17AM (#24315582)
What's the real time image processing stuff you work on?
Re:Lithium ranked the highest performance web application pl... by matt42 on Saturday August 29, 2020 @08:52AM (#24315742)
High density point tracking and optical flow was a big part of my PhD, here is a demo :) https://www.youtube.com/watch?v=GIUDAZLfYhY
Re:Lithium ranked the highest performance web application pl... by codekilla on Saturday August 29, 2020 @12:58PM (#24317493)
This looks great. How would you compare to seastar?
Re:Lithium ranked the highest performance web application pl... by matt42 on Saturday August 29, 2020 @01:59PM (#24318081)
Sadly seastar has no implementation of this benchmark. I had a quick look at the website and it seams that seastar is much more low level (it does not provide a http parser) and more generic that lithium, which is focused on simplifying the writing of HTTP APIs.
Re:Lithium ranked the highest performance web application pl... by yesbutt11 on Saturday August 29, 2020 @11:05AM (#24316562)
Re: metamap being zero cost

I thought there were no zero cost abstractions in C++?

https://youtu.be/rHIkrotSwcc

Still, it isn’t RoR or anything JS so it has that going for it.

Re:Lithium ranked the highest performance web application pl... by matt42 on Saturday August 29, 2020 @11:59AM (#24317009)
Yes zero cost is subjective. It has a cost at least at compile time. But you can see metamap is a like loop unrolling for objects (if you think loop unrolling is zero cost then metamap too).