Some questions regarding implementation of a scripting engine - c#

Since this would be hard to explain, let me start with a Diagram:
So much for the theory, but how would I actually implement this? Is this even possible/feasible?
Some questions that come to mind:
How would I actually load the scripts into Objects for the ScriptManager to hold?
How do I expose certain functionality? I don't want them to have ultimate power over my program, only one Domain.
How would the scripts even know about for example EngineClass? Should I do a using in the scripts? Wouldn't that require to be copy of the assembly in the script path?
I heard about MEF, is this possible? It seems more fitting for plugins.
How do I even compile the scripts?
Of couse I understand you can't answer all of those or implement the whole engine for me. But I need pointers on what to do, I've been banging my head on this concept for a long time.
Thanks in advance for any answers.

After some more researching I stumbled upon What is the best scripting language to embed in a C# desktop application? and http://blogs.msdn.com/b/abhinaba/archive/2005/11/14/492458.aspx and it seems to do what I want with some modifications. How I didn't stumble on this the weeks before I don't know.

Related

Unity: Do I have to learn one, or both (C#, UnityScript) [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
I originally thought that one had to know both C# as well as UnityScript to develop using Unity. But it now seems that I only need to know one. So,
Do both the languages do similar things and hence I should code in one, or should I learn them both as I'm supposed to use both?
Does Unity only use C# and/or UnityScript cuz I always thought games had to use at least 2, even in Wikipedia, it's written as if it's a definition or something. (I know some games can be made solely using pygame and stuff, but I mean things like AAA titles).
Continuing from 2 Or is it that you do use more than just C# and/or UnityScript in case of using Unity, and Unity is only for certain parts of the game?
"unityscript" is deprecated.
You must use c#. It's that simple.
From my very limited development in Unity:
It's an either or thing.
I've written quick test-of-skill games using only C# as I'm more familiar with it from previous knowledge of C and C++. While reading the docs to decide whether or not I would try to port code over to the UnityScript code (again, as a test of skill), it became my understanding that either way you get the end result you want.
In these games I wrote all sorts of components, including UI, game object, terrain collision, even fiddling with jumping and the gravity engine. Never once did I have to stop and go "well darn. Looks like I need to use Unity Script for this."
Games in Unity, as far as I am aware, can use both. But I've never been forced into having to use one or the other.
If you ever run into a part where Unity forces you to use both, go ahead and come back to this post to yell at me.
You can pretty much use whichever language you're most comfortable with. There will be the odd asset that uses one language when you prefer another. If you want to use and tweak the functionality of that asset, you'll need to do so in their language.
The scripts work in tandem and both can exist within a given project at the same time. Doing this can get messy as evidenced by this issue:
Unity3d: Accessing JS variable from c# and vice versa
I believe some of the basic freely available assets are in UnityScript such as the character controller. If you're planning to use one of these heavily and will need to communicate with those scripts regularly, it may inform your language decision. Hope this helps.
Too many question in a single post, well try to provide answer accordingly.
Do both the languages do similar things
Answer: In Programming, Theoretically, mathematically, strictly, yes. They're all equivalent.
In practice, no, they vary fairly wildly. ref
I should code in one, or should I learn them both as I'm supposed to
use both?
Answer: I would say it depends very much on your past experience. If your background is in C++ or Java, you will likely feel most at home in C# - however if you're experienced with dynamically typed languages such as JavaScript / Basic or PHP, chances are you will prefer JavaScript.
If you have no previous experience with programming - JavaScript might be an easier introduction - given that you do not need to worry about types and casting.ref
Does Unity only use C# and/or UnityScript cuz I always thought games
had to use at least 2
Answer: absolutely not mandatory, much depends upon you expertise, requirement, teams strength and management.
Unity is only for certain parts of the game?
Answer: Absolutely yes, unity allow you to build, do lighting and provide some particle effects(if require). it not allow you complex modelling it provide interface to programming even mono-developer is a separate application.
helpful links:
https://gamedev.stackexchange.com/questions/8118/what-are-the-pro-cons-of-unity3d-as-a-choice-to-make-games
https://www.quora.com/What-are-the-main-pros-and-cons-of-Unity-3D-and-Unreal-Engine
To be honest, if you want to be freer when you want to write your script in game you should learn c# cause it's based on that but if you are new to writing scripts I can recommend using bolt which is visual scripting and you can get the whole idea behind what codes do.
I did this and it helped me to get some ideas about scripting but now I'm trying to write it with c# cause its crucial and c# is much much easier than most other languages
After all, you should choose one which you feel more comfortable with.
and don't forget to use some of the unity ready-project that would help much more than you can think and check their code as well.

Build script with C#

For insight into the below, read: http://martinfowler.com/articles/rake.html
I've been using Rake (with Albacore) recently, and like it alot. Mostly the strength of having the Ruby language right at hand when I need it.
I must admit I am alot more at home with C# - and that lead me to thinking if there was an equivalent to Rake in the .NET world.
What I am looking for is a way to write build scripts in C#, or maybe a DSL, having the same dependency programming model, where I can also use C#.
Maybe I'm way off base asking this question. But if it's possible to do with Ruby (and an internal DSL), then I can't right off the bat say why the same wouldn't be possible for C#. And I certainly don't understand why it hasn't already been done :-)
Anyone have some perspectives on the issue?
What we already know:
C# needs to be compiled to run, so we would need to create a seperate build-script, that is parsed, and compiled at run-time by an executable.
Thanks in advance!
Solution
Use "Cake" http://cakebuild.net/ -- with Roslyn compiler what I wanted (years ago) is now possible. Thanks Microsoft. And thanks to the people who wrote Cake.
An alternative is to use Powershell. The library is called Psake (saké)
Maybe Cake is what you're looking for: https://github.com/cake-build/cake
A lot of people do use Rake for build scripts. There are even Rake tasks just for .NET. http://albacorebuild.net/
But there is a c# based make utility I know about. http://shake.codeplex.com/ And I thought I saw one on github. But I think they require a compile and that didn't seem as cool.
I ended up on https://github.com/psake/psake mainly because I wanted to learn Powershell and everyone already had it installed.
Hmm Bounce too https://github.com/refractalize/bounce
You can script your build/deployment tasks with msbuild and then script your tasks and execute them from bat files.

Starting wxWidgets C++ need a gentle nudge

So I've been learning C# for like a year now (I'm 20 years old) and I'm getting pretty confident with it. I've also been meddling with C++ every now and again. For example just recently I've been following the Nehe OpenGL tutorials for C++ and I find it a fun way of learning.
I want to start looking at creating cross platform GUI software after I stumbled across this library called FLTK (fluid something rather). After finally and painfully getting it to work I found it refreshing to know that there are solutions for GUI creation in C++, however I think FLTK looked pretty old.
So I googled around for some newer GUI frameworks and decided to start playing with wxWidgets (decided against Qt because of licensing).
I downloaded it, compiled it, and looked to see if there were any IDE plug-ins for RAD development, as you can imagine going from drag and drop a component onto a form in C# I was hoping for something similar.
I learned that code::blocks has something of the sort so I tried that out. It was alright but the thing that turned me off was the horrible code completion; it would only show members and methods in the current object and nothing for the #included header files. I understand that code completion/IntelliSense isn't easy for C++ but Visual Studio 2008 handles it pretty good. I did find some other RAD tools like wxFormBuilder but it costs money, not something I want to do for simply learning.
So my TLDR question is if anyone has had experience with wxWidgets? Do you just develop in whatever IDE you're comfortable with and just code the GUI? Meaning no visual helpers? Perhaps you could give me a nudge in what direction I should be going :)
Thanks, this is also my first post on this site albeit I have read many threads before that have helped me solve copious problems. Cheers!
My suggestion is to learn how to do GUI layout with wxWidgets in code, then when you get good at it learn how to use the GUI tools.
Doing this kind of work manually for a while gives you the understanding about what you need ("Ok, I need a wxSizer, vertical, to put these two horizontal wxSizers into, where I put my a wxStaticText and a wxTextCtl for each line ...")... where as I think if you started out with the GUI tools you'd just tend to get annoyed because (last time I looked) none of them were Drag And Drop editors like you get with .NET.
Definitely give Code::Blocks another try. It is a WONDERFUL environment to work with wxWidgets in. It comes with a form designer and templates for wxWidgets projects, so I can't imagine working without it.
Also, for a good beginner's introduction to wxWidgets, try this page. It helped me alot when I started with it.
I use wxWidgets without using a drag and drop designer. There are obviously drawbacks to that approach but an advantage is that you don't have any horrible automatically generated code to deal with. In the past I've found having such code in the middle of my project has caused various types of grief - especially if you decide it needs some serious changes it is often necessary to start from scratch because form designers are so much better at "writing" as opposed to "editing".
For simple applications you can assemble a UI using a mixture of customized and standard widgets without too much difficulty. Check out the wxWidgets samples and demos, which use that approach. My chess app (see my website) uses this approach too.
A more elaborate UI could possibly be implemented by writing something special at a higher level of abstraction. The kind of thing I am thinking of would be a subsystem that accepts high level flexible requests to provide different types of user interface functionality, and then sorts out the details of the controls to create and the positioning etc. of those controls itself. That is kind of a technical fantasy of mine but I haven't ever really attempted to do it. Actually, a fairly primitive facility of this type is already available and used by the demos I mentioned; It is called a "Sizer" (class wxSizer) and is basically a control container.
Finally I would point out that problems with the Qt licence have basically gone away since Nokia bought Trolltech and made it "more" free (LGPL licence). Many people think Qt is the way to go these days. I am pretty happy with wxWidgets but will definitely evaluate Qyt seriously one day. Good luck with your projects.
I have developed a number of application GUIs using wxWidgets - you can see screenshots at http://ravenspoint.com/
IMHO, you should distinguish between designing a GUI and implementing it. Expecting to use the same program to design your GUI and to automatically emit all the code to implement the design is expecting too much.
A design program should be fast and simple. I recommend http://www.balsamiq.com/
Once you have settled on the design, then you can turn to the coding. Personally, I find that placing widgets on a panel using the wxPosition and wxSize parameters of the wxWidget constructors to be trivial - easier than trying to nudge widgets into their exact positions using the mouse.
The trouble with using some kind of form builder to emit all the code for a significant GUI is that you end up with a morass of automatically generated code that is hard to find your way around in. If the code has been handwritten, then you already know where everything is located.
wxFormBuilder but it costs money
wxFormBuilder is Free and Open source
Also Visual Studio is best for C++ coding in wxWidgets, but you will run into lots of issues on Linux due to the way Visual Studio handles a lot of things, like file names you have to take extra care for case sensitivity.
Also regarding the GUI, add the wxFormBuilder to the Visual Studio solution, add the file type handler to Visual Studio. Now just double click on it and add your dialogs, like you do it in C#.
Just add the generated code files to the Visual Studio project once and you are done.
It's very easy to use Visual Studio with GUI programming in wxWidgets.
Also don't forget to watch the CodeLite editor if you want to port on Linux. It is very much compatible with the Visual Studio projects and shortcut keys.
There is wxGlade and wxFormBuilder.
I don't know if there is another one, but the wxFormBuilder I know is free and open source.
You will find links to other tools on the homepage
of wxGlade (http:// wxglade.sourceforge.net/).
Most of these programs are able to output xrc files, which are are an XML representation of your GUI. It address the issue of complexity of the generated code but is not as powerful.
Yet personally I don't use any of these tools, except sometimes to see what it's going to look like before I do it but never to actually generate code.
I just finished doing a hello world program in both wx and fltk using the netbeans IDE. Microsoft Visual Studio WinForms or MFC was much easier than either. I needed cross platform capability so I could not use it for this application. I finished fltk in much less time than wx. The program was simpler, smaller, faster, and easier to write. Wx had pretty disjointed documentation and organization. Fltk was designed back in the "old days" when small fast and efficient was valued. That's probably why it seems "old" to you. I'm an old guy so it worked for me. YMMV

Software that every programmer makes [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
I'm looking for a personal project. One of the sort that "every programmer"* makes. The reasoning is that most developers have a tendency to work on personal projects that have particular traits interesting to all other developers. Software like:
Bug trackers (made one)
CMS (made one)
Blog Engines (Haven't made one; don't want to)
UI 'libraries' and graphics 'engines' (often for the game development crowd)
Password management programs
I'm looking to make something
fun
interesting
not particularly challenging (my work is difficult - or obscure enough)
doesn't have to be original by any means
preferably an application (ie. not a website)
not a hardcore learning experience, this is entirely for fun away from work
That being said, I find that the terms 'interesting' and 'challenging' don't necessarily carry the same meaning for developers as they do for other people (and often-times are interchangeable - I'm not looking for something easy or trivial). Ditto with the 'learning' part, I like and want to solve problems, but I'm not going to be getting into design methodologies or learning entirely new APIs and Languages to do this.
I ask because I think that certain projects, or types of projects, appeal to developers for particular reasons. I don't claim to know what those reasons are, nor do I care, but I do understand that they exist and that being a developer, there is a strong likelihood that the projects that are suggested will appeal to me.
If it helps, my background or preferred medium, without reciting my resume, is c# development for windows/tablet pcs; xna; db design/programming;
*by "every", I mean, "lots of".
You have XNA experience, and DB experience.
Develop a visualization tool for databases which is visually attractive and makes mining data easier.
This can start as a simple browsing tool and eventually grow to a full-fledged DB management application.
If you haven't written one, knocking together an implementation of Conway's Game of Life is always an interesting challenge. It's also the sort of project that once you get it done leads to seemingly endless tinkering ("I'll just add one more feature...")
Graphics are always fun to play around with, try writing a program to draw a Sierpiński triangle. It's a fairly simple fractal to generate. I once made a screensaver that drew them in random places and colors on the screen.
If you are looking for something more practical, try writing an email or RSS client. Learning to interact with SMTP/POP3 at low level is pretty interesting. Same thing with RSS, it will expose you to network, GUI, and XML design at a minimum.
Maybe write a compiler? I think every artist/craftsman should, at some point, learn how to build the tools of their art or craft.
Write a character generator for the pen-and-paper rpg of your choice.
It should be able to be used in 2 modes: Build-A-Character (which will let you build a character from scratch) and Generate-An-NPC (which, given some guidelines, will generate a decent NPC).
This is actually a project I've been working on for a while, and I've found it fun. YMMV, especially if you don't game regularly.
Edit - figured I'd give some reasons I find it fun.
It's something I and my friends will actually use
It helps me understand the game better, knowing what decisions make a good character
There's some (limited) AI in the random character generation(mainly a simple decision tree with some random jumps)
It's overall fairly simple, a reasonable project for a one-man development team.
I'm looking for a personal project. One of the sort that "every programmer"* makes.
How about writing your own scripting language interpreter?
That's a very common thing to do, which is usually not only a highly educational experience, but also fun and interesting.
Once you are finished with something working, you'll start thinking completely differently about programming, it will change your way of thinking!
A Sudoku game (or Connect Four, Clue, etc.).
Something that relies mostly on logic, and not artificial intelligence (like chess).
How about a ray tracer? It can be very simple if you do everything by brute force.
They are very fun to write and can lead to many interesting problems. Writing a ray tracer meets all your criteria =)
Each and every developer is different. About three years ago I asked exactly your question on some other site. It brought nothing because we all have different interests.
Maybe to make a website with focus on what you like? Like a small community within a university or your other fellows?
In order to learn Ruby, I just recently made a mini DSL/XML generator for a custom XML based language I use in a program of mine. I simply turn some real text into its XML representation. It was just a fun little side project that didn't provide much benefit in the long run but helped me to learn the language.
So... I suggest trying to create a DSL. The experience could actually prove invaluable as DSL's are pretty damn useful.
Write a 3D environment populated by artificially intelligent virtual beings, implemented on a public server, that we can all access using a WPF-based client.
Personally 'interesting' strongly overlaps 'difficult', so I'm kind of at a loss ...
... but perhaps you should take a non-programming interest you may have and try to solve a simple problem in that space.
A friend of mine once built a model railway database so people could track the trains they had. He was trying to sell it, that didn't go so well, but it was simple and fun.
Why not rolling your own
Web MVC framework or
Web templating system or
Persistence framework (+1 if you make an OR-mapper) or
Interceptor-based aspect-oriented framework
But oh, those were the sins of early 2000's.
Something cloudish then? :)
I had fun programming an audio player (like winamp / WMP) to learn .NET before I started my current job. There are free libraries to read MP3 files (and other audio formats), so that gets the complicated part out of the way ;)
An audio player is not too complicated and is good for learning threads, UI, and working with the file system.
I've always had fun trying to play with compilers/interpreters. I started out making pathetic attempts at my own Javascript interactive shell (I had no prior experience or knowledge of compilers/interpreters and just tried to wing it). And now I'm about to start working on writing my own lexer/parser from scratch.
Personally, I find compilers and interpreters interesting. You can use them, or their components as a start of other project ideas too if you wanted. Also, you can play with them in any language of your choice, so it might not be a bad side project if you want to learn or use a new language and aren't sure what to focus on to do it.
I've always enjoyed writing a little physics simulator or the canonical mandlebrot / julia set generator (parallel extensions anyone :)
Some kind of GPS tracker? I never made one but I believe that of lot of devs do.
Write an touch screen game for a Windows mobile device that competes with the iPhone. Maybe like,'Squash the Bug' or something. Chicks dig that kind of stuff.
Search for a good flash puzzle game and implement a solver for it :)
Personally, it based on your own preferences. For me, it was a grade book program. Since I always had teacher friends, they always wanted me to update it. So I first wrote it in Pascal, then wanted to learn C, so I wrote a C version, then a C++ version and so on.
My daughter was playing basketball, so I wanted to keep score and I had a PocketPC at the time, so I wrote a little app for it.
My $.02

