Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Other Programming > Intro Programming
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Intro Programming What is a loop? Which language is best for beginners? What is "object oreinted?" All those types of questions and more are welcome here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Intro Programming section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 26th, 2008, 03:37 PM
Registered User
 
Join Date: Jun 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default What Language For Me, Now?

I'm not newbie, I'm a hasbeen. I used to be a programmer. I worked for the government. I programmed in Clipper, mainly (ever heard of that?) and did a little C and simple assembler, too.

Then in later years I did stuff in Access Basic, digging into it to a fair extent (but not like a full-on pro working 40hrs a week at it, year in, year out) and then for the sake of a compiled executable I did a little Delphi (even less than the Access).

But the last few years I've been doing no programming at all and my computing is mainly confined to endlessly downloading new programmes I seem to think I simply must have and learning to use them and do video/audio/web type stuff.

But the other day I read this interesting thing about how it doesn't matter where in a word the letters of that word are, just so long as the first and the last are where they should be we can still read it.

And that tweaked my interest no end and for the first time in years I found myself thinking of programming again. I thought I'd like to write a little routine that would take a text file and do that to it.

And then I thought - what shall I write it in?

Clipper is gone.
C doesn't have a graphical UI - too unnecessarily labour intensive to write your own so:
Visual C ? I don't know, maybe?
Access is not compilable (or wasn't the last time I looked)
Delphi again, maybe?

But what about all the new languages such as C# and web languages such as PHP and Perl?

But PHP and Perl, web languages, require a browser, don't they? I want code that doesn't require a browser, but will work with one, too.

I've been at it long enough, as you can see, going back to Cobol and Fortran days, that I see the futility of trying to stick with old fashioned stuff.

So what's the new fashion? We never really got anywhere with 4GL's, did we?

But perhaps there's a new language that really makes all the old ones look sick.

If I jump into coding again I'd like to jump into the driving seat of the best modern vehicle - and by best I don't just mean fastest or most powerful, to stick with the car analogy, but the easiest to drive and the most flexible in use.

Anyone got any thoughts for me?

 regards,

 ab

Reply With Quote
  #2 (permalink)  
Old June 26th, 2008, 04:49 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,652
Thanks: 3
Thanked 141 Times in 140 Posts
Default

VB.NET, C#, JavaScript, VBScript, Java

All of those are capable of running stand-alone applications or of creating HTML output for browsers.

VB.NET, C#, and Java can even do so in GUI environments. Though then the code you write for support of the GUI will be *completely* different from what you write when you incorporate the language into web pages.

JavaScript and VBScript can be used as command-line languages *OR* as part of ASP to produce HTML output *OR* can work completely client-side, in the browser, with no server-side coding needed. [VBScript, of course, only works in MSIE like this. JavaScript works in virtually all browsers.]

So...

For your simple little experiment, I'd probably just stick with JavaScript in a browser. Pretty trivial, really. You would need to first learn enough HTML to be dangerous, but then integrating that with JS code in the browser is a relatively small step.

But any of the above will work. And of course you can use PHP and CF and other web-only languages. But you indicated you wanted an either/or language.

Finally... I sure don't see why you couldn't do this in Access. Though I certainly couldn't recommend that approach. The code would *ONLY* run, then, when you loaded up and ran Access-the-program. (You couldn't integrate it easily with a web solution, for example.)

Want a sample HTML page with JavaScript that demonstrates the word scrambling?? I think I could toss it off in 15 minutes or so. Or do you really want the "joy" of doing it yourself?
Reply With Quote
The Following User Says Thank You to Old Pedant For This Useful Post:
WillieO (January 16th, 2011)
  #3 (permalink)  
Old June 26th, 2008, 04:52 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,652
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Clarification:

"VB.NET, C#, and Java can even do so in GUI environments. Though then the code you write for support of the GUI will be *completely* different from what you write when you incorporate the language into web pages."
The *logic* will be the same, of course. If you wrote a function that took some text as input and spit it back out with the internal letters of words scrambled, you could use that function in either a Web page or in a standalone GUI environment. It's just that then the code to accept the user input text and display the function result will be a lot different.
Reply With Quote
  #4 (permalink)  
Old June 26th, 2008, 05:24 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,652
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Okay, it took over 20 minutes. Mainly because I started playing with the problem of punctuation. But I decided, finally, to leave that to you. As is, this code treats *ALL* non-space characters as letters in a word. So punctuation immediately following a word becomes part of the word. Meaning that it can scramble
     framitz.
into
     fzimrat.
retaining the f and the period, instead of the f and the z.

Also, line breaks are lost and treated the same as spaces.

So...room for improvement, for sure. But still fun.

Just save this to a file named "mungeText.html" on your machine and then browse to that file with your browser.

