pauliunas
Posts: 41
Joined: Mon Feb 26, 2018 7:43 am

.NET Core - Raspbian or Win10IoT?

Mon Feb 26, 2018 8:02 am

I would like to run a web-enabled application on Raspberry Pi 3. The application should also be able to interface with the GPIO pins. Will .NET Core work for this, or should I choose a different runtime? I like C#/.NET because it's object oriented and works very nicely for web enabled stuff, but I'm worried it might not have a decent GPIO library. And also about the performance - I assume Windows 10 IoT Core would run it faster, right? Or is it still slow and you would recommend a different language?

Heater
Posts: 9463
Joined: Tue Jul 17, 2012 3:02 pm

Re: .NET Core - Raspbian or Win10IoT?

Mon Feb 26, 2018 8:45 am

What do you mean "web enabled" ?

Is this to be a web server or a client?

I do all this kind of thing in node.js because it makes all that "web enabling" very easy. Especially when using the express.js module to create HTTP servers and socket.io for websocket connections (client and server).

Interfacing to GPIO and other things on the Pi is also very easy in node.js.

As for performance. Despite being an interpreted language it is pretty quick. I can get node.js programs to run at the same speed as compiled C with compiler optimizations turned off. Plenty good enough for many things. No idea how it compares to C#

pauliunas
Posts: 41
Joined: Mon Feb 26, 2018 7:43 am

Re: .NET Core - Raspbian or Win10IoT?

Tue Feb 27, 2018 6:32 am

Heater wrote:
Mon Feb 26, 2018 8:45 am
What do you mean "web enabled" ?

Is this to be a web server or a client?

I do all this kind of thing in node.js because it makes all that "web enabling" very easy. Especially when using the express.js module to create HTTP servers and socket.io for websocket connections (client and server).

Interfacing to GPIO and other things on the Pi is also very easy in node.js.

As for performance. Despite being an interpreted language it is pretty quick. I can get node.js programs to run at the same speed as compiled C with compiler optimizations turned off. Plenty good enough for many things. No idea how it compares to C#
It would act as a web server. I'm not yet sure how I would implement it, but probably it would have an HTML user interface accessible through a web browser on another computer. Or perhaps I would make a native UI and use simple REST calls to get data from the web app, which would load the RPi a bit less.

I've heard good stuff about node.js, but I'm reluctant to learn a new language because I'm already experienced in .NET and I think I can make a good use of it here.

ghans
Posts: 7769
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: .NET Core - Raspbian or Win10IoT?

Tue Feb 27, 2018 7:25 am

How is .NET core different from the .NET running on Windows Desktops ? The latter is supported via Mono on Raspbian.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

Heater
Posts: 9463
Joined: Tue Jul 17, 2012 3:02 pm

Re: .NET Core - Raspbian or Win10IoT?

Tue Feb 27, 2018 9:11 am

It would act as a web server. I'm not yet sure how I would implement it, but probably it would have an HTML user interface accessible through a web browser on another computer. Or perhaps I would make a native UI and use simple REST calls to get data from the web app, which would load the RPi a bit less.
Personally I think the web browser interface is the way to go. All that HTML/CSS/Javascript is a bit of handful to when one has the hang of it the browser make creating nice GUI's a lot easier.

Also your resulting GUI is not platform specific like a native implementation would be. Use it Mac, Linux, Windows, iOS, Android whatever.
I've heard good stuff about node.js, but I'm reluctant to learn a new language because I'm already experienced in .NET and I think I can make a good use of it here.
I do understand the reluctance to learn yet another language. But if you are going to create a non-trivial GUI in the browser you are going to need to learn Javascript. Using Javascript under node.js for the server end ends as well ends up being very easy and convenient.

Besides, despite what people say, JS is a rather different and sophisticated language that has always had advanced (and useful) features that other languages have only recently started to acquire. It's event driven programming model makes that server side code a lot easier to deal with.