How can I become a better C# programmer? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
When you can create classes and do the simple stuff (GUI, reading text files, etc...), where do I go from here? I've started reading Code Complete 2nd Edition which is great but is more of a general programming book. What topics should I learn next?
I'd argue that, at some point, it's no longer about topics. It's about doing stuff. You gotta write code an you've gotta write a lot of it.
People will often tell you to find some niche problem to try and solve when learning a new language and that's perfectly fine, but if there's an application or feature of an application that you really enjoy using or really admire, attempt to build it (or parts of it) yourself. Even more so, if you find your self wondering Hey, how does [this application] do that?! Try to build it.
Many of your projects may never see the light of day beyond your desktop, but the learning, experience, and tools you'll have under your belt will be something that you can carry over to each subsequent project.
You never know, though, one of those little hobby projects may end up solving a problem for someone.
Not to disagree with the folks who are saying "write stuff," but one topic that you should learn about next is the underlying fundamentals of the CLR -- the workings of the engine that sits behind all of these libraries. A good resource for this is Richter's "CLR Via C#."
Write a desktop RSS reader. You'll get exposure to a bunch of different areas (parsing files, graphical apps, HTTP, the flakiness of the internet), and you might actually use the result on a daily basis. Picking a specific goal or feature to work towards will help you learn more quickly than something abstract.
I agree with most of the answers so far, but I think that if you want to improve as a developer you can benefit greatly by not running solo. Try to find someone who can coach you. Over the years I've made my greatest leeps in depth of understanding by teaming up with programmers who were smarter and more experienced than I was. (They still are :-) )
Learn another language and apply the learned knowledge to C#.
F#, Scala, Haskell - lots to pick :)
Get ReSharper, keep all recommendations enabled and understand them.
Learn best practices and software engineering and how to apply them to C#.
Learn Version Control, TDD, Domain Driven Development, Continuous Integration, MVC, MVP, A handful of patterns: facade, factory, repository vs. active record, etc.
Learn tools that will help you avoid reinventing the wheel: Validation Application Block, NHibernate, etc.
I found this free e-book from the guys at CodeBetter a few days ago:
link text
I haven't read all of it but it looks like a good read.
Try reading the Mono source code to get a look at how a C# compiler written in C# looks. You'll learn so much about the language, compilers, and computer architecture. This is the great benefit of a project with source - you can learn from it.
Visit CodePlex.com and GitHub.com and look for open source projects which you can contribute towards.
looking at q/a of stackoverflow, c# topic. :-D
The best way to learn is to actually get stuck in and build some cool apps, websites, whatever. Its still a good idea to keep up with the various websites to learn new stuff that you might not have come across though.
Maybe build the next facebook or google :)
Also a good way is to get involved in a small project with multiple members (friends maybe), so you can learn from each other and see how other people do their stuff.
Read code
Write code
Test code
Read books (some suggestions), blogs etc.
Repeat
write good unit tests and try to get the code coverage as high as possible
Write code yourself, and read the code that has been written be someone else. But, not anyone else; of a person of whom you're sure that he writes good, clean, smart code.
Work in a team with better programmers - get employed
Work on large open source projects.
I disagree with most people here that learning by building stuff just by yourself is the best way.
Write code, lots of it. And not those fluffy little HelloWorld-type programs.
Find either a real project that interests you or something you've already written that can be converted to C# and do that. Only by doing (and, unfortunately, making copious mistakes) do we learn.
practice, look at open source projects, understand completely what it does and how it does it, especially complex libraries like mocking frameworks, ORM, etc
CLR via C# a great book !! helped(still helping) me a lot understanding the language also you can download the c# language specification book
If you want to become a better C# (replace with any other language), work on large scale applications, the kind that has certain features on 'musts' in it that you know you have no clue how to realize them, yet. All the easy ones around these core 'nuts-to-crack' will help you, too.. it's always good to get used to thinking in large, interwoven dependencies in projects which force you to think through and layout the architecture of your final product upfront.
This isn't particularly c# related, but if you want to become a better developer, these kind of projects (that implicitly include lots of ((c)lean) coding and testing etc etc) are the best learning grounds.
If none of the clients wants to 'give you the chance' to work on such a project with your current skill set just yet, go ahead (or in any case) and start coding on an opensource project and keep friends, colleagues and places like stackoverflow involved.
Be prepared and open to make 'errors' (as you might judge them afterwards)... because only with a gazillion errors made you see the slim/windy path in between them.
That being said, learn to not over-engineer or get tooo perfectionist too early. Bugs will be made, bugs may even remain in a final product considering certain impact conditions etc, learn to live with that as an engineer/developer.
Suggest you read C# in Depth. It is a deep dive into C# that will greatly enhance your understanding of the language. The author, Jon Skeet, is rumored to be a lurker on this site...
With a new language, try to solve some of the Project Euler problems. Improving math and coding at the same time!

Categories

Resources