Code:
<HTML><BODY>
<FORM>
Enter some text:<br/>
<TEXTAREA Name="raw" style="width: 500px; height: 200px;">
'Twas brillig and the slithy toves 
Did gyre and gymbal in the wabe 
All mimsy were the borogoves  
and the mome rath outgrabe 
</TEXTAREA>
<P>
<input type=button value="&quot;Translate&quot;" onClick="translate(this.form.raw);">
</FORM>

Translation:<br/>
<DIV id="munged"></DIV>

<script language="javascript">
function mungeWord( word )
{
    var i;
    var letters = new Array();
    for ( i = 0; i < word.length; ++i )
    {
        letters[i] = word.charAt(i);
    }
    var rlen = letters.length - 2;
    for ( i = 1; i < letters.length-1; ++i )
    {
        var rnum = 1 + Math.floor( Math.random() * rlen );
        var temp = letters[i];
        letters[i] = letters[rnum];
        letters[rnum] = temp;
    }
    return letters.join("");
}

function translate( fld )
{
    var words = fld.value.split(/\s/);
    for ( var w = 0; w < words.length; ++w )
    {
        var word = words[w];
        if ( word.length > 3 ) words[w] = mungeWord(word);
    }
    document.getElementById("munged").innerHTML = words.join(" ");
}
</script>
</body></HTML>
Reply With Quote
  #5 (permalink)  
Old June 26th, 2008, 05:29 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,652
Thanks: 3
Thanked 141 Times in 140 Posts
Default

An easy fix for the punctuation problem.

Just change the line
    var words = fld.value.split(/\s/);
into
    var words = fld.value.split(/[^a-zA-Z]/);

That works by simply getting rid of all punctuation. Heh. Not a great solution, but we have to start someplace. <grin/>
Reply With Quote
  #6 (permalink)  
Old June 26th, 2008, 06:28 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,652
Thanks: 3
Thanked 141 Times in 140 Posts
Default

So I couldn't leave well enough alone.

This code works pretty well. Only problem is that every line break becomes two line breaks. Think I know why, but I've finally lost interest <grin/>.

FWIW, I don't think it's true that you can scramble the interior letters of words and still read the text. Probably works for typical newspaper pap, but clearly doesn't work well with technical content. As is now illustrated by the default text.

Code:
<HTML><BODY>
<FORM>
Enter some text:<br/>
<TEXTAREA Name="raw" style="width: 700px; height: 200px;">
String objects can be created implicitly using string literals. 
String objects created in this fashion (referred to as standard strings) 
are treated differently than String objects created using the new operator. 
All string literals share a common, global string object. If a property 
is added to a string literal, it is available to all standard string objects: 
</TEXTAREA>
<P>
<input type=button value="&quot;Translate&quot;" onClick="translate(this.form.raw);">

Translation:<br/>
<TEXTAREA Name="munged" style="width: 700px; height: 200px;" readonly></TEXTAREA>
</FORM>

<script language="javascript">
function mungeWord( word )
{
    var i;
    var letters = new Array();
    for ( i = 0; i < word.length; ++i )
    {
        letters[i] = word.charAt(i);
    }
    var rlen = letters.length - 2;
    for ( i = 1; i < letters.length-1; ++i )
    {
        var rnum = 1 + Math.floor( Math.random() * rlen );
        var temp = letters[i];
        letters[i] = letters[rnum];
        letters[rnum] = temp;
    }
    return letters.join("");
}

function translate( fld )
{
    var txt = fld.value.replace( /([^a-z ])/ig, " @@@$1@@@ " );
    var words = txt.split(/ /);
    for ( var w = 0; w < words.length; ++w )
    {
        var word = words[w];
        if ( word.length > 3 && word.charAt(0) != "@" ) words[w] = mungeWord(word);
    }
    txt = words.join(" ");
    fld.form.munged.value = txt.replace(/@@@([^a-z ])@@@/ig,"$1").replace(/([a-z]) ([^a-z])/ig,"$1$2");
}
</script>
</body></HTML>
Reply With Quote
  #7 (permalink)  
Old June 26th, 2008, 10:45 PM
Registered User
 
Join Date: Jun 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default


 Hi, and thanks.

 I think the idea is that we recognise the whole word and instantly reconstruct it on sight. Therefore those words we'd have difficulty recognising because they're new or hard somehow we'd have difficulty reconstructing.

 It's still a good party trick, though, don't you think? And something I'd never suspected, being a bit of an old pedant myself and a stickler for spelling.

 Makes me wonder about dyslexic children, too. If dyslexic is the right word. Those with difficulty in writing words inasmuch as they do things like write them with spelling all mixed up or written backwards or whatever. Seems they could just be working on a higher plane than we are - they recognise immediately that the order of the letters isn't that important as long as they're all there.... or something.


 Anyway thanks for the code and the advice. Your routine runs without any double spacing on my test. You don't plump for a single language so I've still got a choice to make. VB.Net seems the way to go, perhaps, seeing I've got so much Access Basic background.

 Yes, I wasn't saying I couldn't do it or it couldn't be done in Access - just Access couldn't be compiled into a standalone executable back when I used to use it - you had to run an instance of Access. I don't want that.

 And, yes, you say stick with Javascript for something so trivial as this exercise. Well, yes, sure, if you've got Javascript to the required level. But if not then I wouldn't bother learning it just for such trivial exercises! Best to learn a language that can do the trivial as easily as the major.

 thanks again and regards,

 ab