pauliunas
Posts: 41
Joined: Mon Feb 26, 2018 7:43 am

Re: .NET Core - Raspbian or Win10IoT?

Tue Feb 27, 2018 8:55 pm

ghans wrote:
Tue Feb 27, 2018 7:25 am
How is .NET core different from the .NET running on Windows Desktops ? The latter is supported via Mono on Raspbian.

ghans
Oh, it's different :)

On Windows desktops, you usually see .NET Framework. That is the full stack of .NET functionality. But it only works on Windows.

Mono is an open source cross-platform port of .NET Framework, but it still lags behind both in functionality and in speed. It might have enough functionality for what I need, butI couldn't just use the same .NET Web Application template in Visual Studio as I do for Windows and expect it to just work. I could look into that but there's an easier way:

.NET Core is a smaller subset of .NET Framework, omitting all the UI code and platform specific stuff. It's also an open source cross-platform port, but it comes from Microsoft, so it's easier to work with. Just for example, Visual Studio has templates specifically for .NET Core, so I don't need to worryabout implementing HTTP on it. Without those templates, I would either need to use a 3rd party library with poor documentation, or implement everything from naked sockets up.

Actually, .NET Core was specifically designed for web applications, so it's perfect for what I'm doing. Although, I still need to figure out how it would work with GPIO. Maybe there's a library for that.

To make things even more complicated, there's the .NET Standard which is somewhere in the middle between .NET Framework and .NET Core. I think it runs on more than Windows, but I'm not sure about that. It's a subset of .NET Framework, but has more functionality than .NET Core. Its core strength seems to be that it runs faster than Framework... I don't really know much about it, but it surely makes things more confusing.

Now the question is whether I should run Linux or Windows IoT core on it... I can't find any performance comparisons, so I thought maybe someone on this forum could share their experience.

pauliunas
Posts: 41
Joined: Mon Feb 26, 2018 7:43 am

Re: .NET Core - Raspbian or Win10IoT?

Tue Feb 27, 2018 9:13 pm

Heater wrote:
Tue Feb 27, 2018 9:11 am
It would act as a web server. I'm not yet sure how I would implement it, but probably it would have an HTML user interface accessible through a web browser on another computer. Or perhaps I would make a native UI and use simple REST calls to get data from the web app, which would load the RPi a bit less.
Personally I think the web browser interface is the way to go. All that HTML/CSS/Javascript is a bit of handful to when one has the hang of it the browser make creating nice GUI's a lot easier.

Also your resulting GUI is not platform specific like a native implementation would be. Use it Mac, Linux, Windows, iOS, Android whatever.
I've heard good stuff about node.js, but I'm reluctant to learn a new language because I'm already experienced in .NET and I think I can make a good use of it here.
I do understand the reluctance to learn yet another language. But if you are going to create a non-trivial GUI in the browser you are going to need to learn Javascript. Using Javascript under node.js for the server end ends as well ends up being very easy and convenient.

Besides, despite what people say, JS is a rather different and sophisticated language that has always had advanced (and useful) features that other languages have only recently started to acquire. It's event driven programming model makes that server side code a lot easier to deal with.
It seems like you misunderstood me a little bit.

Regarding GUI: I won't be accessing this from anything but Windows, because I don't even use anything else. Except my phone, but it wouldn't be practical to use it in this scenario.

Regarding JS: I know Javascript, I've programmed websites, both front and back end, although never with Node.JS. Since I'm not a web developer, and not planning to be one, Node.JS seems very redundant to me. I do know the underlying language, but I would still need to learn the API, wouldn't I? I don't know how big or complicated it is, but I've heard people refer to Node.JS as a separate skill from just Javascript. Furthermore, I'm not fond of Javascript and I'm not planning to use it even if I decide to have an HTML front end. I don't see why I would need it. I mean, this project is not supposed to have a good looking front end - the whole UI would be just for my personal use and it will be just a bunch of text. I will probably only use Javascript for live updating text, but that's really minimal usage.
I just don't like languages that aren't strongly typed. C# is strongly typed, object oriented and that isn't duct taped on top of something (e.g. C++ is technically object oriented, but the object oriented bit of it is duct taped on top of C, so it doesn't make much sense). So I would like to stick to that, because it's pleasant to code with it. I mean, after all this is a hobby project :)

