So you've got to create your own scripting language built in .NET C#.
What's better now for libraries? (think SDL/OPENGL), generate wrappers with Swig or do it by hand? Any other choice?
Since you're building the language in C#/.NET (which I will comment about later), you should have easy access to the entire .NET library system. This should make it very easy to use existing libraries to make .NET assemblies, and have them exposed to your scripts.
However, I'd question wanting to make a scripting language in C# - There are very good options out there, especially if you take the DLR (dynamic language runtime) into account. You can provide scripting to an existing C# application very easily without making a custom language.
I would recommend using the CLR.
This way, you get the entire FCL, and any third-party libraries that people write in .Net, without having to do any additional work.
Related
What is an embedded scripting language? What are some advantages it would have over the domain specific language?
"A number of languages have been designed for the purpose of replacing application-specific scripting languages by being embeddable in application programs." -Scripting language (wiki)
Javascript.NET is one such example. It can be used in place of c# for example. However, what constitutes the difference between a scripting language, and an embedded scripting language? Moreover, why would javascript be more desirable than C# - or any other domain specific language?
An embedded scripting language would be a scripting language (or more specifically an interpreter for such a language) that can be embedded into applications. Thus, the interpreter has an API that can be used to integrate it into the application, allowing scripts to control all or parts of the application.
the advantage is that application developers only have to provide the interfacing with the language; they don't have to implement the actual language. This allows more complex and feature-rich languages to be used, since there's no development time (from the application developer point of view).
For users, it means they know the pros and cons, the quirks and benefits of the scripting language, provided we are talking about a commonly used one.
For your core business, you probably should not use an embedded language, but there are other upsides of using an embedded language. Most importantly, in my experience, it is beneficial to have an easy-to-use language on which other users can build against your system. While theoretically it is possible to build against your system with proper definition of interfaces, it is a lot more user-friendly to let inexperienced people play with JavaScript and Lua, instead of having to set-up an entire environment to deploy in .NET.
Of course, it is easy to hot-swap embedded languages and it can speed up your testing considerably; it is also possible to see your changes immediately without reloading your application, because you just reload a small virtual machine for that embedded language.
I personally employed this to allow people to write assisting scripts against a game.
I don't like django. The forms, the url schemes, the way they assume everyone use models on schemaful db (I prefer to use mongodb because it's so clean and easy).
I am pretty much fluent in all the major languages. I do prefer python because it's very clean but also strict (aka function signatures requires you to pass in only X variables etc).
I want something developed and mature - this means that stuff like authentication, registration etc should all be developed and ready to use.
Any suggestions?
TLDR: Need new web dev framework. Requirement: Nothing. Preference: Mongodb, python.
By the way forgot to mention that I might be looking for employment in the web dev industry. So if you can recommend something that is common among big companies that would also be a bonus. like scala's lift for foursquare (if I am not wrong) and php for facebook.
Rails. It works with MongoDB via Mongoid and has many authentication solutions. You'll find Ruby very comfortable if you have Python experience.
I'm using Flask for Python, and I love it. I'm using SQLAlchemy for Postgre, but it's super minimalistic, so you can use it with whatever you'd like. I've also heard really good things about Pylons, but don't have any experience with it myself.
Spring Framework. (Java)
For authentication you can use Spring Security
It seems like you aren't very keen on using Java, but if you don't mind a different language on the JVM I'd suggest taking a look at Compojure, a web framework for Clojure. It isn't a scripting language but can offer close to the same development speeds once you get used to 'the-lisp-way' of doing things.
I'm unaware of a fully featured MongoDB interface specifically for Clojure, but CongoMongo and Adia (I can't include more than the one link currently so you'll need to google them yourself, sorry!) might have (atleast part of) what you're looking for. If nothing else, you could probably just use an existing Java library to access MongoDB or use a different database. Give Compojure a try though, its definitely productive!
Also on a completely unrelated note, this happens to be my first answer on SO, so please be gentle with the downvotes :)
Pylons.
It will be very fitting for you
Im a big believer in grails. Built on best of breed technologies like Spring and Hibernate, you can fall back to java if you have too. Takes all the pain out of more traditional Java EE development. Has all the important functionality as plugins, you have access to Spring Security, JMS, everything you need. Is very convenient as the back end to a RIA, easily render you models as json, easily handle xml. Its great.
EDIT -- to address the comment, Grails uses the Groovy language, which is scriptable and has some very groovy features. And it is easy to learn if you are familiar with java. Has closures, lots of syntactic sugar.
The scripting part is actually quite invaluable -- you write groovy scripts and import your grails classes to whip up functionality to augment your app (like quick queries into your db)
I learned some java first, and now I'm learning PHP. I am not comfortable with how "free" it is, with things like loose typing. I really liked the way java forces you into good practice. Are there any open source web programming languages that are more restrictive than PHP, in the same way java is?
How about... Java? :D
If normal Java-driven frameworks are (for some reason) unacceptable, then how about Google Web Toolkit - you write code in Java (with all the benefits of the language), but the application is compiled to JavaScript, which can be run on any modern browser. Additionally, it performs some optimization, etc - really worth looking into if you are familiar with Java and want to use that language to write "light" web applications.
If I didn't make it clear before: you write code in Java (you can use all the design patterns, object-oriented features, strict typing, etc., the compiler warns you if there are compilation-time errors, there's very mature Eclipse integration and so on), but the application is compiled to JavaScript - no need for Java plugin in the browser (no Java applets whatsoever). The compilation part additionally optimizes and obfuscates the output JS code so you'll get faster and smaller code, then if you wrote it by hand. The server side is up to you - while it is easiest to use Java there (especially with all the cool stuff coming in GWT 2.1), you easily use PHP, RoR or Django (via JSON or XML).
I want to develop a forum like web site. I know C, C++ well but I havent used in web development.I know PHP little bit. Which language should i use?
C++ can and has been used to successfully develop highly scalable web applications. That said, one of the main reasons C++ is not so popular in this category is to do with the lack of standard tools and libraries. There is simply no feature rich library which includes all the necessary boiler-plate code needed to write web applications.
PHP is everything that C++ isn't when it comes to web development - a high-level scripting language designed mainly for web development. The description of PHP on the homepage sums it up nicely:
PHP is a widely-used general-purpose
scripting language that is especially
suited for Web development and can be
embedded into HTML.
If you're developing a simple forum, this decision is a no-brainer: PHP. In addition to the obvious advantages to using it, you'll find the syntax familiar as it is C-like. However, if you have all the time in the world, you're feeling brave and this is for hobbies' sake, do it with C++!
Out of those, for web development, PHP for sure.
C and C++ is not the correct choice to develop for web, so if you know PHP it's better.
also you can try python, ASP.net etc...
To add most hosting does not support c++ and they will not in most case so if you were me I will go for PHP and almost(nearly) all hosting service support it.
Also the lack of function for web development in c++ is also a pull down.
Actually, I wonder why you're not considering to use both! Use PHP for the web interface and write special C++ methods for the more complex actions that you want to take. (Although PHP can handle most of those too.) Basically, this would require less knowledge of PHP and your C++ knowledge stays usable.
Do keep in mind the hosting restrictions of your webhost, unless you're going to host your site on your own system.
Also, do realize that the use of C++ for web development would restrict you to the more general C++ libraries. C++ can be used to write platform-independent code, just like PHP. But not all libraries are supported on every platform.
Finally, PHP already is a powerful language and there are plenty of add-ins for PHP that you can re-use instead of writing it yourself. Still, most of PHP and all the add-ins are written in C++, even though many people just forget about the fact that the code behind PHP had to be written in some language too. Image manipulation, encryption, complex math, etc... It's all been done before for PHP. But it should not stop you from writing your own extensions...
PHP, Python, ASP, JSP, C#.net all should work
C++ is not commonly used for this purpose. Most shared hosting providers won't allow you to run native executables created by C++ for reasons of security (though I suspect this would be manageable with fine-tuned rights) and portability (eg. you'd have to know which OS the shared hoster's webserver runs on and possibly install additional libraries).
Even if you have your own dedicated server with root access, it might still be difficult to properly integrate an executable as CGI into Apache or IIS.
If you're not bound to PHP or C/C++ for some other reason, you could also try C#. Picking up C# from C++ is very easy and ASP.NET allows you to write your complete website in C#. With ASP.NET MVC, you even have an MVC framework comparable in productivity to Ruby on rails. Many shared hosting providers support ASP.NET and through Mono, it's even possible to host ASP.NET web sites in Linux (I'm doing this with my blog ;-))
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I need some resources that talk about how to design your software to be extensible, i.e. so that other people can write add-ons/plug-ins that adds functionality to it.
What do you recommend? Any books out there that discuss the subject?
I would prefer something that's short and to the point; a bit of theory and a bunch of concrete examples.
I'm not targeting a specific language, I want to be able to understand the core idea so that I can implement it in any language.
And for the same reason, I prefer not to do it using a framework that someone else built (unless the framework is not very high-level, i.e. doesn't hide too much), at the moment I only want to educate myself on the subject and experiment with various ways to implement it. Plus, a framework usually assumes user's knowledge about the subject.
UPDATE
I'm not asking about OOP or allowing my classes to be inherited. I'm talking about designing an application that will be deployed on a system, such that it can be extended by third-party add-ons AFTER its been deployed.
For example, Notepad++ has a plug-in architecture where you can place a .dll file in the plugins folder, and it adds functionality to the application that wasn't there, such as color-picking, or snippet insertion, or many other things (a wide range of functionality).
IF we're talking .NET, try Scripting .NET applications with VBScript over on CodeProject. Lots of concrete examples there.
Below are sites implementing various application extension techniques
ClearScript - Makes V8, VBScript and JScript available to .NET apps
CS-Script - The C# Script Engine
Plugin Architecture using C#
Opinio plugin architecture
Notes on the Eclipse Plug-in Architecture
Plug-in Architecture Framework for Beginners
Gecko plugin architecture
Fungimol plugin architecture
OSGI is a good practical example of a technical framework allowing to do what you are after.
The theory is here.
The (free!) book is there.
Extensibility and the ability to write plugin must deal with service lifecycle
adding / removing service/plugin on the spot
managing dependencies between services
managing states of services (declared, installed, started, stopped,...)
What is OSGI for ?
One of the main functions of a module is as a unit of deployment… something that we can either build or download and install to extend the functionality of our application.
You will find a good introduction here, on the central notion of service (which is related to your question, and which explain some problems around services, key component for extensibility).
Extract:
Why are services then so important if so many applications can be built without them? Well, services are the best known way to decouple software components from each other.
One of the most important aspects of services is that they significantly minimize class loading problems because they work with instances of objects, not with class names. Instances that are created by the provider, not the consumer. The reduction of the complexity is quite surprising
Not only do services minimize configuration, they also significantly reduce the number of shared packages.
Implement SOLID principles in your application.
1. Single responsibility principle: A class should have only a single responsibility (i.e. only one potential change in the software's specification should be able to affect the specification of the class
2.Open/closed principle: Software entities … should be open for extension, but closed for modification
3. Liskov substitution principle: Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program
4. Interface segregation principle: Many client-specific interfaces are better than one general-purpose interface
5. Dependency inversion principle: One should Depend upon Abstractions. Do not depend upon concretions
Stackoverflow questions:
Example of Single Responsibility Principle
Is the Open/Closed Principle a good idea?
What is the Liskov Substitution Principle?
Interface Segregation Principle- Program to an interface
What is the Dependency Inversion Principle and why is it important?
You try to reach two competing goals:
The components of your software must expose a lot of themselves, so they can be reused
The components of your software must expose very little of themselves, so they can be reused
Explanation: To encourage code reuse, you should be able to extend existing classes and call their methods. This isn't possible when the methods are declared "private" and the classes are "final" (and can't be extended). So to meet this goal, everything should be public and accessible. No private data or methods.
When you release the second version of your software, you will find that many of the ideas of version 1 were plain wrong. You need to change many interfaces or your code, method names, delete methods, break the API. If you do this, many people will turn away. So in order to be able to evolve your software, the components must not expose anything that is not absolutely necessary - at the cost of code reuse.
Example: I wanted to observe the position of the cursor (caret) in an SWT StyledText. The caret is not meant to be extended. If you do it, you'll find that the code contains checks like "is this class in the package org.eclipse.swt" and a lot of methods are private and final and whatnot. I had to copy about 28 classes out of SWT into my project just to implement this feature because everything is locked down.
SWT is a nice framework to use and hell to extend.
Of course there is the famous Open Closed Principle - http://en.wikipedia.org/wiki/Open/closed_principle
Well it depends on the language.
In C/C++ I'm pretty sure there is a loadlibrary function that allows you to open a library at runtime and invoke it's exported functions. This is typically how it's done in C/C++.
In .NET, there is Reflection, which is offers similar (but more broad) to loadlibrary. There is also entire libraries built on Reflection like Managed Extension Framework, or Mono.Addins that does most of the heavy lifting for you already.
In Java, there is also Reflection. And there is the JPF (Java Plugin Framework) which is used in stuff like Eclipse IIRC.
Depending on what language you use I could recommend some tutorial/books. I hope this was helpful.
Plugin architecture is becoming very popular for its extensibility and thus flexibility.
For c++, Apache httpd server is actually plugin based, but a concept of module is used instead. Most of apache features are implemented as modules, like cache, rewrite, load balancing, and even threading model. It is a very modular software I ever saw.
And for java, Eclipse is definitely plugin based. The core of Eclipse is an OSGI module system which manage bundles, another concept for plugin. Bundle can provide extension points on which we can build modules with less efforts. The most intricate thing in OSGI is its dynamic characteristic, which means bundles can be installed or uninstalled at runtime. No stop-the-world syndrome any more!
Since I dont have enough rep points to leave a comment, I am posting this as an answer. SharpDevelop is an IDE for developing applications in C#/VB.NET/Boo. It has a pretty impressive architecture that allows itself to be extended in a number of ways - right from new menu items to development support for whole new languages.
It uses a bit of XML configuration to act as a glue layer between a core of the IDE and the plugin implementation. It handles locating, loading and versioning of plugins out of the box. Deploying new plugins is matter of simply copying in the new xml configuration file and the required assemblies (DLLs) and restarting the application. You can read more on this in the book "Dissecting a csharp application" by the original author(s) - Christian Holm, Mike Krüger, Bernhard Spuida of the application from here. The book doesnt seem to be available on that site, but i found a copy that might still be around here
Also found a related question here
Checkout "CAB" - Microsoft's Composition Application Building blocks Framework. I think they've got a "web version" of that too...
I have just started to develop a smart client application. These are two options I am considering.
Using Microsoft's System.AddIn namespace. Looks very promising, however it may be a little complex for our end solution.
Or the Smart Client - Composite UI Application Block from Microsoft
Recently, i have looked at taking components both the Composite UI Application Block and the System.AddIn namespace to build my own. Since source code is available for the CAB it is easy to extend. I think our end solution will be a light weight version of the CAB, definatly using the Unity Application Block
If you work with .Net, our research yielded two approaches: scripting and composition.
Scripting
You extend the functionality of what your classes can do by orchestrating them using scripts. That means exposing what is compiled in your favorite .Net language in a dynamic language.
Some options we found worth exploring:
IronPython
IronRuby
JavaScript: Jint, Jurassic and JavaScript .Net are good starting points.
Script.Net -> this one was the first one to call our attention.
Composition
If you start a project with .Net 4 or above, you must take a good look at the Managed Extensibility Framework (MEF). It allows you to extend the functionality of your apps in a plugin way.
The Managed Extensibility Framework (MEF) is a composition layer for
.NET that improves the flexibility, maintainability and testability of
large applications. MEF can be used for third-party plugin
extensibility, or it can bring the benefits of a loosely-coupled
plugin-like architecture to regular applications.
Managed Add-in Framework is also a good read.
MSDN: http://msdn.microsoft.com/en-us/library/dd460648.aspx
Codeplex: http://mef.codeplex.com/
Rather than re-inventing the wheel, use the frameworks in hand. Eclipse and Netbeans both support plugin based extensions. You have to work in Java though.