Reply With Quote
  #8 (permalink)  
Old June 26th, 2008, 11:36 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,652
Thanks: 3
Thanked 141 Times in 140 Posts
Default

You said you also had C background.

So C# might be a better possibility than VB.NET.

You need to understand that either language is going to wrench your brain in new directions. Neither C nor VBA have anything object-oriented about them. Whereas in C# and VB.NET *all* your code must be written in OO fashion. Your Delphi experience might come closest, actually.

Personally, I can't see any real difference that matters between VB.NET and C#. Just the syntax is different, while all the underlying libraries and concepts remain the same. This is natural, as both of them compile source code into a tokenized "byte code" known as CLR ("Common Language Runtime"). And then the CLR is further compiled to machine code as needed. Meaning, of course, that any C# code can call VB.NET code which can call C# code. [And, indeed, any code written in any other .NET language. And there are actually quite a few of them, just that they aren't supported for doing ASP.NET.]

So were I you, I'd examine some essentially identical code written in both languages and compare and contrast and choose the one you are more comfortable with. Several of the freebie "starter kits" at http://msdn.microsoft.com/Express are available in both languages, I believe. A good place to start.

And of course the tutorial materials available for either language are nothing short of fantastic. Complete college-level courses on-line, for all practical purposes. Besides the msdn URL, check out http://www.asp.net/Learn as a starting point.

Have fun!
Reply With Quote
  #9 (permalink)  
Old June 27th, 2008, 01:19 AM
Registered User
 
Join Date: Jun 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Yes, Clipper was written in C and easily extensible to C routines and I did a couple of C courses way back then and we had Ultrix on the Vax at Uni. It's a pity I was shunted away from it really. I think you might be right. C# could perhaps suit me fine.

 Thanks for your advice, your code and your links. I'll use them all.

 regards,

 ab :)


Reply With Quote
  #10 (permalink)  
Old April 12th, 2010, 11:38 AM
Registered User
 
Join Date: Apr 2010
Posts: 3
Thanks: 0
Thanked 1 Time in 1 Post
Default

The question about which (one) language has implications for code design for all development issues.

you can break an application down into a number of discreet but associated stages. The simplest is 3-tier

User Interface
Business Logic
Data Storage

This is one reason Access rocks (or sucks depending on which way you look at it). You can do all three tiers in a single product.

When working on the web you will usually have 3 separate tiers

HTML for the user interface (ask the questions, display the results)
A database to hold the information (MSSQL or MySQL normally)
A programming language to decide what information should be displayed (ASP/.NET/Perl/Python/PHP)

The big advantage of separated structures is that in theory you can swap one element for another and your application will still work.

e.g. swap your web front end for one written in Access, looking at the same scripts on the web server and your application still works. change the business rules in the code on the server and both the web and client side both change what they display. Change mySQL for MSSQL and the business rules still get the same data.

Of course it is never that simple. You can add another tier and have the business logic held inside the db using stored procedures. Your PHP/ASP code then simply call the SPs, passing through whatever parameters are required. you could introduce ajax to provida and RIA experience which would probably require lots of additional server side code to handle the ajax requests.
You can use a framework (Cake, ruby, Codeigniter etc) for the server side programming which takes away some of the mundane activity like connecting to databases or building web forms and doing validation.

Generally, unless you are going to use Access there isn't one language to learn but several and Access is really three languages anyway (SQL, VBA and GUI forms).

Personally I would learn SQL (microsoft T-SQL or mySQL which is ANSI standard) and PHP and HTML as a starting point as you they are free and you can build either client side or server side applications with these. You would then want to look at javascript/ajax and/or = VB.NET/ C#.NET to complete your knowledge base.

obiron
Reply With Quote
The Following User Says Thank You to obiron For This Useful Post:
WillieO (January 16th, 2011)
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Which language would be best for... GeckOblue925 Intro Programming 4 February 20th, 2007 12:04 AM
Which language to use? SkyBlueshoes Intro Programming 1 March 9th, 2006 07:51 AM
Which language is better? sario777 VS.NET 2002/2003 4 April 17th, 2005 01:35 PM
c language help!!! kernel_zap C# 2 April 29th, 2004 09:10 AM
A different language bearpaws Classic ASP Basics 7 December 5th, 2003 03:47 PM



All times are GMT -4. The time now is 11:33 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.