By the way, C# had events long time ago, so I don't see this as advantage of Javascript. If you were comparing it to something like C, it would be an advantage, although at the cost of speed.
Last edited by pauliunas on Tue Feb 27, 2018 9:18 pm, edited 1 time in total.

Heater
Posts: 9463
Joined: Tue Jul 17, 2012 3:02 pm

Re: .NET Core - Raspbian or Win10IoT?

Tue Feb 27, 2018 9:17 pm

pauliunas,
Actually, .NET Core was specifically designed for web applications, so it's perfect for what I'm doing. Although, I still need to figure out how it would work with GPIO. Maybe there's a library for that.
Or you could just use node.js, which is designed for web applications and so perfect for what you are doing.

Working with GPIO, or serial ports, SPI, I2C etc is no problem from node.js.
Now the question is whether I should run Linux or Windows IoT core on it...
I'm not sure why that is even a question in 2018.

Open Source is always preferable to closed if it gets the job done.

You will find the most community support for your Linux efforts.

All the worlds web runs on Linux, so why not you?
I can't find any performance comparisons, so I thought maybe someone on this forum could share their experience.
Why the emphasis on performance?

Are you really expecting thousands of users on your Pi based web server at the same time? If so it's probably time to think about a different machine or creating a cluster of servers on multiple Pi with load balancing.

node.js can hold it's head up with C# when it comes to web serving. I suspect you would be hard pressed to spot the difference.

pauliunas
Posts: 41
Joined: Mon Feb 26, 2018 7:43 am

Re: .NET Core - Raspbian or Win10IoT?

Tue Feb 27, 2018 9:28 pm

Heater wrote:
Tue Feb 27, 2018 9:17 pm
pauliunas,
Actually, .NET Core was specifically designed for web applications, so it's perfect for what I'm doing. Although, I still need to figure out how it would work with GPIO. Maybe there's a library for that.
Or you could just use node.js, which is designed for web applications and so perfect for what you are doing.

Working with GPIO, or serial ports, SPI, I2C etc is no problem from node.js.
Now the question is whether I should run Linux or Windows IoT core on it...
I'm not sure why that is even a question in 2018.

Open Source is always preferable to closed if it gets the job done.

You will find the most community support for your Linux efforts.

All the worlds web runs on Linux, so why not you?
I can't find any performance comparisons, so I thought maybe someone on this forum could share their experience.
Why the emphasis on performance?

Are you really expecting thousands of users on your Pi based web server at the same time? If so it's probably time to think about a different machine or creating a cluster of servers on multiple Pi with load balancing.

node.js can hold it's head up with C# when it comes to web serving. I suspect you would be hard pressed to spot the difference.
Nah, I don't give a damn about open source :) It just doesn't matter. I actually think proprietary code is often more well maintained, but let's not spark a debate here, I didn't come for that.

Why are you trying to push Node.JS so hard? The things you said about Node.JS vs C# can be easily flipped upside down by just switching C# and Node.JS in places... .NET Core was designed for web apps and it's perfect. I don't understand why you want me to learn a new language lol...

I sort of prefer Windows IoT because it's just simpler to use. Linux is overcomplicted, and it runs many background services that I don't need. It's a desktop OS. But Windows IoT is down to the basics OS that is designed for running one application and nothing else. Well, except those services that are necessary to run that application. That makes it easy to set up and fast. Or at least so I think, but I can't find anything about the performance.

