windows programming without a OOP language - windows

Which language ( that is not oop ) should I consider using for writing gui windows apps ?
I guess the obvious answers are visual basic and C , but am wondering if I should look into anything else
am not saying OOP sucks or anything. I just don't.. not using it. The END
ty
Edit: I just want a language that has a non oop paradigm option and that is/can be used to write a windows gui application .

It is quite possible to write procedural code in any language.

There is FreeBasic

I'd personally recommend giving Fortran a go, it's quite nice...

I'd use Python. Sure it can be used in a OO way (as pretty much all other languages can as well), but it's pretty easy to write clean, simple, procedural code with it as well.

C would be my choice, Visual Studio supports it and has an excellent debugger. There are also plenty of examples out on the web in C for Windows programming so you'll have the easiest time getting your code to work.

OO is kind of a pervasive paradigm these days. It's pretty much impossible to avoid, even languages like VB and C can be used to program in an OO way, although I do get what you mean. Have you considered Fortran? COBOL? J? Perl? Python? They can all pretty much be used in a non OO way.
Not to mention assembly language.

F# I guess, avoiding its inherent object-oriented programming model. But do you like functional languages and the .NET framework?!

Out of curiosity, why do you need such a thing?
Windows programming is OO by design. Even if you use C, all the API functions work like OO.
Every handle has a corresponding Create function
CloseHandle if used to close any object, not just a specific type
And finally every single API function gets a Handle to a relevant object, just like the old implementation of OO in pure C with structs - the equivalent of this.

Well, there are guys who are still using Visual Foxpro, or Visual Basic 6 (which is NOT OO, contrary to what some people say).

