MapStruct VS SharpLab

Compare MapStruct vs SharpLab and see what are their differences.

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
MapStruct SharpLab
24 106
6,797 2,554
1.5% -
7.8 7.8
28 days ago 4 months ago
Java C#
Apache License 2.0 BSD 2-clause "Simplified" License
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

MapStruct

Posts with mentions or reviews of MapStruct. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2024-04-13.
  • Is .NET just miles ahead or am I delusional?
    4 projects | news.ycombinator.com | 13 Apr 2024
    Currently using .NET and ASP.NET for the API of a project that I'm working on, overall it's a pretty lovely experience, especially with the JetBrains Rider as my IDE. Having worked with Java in the enterprise in the past, it feels like a more focused and sometimes more coherent experience (vs the more decentralized nature of Java), that now thankfully runs fine on Linux as well, don't even need to hope that Mono is good enough anymore.

    Entity Framework Core is great, the way how they fetch related data is straightforwards: https://learn.microsoft.com/en-us/ef/core/querying/related-d...

    I also really like the ability to use split queries, when needed: https://learn.microsoft.com/en-us/ef/core/querying/single-sp...

    You can even scaffold your entity mappings from an existing database and manage database migrations separately (which I feel is a must unless you want to pour hours upon hours into learning yet another JPA-like), it's nice when something like that exists in a given ecosystem: https://blog.jetbrains.com/dotnet/2022/01/31/entity-framewor...

    Some of the stuff in the ecosystem is also really nice, like using ActionBlocks from Dataflow for simple queues and task scheduling is very easy to get started with and pretty pleasant: https://learn.microsoft.com/en-us/dotnet/api/system.threadin...

    Honestly, most of the docs that I've come across are rather pleasant and there's plenty of code examples to be had and even LLMs have enough codebases out there to be trained on and give decent output, in addition to the regular autocomplete in the IDE.

    Even some third party stuff like CsvHelper is really well put together: https://joshclose.github.io/CsvHelper/getting-started/#insta...

    That said, I've had issues where trying to deserialize incoming JSON requests ([FromBody]) lead to the whole object being null, due to it not matching the fields 1:1 or violating some nullability constraint, however that happened without a clear error message or as much as a warning in the logs, which felt insane and wasn't very discoverable. Now I just use JObject as the parameter and deserialize at the top of the controller method.

    I've also run into some ecosystem issues where the OpenAPI codegen was a bit lacking and wouldn't actually generate code that works, but maybe that's because the spec was bad: https://openapi-generator.tech/docs/generators/csharp

    I could also not get AutoMapper (https://docs.automapper.org/en/stable/index.html) working satisfactorily, so for now I'm stuck writing mappers by hand with said autocomplete sometimes doing it for me. There were issues with the runtime being unable to register the mappers or something like that, it was a while ago. Overall it felt like the MapStruct library in Java did everything better: https://mapstruct.org/

    On the other hand, I haven't had any of the Spring Boot DI related headaches (needing @Lazy sometimes) with ASP.NET, things there seem way more straightforwards and you clearly define whether something should be a Singleton or Scoped and the rest... just gets out of your way and works.

    Sadly, there have been very hard to track down cases where I try to do a _dbContext.Add(someEntity) and then when I do a save with just the fields in that one entity changed, the performance absolutely seems to slow down to a crawl. Adding _dbContext.ChangeTracker.AutoDetectChangesEnabled = false seemed to help, but I am still not entirely sure what lead to that behavior, the temp directory on my Linux box also started filling up very rapidly, yet the logs had nothing of use, definitely seems like something I'd need to investigate properly.

    Overall, .NET and its ecosystem is pretty good in most cases. And .NET being used in gamedev is also cool, for those who care about that sort of thing, I wonder why jMonkeyEngine never really took off.

  • Object mapping libraries
    1 project | /r/Python | 18 Sep 2023
    In Java (woof..) we have MapStruct (https://mapstruct.org/). Anything like that in Python? I think maybe the Sqlalchemy mapping in Litestar2 is the closest I've seen.
  • Feedback on a new annotation processor api
    9 projects | /r/java | 20 May 2023
    Done right i can look something like mapstruct for example. But like any other feature you need to get a feeling for when it's a good idea to use it.
  • Mapping in Domain Driven Design sucks
    1 project | /r/javahelp | 6 Feb 2023
    We are using mapstruct but it sucks when you have protobuf :/
  • must known frameworks/libs/tech, every senior java developer must know(?)
    6 projects | /r/java | 9 Dec 2022
    You all beat me to MapStruct and Testcontainers. Honorable mention to RxJava, which I use in Desktop apps.
  • Correct way of exception handling, an optional?
    1 project | /r/javahelp | 30 Nov 2022
    For the mapping, I'm using Mapstruct, I got the instance example from their examples they use INSTANCE as constant.
  • Ask HN: What are your “scratch own itch” projects?
    34 projects | news.ycombinator.com | 13 Nov 2022
  • What next Springboot?
    1 project | /r/javahelp | 1 Oct 2022
    Now update your code so that no entities are passed to/from the domain layer and that no objects are passed to/from the domain layer. You'll look at me as though I'm nuts, but you will thank me later. Look at things like http://immutables.github.io/ and https://mapstruct.org/
  • Using MapStruct and Lombok with Inheritance
    1 project | dev.to | 22 Sep 2022
    When my pairing partner and I ran into this use case, we were initially stumped. Even our combined Google Fu efforts were not turning up a good solution. However, we eventually discovered a PR for MapStruct that seemed to be the solution to our issues! But, of course, if it were that simple, I would not be writing this now. The SubClassMapping annotation provided by that PR, while quite helpful, requires specific Mapping annotations for every field on the subclass. We wanted a more elegant solution.
  • We released a new version of ShapeShift (0.6.0) - A lightweight, modular, performant and extensible object mapping library
    2 projects | /r/java | 6 Sep 2022
    Just use MapStruct...

SharpLab

Posts with mentions or reviews of SharpLab. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2024-04-13.
  • Is .NET just miles ahead or am I delusional?
    4 projects | news.ycombinator.com | 13 Apr 2024
    Do these all compile to the exact same thing?

    https://sharplab.io/#v2:CYLg1APgAgTAjAWAFBQMwAJboMLoN7LpHoCW...

    Yes, so you are right.

  • Generating C# code programmatically
    4 projects | dev.to | 5 Apr 2024
    Recently, while creating some experimental C# source code generators (xafero/csharp-generators), I was just concatenating strings together. Like you do, you know, if things have to go very quickly. If you have a simple use case, use a formatted multi-line string or some template library like scriban. But I searched for a way to generate more and more complicated logic easily - like for example, adding raw SQL handler methods to my pre-generated DBSet-like classes for my ADO.NET experiment. You could now say: Use Roslyn and that's really fine if you look everything up in a website like SharpLab, which shows immediately the syntax tree of our C# code.
  • The One Billion Row Challenge – .NET Edition
    3 projects | news.ycombinator.com | 6 Jan 2024
    One results in MOVSX, the other in MOVZX [1]. The difference thus is sign/zero extension when moving to the larger register. However, they seem to perform pretty much identical if I'm reading Agner Fog's instruction tables correctly.

    [1] https://sharplab.io/#v2:C4LghgzgtgPgAgJgIwFgBQcDMACR2DC2A3ut...

  • Any programs or websites to practice programming?
    6 projects | /r/csharp | 8 Dec 2023
    If you don't have an IDE, you can use SharpLab.io or dotnet fiddle
  • Por debaixo do capô: async/await e as mágicas do compilador csharp
    3 projects | dev.to | 18 Oct 2023
  • C# Testing Playgrounds for old versions?
    3 projects | /r/dotnet | 26 Aug 2023
    The closest online tool I can think of would be SharpLab, but you can only choose between Roslyn's git branches instead of C# versions.
  • The combined power of F# and C#
    10 projects | news.ycombinator.com | 7 Aug 2023
  • TypeScript 5.2's New Keyword: 'using'
    18 projects | news.ycombinator.com | 19 Jun 2023
    Your code is destructuring two properties and discarding one of them. It doesn't work with a single property: https://sharplab.io/#v2:C4LgTgrgdgNAJiA1AHwAICYAMBYAUBgRj2Nw...

    I think that records don't generate a deconstruct method when they only have one property, but even if you manually define one you'll get an error on `var (varName) = ...`

  • Tips for entry-level .net developer?
    2 projects | /r/dotnet | 2 Jun 2023
    - LinqPad is great and I love, but, IMO, it is not the best tool to start with. It does not provide intellisense or debugger in the free version. Assuming you do not want to pay for this licence just to play a little with the language, I'd suggest https://sharplab.io/. It is not as powerfull as LinqPad, but at least it gives you suggestions.
  • Running a XUnit test with C#?
    3 projects | /r/csharp | 28 May 2023

What are some alternatives?

When comparing MapStruct and SharpLab you can also consider the following projects:

ModelMapper - Intelligent object mapping

JITWatch - Log analyser / visualiser for Java HotSpot JIT compiler. Inspect inlining decisions, hot methods, bytecode, and assembly. View results in the JavaFX user interface.

JMapper Framework - Elegance, high performance and robustness all in one java bean mapper

Roslyn - The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.

Orika - Simpler, better and faster Java bean mapping framework

.NET Runtime - .NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.

Dozer - Dozer is a Java Bean to Java Bean mapper that recursively copies data from one object to another.

BenchmarkDotNet - Powerful .NET library for benchmarking

Selma - Selma Java bean mapping that compiles

interactive - .NET Interactive combines the power of .NET with many other languages to create notebooks, REPLs, and embedded coding experiences. Share code, explore data, write, and learn across your apps in ways you couldn't before.

record-builder - Record builder generator for Java records

csharplang - The official repo for the design of the C# programming language