Regarding performance: let me make it clear, it's NOT a web server and it will NOT be hosting a website. If I wanted a website, I would just install LAMP and use good old PHP. But I don't. The web service is just a small part of my plan and it will only serve as a GUI. I wouldn't include a web service in my plan at all, but I want a GUI and the RPi won't have a screen attached to it. So the only way to have it is a web interface.

pauliunas
Posts: 41
Joined: Mon Feb 26, 2018 7:43 am

Re: .NET Core - Raspbian or Win10IoT?

Tue Feb 27, 2018 9:38 pm

By the way, to make it clear, I'm not discussing the speed of delivering web pages, it doesn't matter to me. When I say performance, I mean overall performance, not web page delivery. I'm referring to the remaining part of my application that will be interfacing GPIO pins and doing calculations. In the beginning, I won't need great performance, but I'm planning to expand and I don't want to hit a wall because I chose the slower OS...

ghans
Posts: 7769
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: .NET Core - Raspbian or Win10IoT?

Wed Feb 28, 2018 10:14 am

I doubt Windows 10 IoT is faster. Raspbian has better driver support. Windows IoTCore seems slow to boot, too. Win10IoTCore on the Pi seems very much a marketing gimmick. Everytime you hit a wall (camera, 3D, video, lag) you'll get told "for serious applications consider the DragonBoard 410c instead".

Don't forget that the BSP for the Pi was written by Microsoft against their own better judgement and official dogma that OEMs and only OEMs shall write BSPs, not third parties or Microsoft. They've open-sourced it though.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

pauliunas
Posts: 41
Joined: Mon Feb 26, 2018 7:43 am

Re: .NET Core - Raspbian or Win10IoT?

Wed Feb 28, 2018 3:45 pm

ghans wrote:
Wed Feb 28, 2018 10:14 am
I doubt Windows 10 IoT is faster. Raspbian has better driver support. Windows IoTCore seems slow to boot, too. Win10IoTCore on the Pi seems very much a marketing gimmick. Everytime you hit a wall (camera, 3D, video, lag) you'll get told "for serious applications consider the DragonBoard 410c instead".

Don't forget that the BSP for the Pi was written by Microsoft against their own better judgement and official dogma that OEMs and only OEMs shall write BSPs, not third parties or Microsoft. They've open-sourced it though.

ghans
Hey, thanks for your insight. Seems like Linux wins, then. Just out of curiosity, I'm planning to run a little benchmark program I wrote on both environments. It's not a specialized benchmark, but I had to do some stuff for university and that thing can take hours to complete with larger input, so it's solid enough benchmark for me :) I just want to see how big the difference is, or maybe I'll even prove you wrong unintentionally. I'll post the results here once I find time for doing it.

Heater
Posts: 9463
Joined: Tue Jul 17, 2012 3:02 pm

Re: .NET Core - Raspbian or Win10IoT?

Thu Mar 01, 2018 8:08 pm

pauliunas,
Why are you trying to push Node.JS so hard?
A very good question.

Probably it's because your opening post asked:

"I would like to run a web-enabled application on Raspberry Pi 3. The application should also be able to interface with the GPIO pins."

I have played and worked with all kind of languages since 1976, from Algol to Z. Passing through BASIC, Coral, PL/M, Ada, C/C++, Java, Javascript, Lua, LUCOL, C#, Erlang, Scala, Verilog, VHDL along the way. And perhaps some I don't even remember.

I was amazed to find some years ago that the often looked down on, stupid "scripting" language, Javascript is actually a very good, easy to use, performant system to deal with web-enabled applications and fiddling with GPIO pins and other interfaces.
The things you said about Node.JS vs C# can be easily flipped upside down by just switching C# and Node.JS in places.
Actually I don't think so. We would both have to present our code in C# and JS to prove the point though.
...but I had to do some stuff for university and that thing can take hours to complete with larger input, so it's solid enough benchmark for me
Ah, now you have changed your tune. Now your question is not about a "web-enabled application" or even "interface with the GPIO pins". It's about big time calculation.