C and Windows API. It is not OO, but feels like, because OO (C++, Java, C#) is nothing but making structs into objects.

Related

Using Datalog by itself, is it possible?

I am currently studying Datalog for my report in class, I only need to discuss basic syntax and a basic example.
I know Datalog is usually used as a query language and is usually only implemented to other languages such as Java, Lua, C, etc. but is it possible to teach Datalog only by itself, or am I required to use another language implementing it to show a simple working program?
There are a few online demos you can use:
http://iris-reasoner.org/demo
http://ysangkok.github.io/mitre-datalog.js/wrapper.html
https://repl.logicblox.com/ (docs here:
https://developer.logicblox.com/content/docs4/tutorial/repl/section/split.html )
I haven't tried it myself yet, but http://abcdatalog.seas.harvard.edu also looks nice and easy to run.
A complete overview is on Wikipedia: https://en.wikipedia.org/wiki/Datalog

How to refactor dynamic languages safely?

For example I decided to fuse two classes. The problem with JS or LUA is that it gets very hard to find implicit problems, for example it shows you a error only when your runtime actually executes the piece of code you are trying to implement. The advantage of strict languages like Haxe or C++ is that your code won't compile until you fix everything.
Does anyone know what are the best practices for refactoring dynamic languages?
The problem isn't really specific to "refactoring".
It is that "it (the dynamic language interpreter) shows you a error only when your runtime actually executes the piece of code which is wrong (and sometimes not even then)". This is probably the major defect of dynamic languages.
What is needed is a tool that can reason deeply about your code to decide statically, where practical, if executing it might produce a runtime error or a useless computation. Such tools are pretty hard to find.
The discussion here is instructive: Programming Language Properties that facilitate refactoring?

What is this programming "syntax" on code.org

Out of curiosity, i tried a few tutorials on code.org.
I began with this one.
Have you seen this graphical syntax using blocks ?
Is it some kind of standard ?
Or is completely home made ?
Here is what it looks like :
http://files.websitetoolbox.com/149581/1788549
Where can i learn more about it ?
I think it is really easy to read, and i wonder if i could use somewhere else, programming c# or c++, java, even javascript.
I am still not sure if business code would really be easy to read using this syntax.
It's likely to be some form of OpenBlocks, it's a way of representing your code and what it does in a more intuitive fashion, you can read more about it at the link I posted as a comment.
Notably, a similar solution was in use for creating Android apps too .
This is called blockly. You can find a lot of information from blockly's FAQ. Hope that helps.

Automating Excel 2010 using F#

I have been searching for a FAQ to tell me how to open a Excel Workbook/Worksheet and also how to Save the File once I have finished.
I notice that in most FAQ and all the books I have purchased on F# one is show how to create a new Workbook/Worksheet but is never shown how to either open or Save it.
Being a newbie to F# I would very much appreciate it if anyone could kindly provide me with either an answer or perhaps a few pointers?
Update
As for why F# and not C# or VB?
I am pleased to say that inspite of being a newbie (with the exception of Forth, VBA & Excel 2003, 2007 & 2010 and Visual Basic) I can do this in both VB, VBA & C# and since I've been retired on medical grounds, with plenty of time unfortunately on my hands, I like to continually set myself challenges to keep my little grey cells active and being a sucker for trying new languages....well!
F# is now an intergral part of Visual Studio 2010 so I thought - why not. Consider this - if we are not willing to use or at least try a new languages - I would always be wonder if I might have prefer it to VBA, VB, C# ..... and if you look at it from another point of view, if no one is going to use it - why create it in the first place? I suppose you can say if cave men hadn't experimented and made fire by rubbing two sticks together - where would we be now and would matches have been invented?
Although an complete answer would be good, I prefer a few pointers, to keep my challenge going.
And lastly but not least - thank you for taking the trouble to respond!
I don't think their is a specific F# library for Office, so you will just use the exact same .NET library that you use in VB.NET/C#. F# is a .NET language, so anything that can be done in C# can be done in F# (but you probably already knew that :) ). The API call will be exactly the same, it just that they will be done using the F# syntax instead of the VB/C# one. So for example something that look like this
public void SaveMyWorkbook() {
string filePath = #"C:\failworkbooks\catfail.xlsx";
workbook.Save(filepath);
}
Will be expressed in F# as
let filePath = "C:\\failworkbooks\\catfail.xlsx";
let saveWorkbook() = workbook.Save(filePath) |> ignore //if the Save method return something
Now, what you will soon realize is that the API isn't exactly designed to be easily used from a functional language. It can be done, but this task in particuliar is much more tailored to C#/VB.NET.
If you really want to enjoy F#, I suggest you use in area where its strength really show. My personal experience is that functional language are awesome when a lot of math is involved. It is also marvellous if you want to easily introduce parallelism in your application (since F# code is usually side effect free). So anything that require data crunching on a lot of data is perfect for it. But for task that consist mainly of putting together a bunch of API call to an external library, F# is kind of meh. You could say that F# is kind of like a graphic card programming language, while C# a general purpose CPU programming language. A lot of thing run better with C#, but the stuff that run better on F# run really better on it.
But if you really want to go that route, my suggestion is to try to use the Office API as you already know it, but with a F# syntax. If at some point you really have no idea how to do a specific task, ask a question about it on stackoverflow with your code and exactly want you want to do. Those question get answered ridiculously fast compared to broad all-encompassing question, so you won't wait long. (Programmer seem to love precise question with a specific answer ^^)
I hope that it helped a little.
I found this http://iouri-khramtsov.blogspot.co.uk/2011/12/automating-excel-with-f.html helpful advice. Briefly, you'd use something like this:
#r "Microsoft.Office.Interop.Excel" // Assuming it's a script
let excel = ApplicationClass(Visible = true)
let openFileName = #"C:\MyDir\MyFilenameToOpen.xls"
excel.Workbooks.Open(openFileName)
// Do stuff
let savedFileName = #"C:\MyDir\MyFilename.xls"
workbook.SaveAs(savedFileName)
Using F# with Excel seems like a natural fit.
Getting to a result in Excel requires the use of several immutable values, each driven by formulas. Excel has a brilliant user interface, a lovely model of the world - I love rows, columns and cells - but to automate or customise things requires macros. Why learn this when you can use F#? Formulas and immutable values are fundamental to its design.
Ideally you'd write formulas yourself as a User Defined Function (UDFs) also in F# - see http://excel-dna.net/ . Then, perhaps, you'd want to do something interesting with objects/types - Look for "github com mndrake ExcelObjectHandler" (I don't have enough reputation to post a 3rd link).
Jack

What tools for migrating programs from a platform A to B

As a pet project, I was thinking about writing a program to migrate applications written in a language A into a language B.
A and B would be object-oriented languages. I suppose it is a very hard task : mapping language constructs that are alike is doable, but mapping libraries concepts will be a very long task.
I was wondering what tools to use, I know this has to do with compilation, but I'm a bit afraid to use Lex and Yacc and all that stuff.
I was thinking of maybe using the Eclipse Modeling Framework, which would help me write models (of application code) transformations in a readable form.
But first I would have to write parsers for creating the models (and also create the metamodel from the language grammar).
Are there tools that exist that would make my task easier?
You can use special transformation tools/languages for that TXL or Stratego/XT.
Also you can have a look and easily try Java to Python and Java to Tcl migrating projects made by me with TXL.
You are right about mapping library concepts. It is rather hard and long task. There are two ways here:
Fully migrate the class library from language A to B
Migrate classes/functions from language A to the corresponding concepts in language B
The approach you will choose depends on your goals and time/resources available. Also in many cases you wont be doing a general A->B migration which will cover all possible cases, you will need just to convert some project/library/etc. so you will see in your particular cases what is better to do with classes/libraries.
I think this is almost impossibly hard, especially as a personal project. But if you are going to do it, don't make life even more difficult for yourself by trying to come up with a general solution. Choose two specific real-life programming languages ind investigate the possibities of converting between them. I think you will be shocked by the number of problems and issues this will expose.
There are some tools for direct migration for some combinations of A and B.
There are a variety of reverse engineering and code generation tools for different languages and platforms. It's fairly rare to see reverse engineering tools which capture all the semantics of the source language, and the semantics of UML are not well defined ( since it's designed to map to different implementation languages, it itself doesn't define a complete execution model for its behavioural representations ), so you're unlikely to be able to reverse engineer and generate code between tools. You may find one tool that does full reverse engineering and full code generation for your A and B languages, and so may be able to get somewhere.
In general you don't use the same idioms on different platforms, so you're more likely to get something which emulates A code on B rather than something which corresponds to a native B solution.
If you want to use Java as the source language(that language you try to convert) than you might use Checkstyle AST(its used to write Rules). It gives you tree structure with every operation done in the source code. This will be much more easier than writing your own paser or using regex.
You can run com.puppycrawl.tools.checkstyle.gui.Main from checkstyle-4.4.jar to launch Swing GUI that parse Java Source Code.
Based on your comment
I'm not sure yet, but I think the source language/framework would be Java/Swing and the target some RIA language like Flex or a Javascript/Ajax framework. – Alain Michel 3 hours ago
Google Web Toolkit might be worth a look.
See this answer: What kinds of patterns could I enforce on the code to make it easier to translate to another programming language?

Resources