As such I might suggest using C++. Or some other compiled language.

As much as it seems I "push" node.js, I do think one should choose the tool to fit the job.

pauliunas
Posts: 41
Joined: Mon Feb 26, 2018 7:43 am

Re: .NET Core - Raspbian or Win10IoT?

Thu Mar 01, 2018 8:31 pm

Heater wrote:
Thu Mar 01, 2018 8:08 pm
pauliunas,
Why are you trying to push Node.JS so hard?
A very good question.

Probably it's because your opening post asked:

"I would like to run a web-enabled application on Raspberry Pi 3. The application should also be able to interface with the GPIO pins."

I have played and worked with all kind of languages since 1976, from Algol to Z. Passing through BASIC, Coral, PL/M, Ada, C/C++, Java, Javascript, Lua, LUCOL, C#, Erlang, Scala, Verilog, VHDL along the way. And perhaps some I don't even remember.

I was amazed to find some years ago that the often looked down on, stupid "scripting" language, Javascript is actually a very good, easy to use, performant system to deal with web-enabled applications and fiddling with GPIO pins and other interfaces.
The things you said about Node.JS vs C# can be easily flipped upside down by just switching C# and Node.JS in places.
Actually I don't think so. We would both have to present our code in C# and JS to prove the point though.
...but I had to do some stuff for university and that thing can take hours to complete with larger input, so it's solid enough benchmark for me
Ah, now you have changed your tune. Now your question is not about a "web-enabled application" or even "interface with the GPIO pins". It's about big time calculation.

As such I might suggest using C++. Or some other compiled language.

As much as it seems I "push" node.js, I do think one should choose the tool to fit the job.
you're wrong. It's not only about performance, it's not only about web or gpio. It's about all three of those things. And that's why I choose C#. It's reasonably fast, easy to write web apps with, has one-method way of interfacing with GPIO. It ticks all the boxes, so I don't see why I should choose another language that I just don't like working with. Or C++ that doesn't tick the "easy to write web apps with" box.
So no, I didn't change my tune, I just want to use a language that gets the job done. Not interested in languages that are "better" but only for part of the job, or ones that aren!t any better than what I chose...

Heater
Posts: 9463
Joined: Tue Jul 17, 2012 3:02 pm

Re: .NET Core - Raspbian or Win10IoT?

Thu Mar 01, 2018 9:06 pm

pauliunas,

Wrong?

Perhaps, I was only offering a tentative, viable suggestion given the vague requirement you originally posted.

Clearly you have chosen C# to be the rock you will use to crack whatever nuts you have.

In the face of all this new information it's impossible to make out exactly what you asked in the first place.

Do remember, people out on the net, like me, cannot know what you are really thinking. Only what you write in the limited space of a forum post.

For example, you have not stated exactly what the job is that you want to get done.

pauliunas
Posts: 41
Joined: Mon Feb 26, 2018 7:43 am

Re: .NET Core - Raspbian or Win10IoT?

Thu Mar 01, 2018 9:59 pm

Heater wrote:
Thu Mar 01, 2018 9:06 pm
pauliunas,

Wrong?

Perhaps, I was only offering a tentative, viable suggestion given the vague requirement you originally posted.

Clearly you have chosen C# to be the rock you will use to crack whatever nuts you have.

In the face of all this new information it's impossible to make out exactly what you asked in the first place.

Do remember, people out on the net, like me, cannot know what you are really thinking. Only what you write in the limited space of a forum post.

For example, you have not stated exactly what the job is that you want to get done.
What "new information"? Please read my original post again, it's not "vague" in any way, and ALL the requirements were mentioned there. All I did afterwards was narrow down the definition of "performance" because it was ambiguous.

And remember, people online like me expect you to read my post before replying. Fully. And not to blame me for not saying something when I actually said all you need to know.

Heater
Posts: 9463
Joined: Tue Jul 17, 2012 3:02 pm

Re: .NET Core - Raspbian or Win10IoT?

Fri Mar 02, 2018 7:09 am

pauliunas,

Oh I read everything...

Your opening post asks about "a web-enabled application on Raspberry Pi 3. The application should also be able to interface with the GPIO pins."

You mention performance in passing, but as you want to use C# one can assume that perfrmance is not a primary requrment.

Your OP is indeed vague and open ended.

You OP also asks "would recommend a different language?". However when suiable alternatives are proposed it turns out you are not open to suggestions.

Later you offer new information like so "...a specialized benchmark..can take hours to complete with larger input, so it's solid enough benchmark for me". That is a big change in emphasis from simple a web-enable program that can tweak GPIO pins to something that apparently has to do a lot of calculation and needs performance.

Anyway, you have made up your mind so good luck with your project may it be a success.

pauliunas
Posts: 41
Joined: Mon Feb 26, 2018 7:43 am

Re: .NET Core - Raspbian or Win10IoT?

Fri Mar 02, 2018 7:14 am

Heater wrote:
Fri Mar 02, 2018 7:09 am
pauliunas,

Oh I read everything...

Your opening post asks about "a web-enabled application on Raspberry Pi 3. The application should also be able to interface with the GPIO pins."

You mention performance in passing, but as you want to use C# one can assume that perfrmance is not a primary requrment.

Your OP is indeed vague and open ended.

You OP also asks "would recommend a different language?". However when suiable alternatives are proposed it turns out you are not open to suggestions.

Later you offer new information like so "...a specialized benchmark..can take hours to complete with larger input, so it's solid enough benchmark for me". That is a big change in emphasis from simple a web-enable program that can tweak GPIO pins to something that apparently has to do a lot of calculation and needs performance.

Anyway, you have made up your mind so good luck with your project may it be a success.
Yes, I asked for another language, but read the whole sentence. You just pulled it out of context. I asked for another language IF you think C# is too slow in both ways.

I'm open to suggestions, but I refused Node.JS trice and you still kept pushing it. It's time to cut it off. As for C++, it just doesn't work for what I'm doing.

And I don't see ANYTHING "new" in that post about benchmark. Everything was said in OP. I just added that I have a way to test it now.

Heater
Posts: 9463
Joined: Tue Jul 17, 2012 3:02 pm

Re: .NET Core - Raspbian or Win10IoT?

Fri Mar 02, 2018 7:42 am

pauliunas,

The new thing that came to light as this thread proceeds is the emphasis on performance. Which of course is vague in itself, performance at doing what? Measured how?

I certainly would not suggest JS if you have lengthy calculations to do in a hurry. Then again I would not suggest C#, Java, Python etc either.

You don't like C++. Which I can sympathise with, it's a nightmare of complexity that nobody understands anymore.

What does that leave us to consider? Go, Ada, Rust?

Bottom line is that there are no details here of what it is you actually want to do so it's only possible to make very general, speculative suggestions.

pauliunas
Posts: 41
Joined: Mon Feb 26, 2018 7:43 am

Re: .NET Core - Raspbian or Win10IoT?

Fri Mar 02, 2018 8:16 am

Heater wrote:
Fri Mar 02, 2018 7:42 am
pauliunas,

The new thing that came to light as this thread proceeds is the emphasis on performance. Which of course is vague in itself, performance at doing what? Measured how?

I certainly would not suggest JS if you have lengthy calculations to do in a hurry. Then again I would not suggest C#, Java, Python etc either.

You don't like C++. Which I can sympathise with, it's a nightmare of complexity that nobody understands anymore.

What does that leave us to consider? Go, Ada, Rust?

Bottom line is that there are no details here of what it is you actually want to do so it's only possible to make very general, speculative suggestions.
Nope, nothing new. I never said performance was crucial, I just said I want it to be as fast as possible because that's always a good thing. Better performance => less CPU load, less heat, less energy consumption. You seem to be very keen on offering me another language. Please don't. I chose C# and I made it clear in the OP. I only asked for another language suggestion if it's significantly faster than .NET Core but still offers the same ease of use for web apps. You don't seem to have any of that in mind, so let's just leave it as it is, please. If you come up with a suggestion that ticks all the boxes, please share it, I'll be glad to hear. But overall, performance is just a second thought here. It's "nice to have" more than a requirement.

Heater
Posts: 9463
Joined: Tue Jul 17, 2012 3:02 pm

Re: .NET Core - Raspbian or Win10IoT?

Fri Mar 02, 2018 8:33 am

pauliunas,
If you come up with a suggestion that ticks all the boxes, please share it, I'll be glad to hear.
I did already, and you have rejected it.

Fair enough, there are many ways to skin cats and you have your own prefered way, as we all do.

Clearly you don't want to provide any more detail about exactly what it is you want to do so this thread come so the end of the road.

Once again, good luck with your project.

pauliunas
Posts: 41
Joined: Mon Feb 26, 2018 7:43 am

Re: .NET Core - Raspbian or Win10IoT?

Fri Mar 02, 2018 12:40 pm

Heater wrote:
Fri Mar 02, 2018 8:33 am
pauliunas,
If you come up with a suggestion that ticks all the boxes, please share it, I'll be glad to hear.
I did already, and you have rejected it.

Fair enough, there are many ways to skin cats and you have your own prefered way, as we all do.

Clearly you don't want to provide any more detail about exactly what it is you want to do so this thread come so the end of the road.

Once again, good luck with your project.
None of your suggestions ticked all the boxes. C++ is hard to program, node.js isn't any faster. I don't remember you suggesting anything else.

And this whole discussion is not what my thread is all about, so for whoever else might be reading it, let me get it back on track:

I wanted to know which OS would be more suitable for running a .NET Core app. Currently, Linux seems to be winning, but I'll do a benchmark. I'm also open to other language options if they easily match the requirements in OP and are significantly faster than .NET Core/C#.

rballonline
Posts: 1
Joined: Fri May 04, 2018 6:41 pm

Re: .NET Core - Raspbian or Win10IoT?

Fri May 04, 2018 6:47 pm

Heater, holy crap you have the patience of a saint. I came here wondering about .NET Core 2 performance on the Pi as I also use it for work and thought it would be nice to use those skills elsewhere.

After reading through your very helpful posts I'd come to the same conclusion as you. This other guy is just being as lazy as possible, which is funny because I'm sure he's jumping through hoops in order to get things done. Amazing that someone that knows nothing about what they are doing is challenging so hard against someone that has the experience and is basically telling someone, sure you could probably do it that way, but this is freaking easy, so why would you do that?

Either way, I got something out of it: Use .net core if you want a challenge, but just use Node and JS if you want to get stuff done. I also know very little about Node but this seems like a great learning opportunity. Sounds pretty simple. Thanks!

creativeprojects
Posts: 1
Joined: Fri May 18, 2018 3:42 pm

Re: .NET Core - Raspbian or Win10IoT?

Fri May 18, 2018 5:01 pm

Hey!

I was also considering developing on the raspberry pi using dotnet Core 2.0. The same reason being that I'm already using C# at work, and I do like it.
And to be honest, I don't really understand the fuss about Python. I'm probably missing something, but as a beginner I'm already stuck with incompatible versions and libraries, and a complete nightmare to handle virtual environments and things. I keep wanting to get into it once for good, but there's always something that put me off :)

Anyway, I wasn't thinking about nodeJS. I find javascript very difficult (and so ugly) if you want to make a maintainable application and not just a small script. Fortunately there's typescript now, and it works well to make a readable and maintainable application with nodeJS. So why not?

Anyway, for that matter I thought I could try a very simple piece of code on each language and see the difference in real.

For my experiments, I was using a diskless Raspberry pi 3 B (the original 1.2 GHz) booted from network (bootp/nfs) (not that it should make any kind of difference). All tests were run 3 times, to be sure nothing was happening in the background. And each time, the results were extremely close.

The code is voluntarily extremely simple: there's no string comparison, no arrays, no lists, no memory allocation, only very simple additions and subtractions. This way, most of the time is spent on the overhead around your code. Well, should do, right?

Here's the code in C:

Code: Select all

int main()
{
    int max = 2147483637;
    int count = 0;
    while (count < max)
    {
        count += 10;
        count -= 9;
    }
    return 0;
}
As you can see, there's really nothing.
So I made a version in pure C as a comparison (sorry no ASM, I don't know much about ARMs).
Then I made a version in dotnet Core 2.0 (cross-compiled from the mac), a version in NodeJS, a version in PHP (because why not? the perfs should be similar to Python after all?), and a version in Python. I'll post a link to the code if you're really interested.

Anyway, as for the results, in order of speed (but not in order of coolness):

C (compiled directly on the Pi with the default cc 6.3.0-18+rpi1+deb9u1)
Time elapsed was 21.6s

C# .net Core 2.0 (cross-compiled from 2.1.200 SDK)
Time elapsed was 32.8s

NodeJS 8.11.2 (binary from nodesource)
Real time 2m 55.8s (but total user time was 3m 39.6s)

A bit of explanation: the time command in unix is returning the real time, the "user" time, and the "system" time. Only the real time is interesting here, but in the case of NodeJS the user time being higher than the real time is a funny one. It means that NodeJS is heavily multi-threaded, and seriously I'm not sure how you can multi-thread such a simple piece of code. So it's probably doing a lot in the background. Maybe doing all its magic of being clearly the fastest of the interpreters.

PHP 7.0.27 (default binary in Raspbian)
7m 19s

Python (default python 3 on the Pi: 3.5.3)
74m 16.s (I am not joking!)

The clear winner is C (and that's not a surprise), closely followed by C#, and that is quite a surprise. The dotnet Core team did a fabulous job with their new compiler!

I was also most impressed by NodeJS which is the fastest interpreter of the tests.

The complete loser is definitely Python! I know I'm going to get flamed for it, and you're going to tell me there are plenty of other Python interpreters to use on the market, and you would probably be right. But I'm not a Python expert, and I wasn't going to spend more time to install them all. Now if you want to do it to prove me wrong, be my guest. The algorithm is extremely simple ;)

Also, I did run the experiment on my 10 years old Intel Core i7, and the results were proportionals, except for the C version which was lightning fast. I take that all the code was sitting in the internal cache of the CPU.

Fred

pauliunas
Posts: 41
Joined: Mon Feb 26, 2018 7:43 am

Re: .NET Core - Raspbian or Win10IoT?

Fri May 18, 2018 6:01 pm

I really appreciate your effort :) it's nice to have some real results. Although I'd prefer something closer to the real world, including string manipulation, some simple web sockets etc.
This test basically evaluates the speed of just one command, but in fact we're interested in other things too, for example memory allocation.

And I wasn't really surprised by C#, I knew it was fast. I mean it never was really slow, except the UI code that was slowing down .NET Framework. .NET Core doesn't have any of that so I was actually expecting it to come close to C in simple operations like this one. I think it might be slightly more behind if you add memory allocation, because of object instantiation, ref counting, garbage collector etc. that C doesn't have.

Now I'm interested in seeing whether Linux or Windows IoT runs .NET Core apps faster. I've modified one of my university algorithm assignments to not print anything to the console and display the time it took to solve a data set instead, I've even ran it multiple times on Linux to get some numbers... but then my micro SD card refused to boot Windows IoT so that had to be put away.. and now it will have to wait even longer because I have the exams right on my nose.

Return to “Other programming languages”

Who is online

Users browsing this forum: No registered users and 4 guests