The Joel on Software Discussion Group (CLOSED)

A place to discuss Joel on Software. Now closed.

This community works best when people use their real names. Please register for a free account.

Other Groups:
Joel on Software
Business of Software
Design of Software (CLOSED)
.NET Questions (CLOSED)
TechInterview.org
CityDesk
FogBugz
Fog Creek Copilot


The Old Forum


Your hosts:
Albert D. Kallal
Li-Fan Chen
Stephen Jones

I Can Name That Code Tune in 10 Lines...

What I mean by the topic title is more of a challenge....the question is this: What is the most functionality you can pack within the smallest number of code lines?

Remember the old game show called "Name That Tune?" Well, this post offers a variation of that game for anyone interested.....

The point of this post is to demonstrate what I think is one of the most succinct programming languages in the world - VB.Net; the following code makes this point:

Dim SrchString As String = "IN,BL,KD,XL,TP,LF,AC,PR,KG,DX"
        Dim Ar(9) As String
        Dim Count As Byte
        Dim CodeFind As String = "PR"
        Ar = SrchString.Split(",")

        Do Until Ar(Count) = CodeFind
            Count = Count + 1
        Loop

        My.Computer.FileSystem.WriteAllText("c:\Test.txt", Ar(Count) & _
Ar(Count).GetHashCode.ToString, False)

The "code tune" above accomplishes the following......

1) Creates a regular string
2) Converts the string to a 1-dim array
3) Searches and finds an item within the array called "PR"
4) Converts the results to a hash
4) Writes the results of both the item and its hash to a text file

This is all accomplished in TEN lines of code.

What is the most functionality you can pack into less than 10 LOC? Use any language you like....

*VB.Net 2008 was used to create the sample code provided*
Brice Richard Send private email
Tuesday, April 08, 2008
 
 
If you want condensed code you meed to Google "obfuscated c"
or "Perl golf"

cheers
Honu
Tuesday, April 08, 2008
 
 
Thats a one liner in Perl...  Wouldn't even bother putting the code in a file.

Tuesday, April 08, 2008
 
 
jk
Tuesday, April 08, 2008
 
 
hehe, this should be interesting.. if I had more time I'd apply :)
Richard Corsale Send private email
Tuesday, April 08, 2008
 
 
class UserController < ApplicationController
  scaffold :user
end

Creates a fully-functional (although ugly as sin and very basic) CRUD application.  No validation, though, and you can't edit the appearance, but still - three lines of code.

Well, okay, I it's a little more than three because you would need to do a migration first, but you could probably do it all on one line with a generator like so: 

ruby script/generate resource User name:string email:string

Then just rake:db:migrate and boom, add that line above and you have a functional, albeit simple, web application.
WayneM. Send private email
Tuesday, April 08, 2008
 
 
I WISH they'd have a competition for "I can make that code SO self-explanatory...".

All these obfuscation contests just irritate me.  The purpose of code is inherently obfuscated, since it's a translation of English into a simplified (compared to English) coding language.

Why encourage people to obfuscate it further?  The property you WANT good code to have is CLARITY.
AllanL5
Tuesday, April 08, 2008
 
 
Wayne,

Much as I admire your answer, it's not really in the spirit of Brice's little teaser because you should probably include the LOC count of Rails itself in the total! However, you could probably replicate Brice's less than amazing effort in a line or three of Ruby itself.
John Topley Send private email
Tuesday, April 08, 2008
 
 
John,

Perhaps, but if he's using VB.NET then surely he's not factoring in the additional lines of code required to compile even a basic VB.NET program ;-)
WayneM. Send private email
Tuesday, April 08, 2008
 
 
What Allan said.  If I want to read code like that... well, I'm doing it right now, at work...at a system written by VB people...which I am certain is just a coincidence...
gc
Tuesday, April 08, 2008
 
 
Let's turn this around. Is there a language where the OP's example would require MORE than 10 lines? I can't think of one, and I can think of lots that require many less (for starters, all the languages that don't require variable declarations). (Though I don't think VB *requires* it either, is that still true in the .NET version?)
Greg Send private email
Tuesday, April 08, 2008
 
 
Well, except for the class-declaration boilerplate in Java I guess, yes that would add a few lines.
Greg Send private email
Tuesday, April 08, 2008
 
 
"This is all accomplished in TEN lines of code."

That's a hell of a lot. Here's roughly the same thing in two lines of PHP plus one line of bash

<?php $s="IN,BL,KD,XL,TP,LF,AC,PR,KG,DC"; $c = "PR";
if ( ereg( "(" . $c . "),", $s, $a ) ) echo md5( $a[ 1 ] ); ?>

saved as "test.php" and followed by

$ php -q test.php > test.txt

By the way Brice, your code crashed out with an UnauthorizedAccessException. Stop running as administrator and start testing as a regular user. Now.

" Let's turn this around. Is there a language where the OP's example would require MORE than 10 lines?"

Um, assembler. Especially if it's a RISC one. In fact all of these will expand out to way more than 100 instructions when you take into account all the libraries involved en route.
Ritchie Swann Send private email
Tuesday, April 08, 2008
 
 
<<<Perhaps, but if he's using VB.NET then surely he's not factoring in the additional lines of code required to compile even a basic VB.NET program ;-)>>>

FYI, the compiled, executable size of the code I provided is 16KB.
Brice Richard Send private email
Tuesday, April 08, 2008
 
 
<<<By the way Brice, your code crashed out with an UnauthorizedAccessException. Stop running as administrator and start testing as a regular user. Now.>>>

Stop writing text files to your server without the appropriate permissions then!

It is possible to programmatically write text files to your local root directory as a regular user!
Brice Richard Send private email
Tuesday, April 08, 2008
 
 
I also note your "Do Until" doesn't have the possiblity that the search string isn't in the array.

Kind of a newbie mistake that, no?
AllanL5
Tuesday, April 08, 2008
 
 
My example is actually (5) LOC without the declarations.
Brice Richard Send private email
Tuesday, April 08, 2008
 
 
"Perhaps, but if he's using VB.NET then surely he's not factoring in the additional lines of code required to compile even a basic VB.NET program"

That's only four lines (one for a class, one for the static main entry point, plus one each to terminate those). Unfortunately since a newline is syntactically important in VB it's not a good language to get really small unreadable code in!
Ritchie Swann Send private email
Tuesday, April 08, 2008
 
 
<<<I also note your "Do Until" doesn't have the possiblity that the search string isn't in the array.

Kind of a newbie mistake that, no?>>>


The search string is HARD CODED, so there is no chance of an error occurring, therein obviating the need for error handling of the sample code.
Brice Richard Send private email
Tuesday, April 08, 2008
 
 
"It is possible to programmatically write text files to your local root directory as a regular user!"

How do you do that then?
Ritchie Swann Send private email
Tuesday, April 08, 2008
 
 
So why don't you simply set "Count" to 7?  What's the purpose of the 'Do Until' lines of code?
AllanL5
Tuesday, April 08, 2008
 
 
I'm assuming this is a contrived example - the fact there's a better way to write this probably isn't a point. Give the man some chance.
Ritchie Swann Send private email
Tuesday, April 08, 2008
 
 
<<<How do you do that then?>>>

You actually have to set up a permission set within the .Net framework to run per either the computer or by user.

I have an executable I use that opens the entire permission set up in those situations where such permissions like writing I/O, or other permissions are required.
Brice Richard Send private email
Tuesday, April 08, 2008
 
 
<<<So why don't you simply set "Count" to 7?  What's the purpose of the 'Do Until' lines of code?>>>

Great question! My intention was to integrate an array search feature within the 10 LOC.

Sure, I could have set the count to 7 but that's not automating the search functionality and I wanted to show that particular functionality within the code sample.
Brice Richard Send private email
Tuesday, April 08, 2008
 
 
Okay, so you DID want an array search, then it should allow for the possiblity of not finding the element.

Either the Do Until is innocently coded, or it's not needed at all.
AllanL5
Tuesday, April 08, 2008
 
 
<<<Okay, so you DID want an array search, then it should allow for the possiblity of not finding the element.

Either the Do Until is innocently coded, or it's not needed at all.>>>

I'll repeat what I said EARLIER.....in this post....

The search string AND THE ARRAY ARE HARD CODED, so there is no chance of an error occurring, therein obviating the need for error handling of the sample code.
Brice Richard Send private email
Tuesday, April 08, 2008
 
 
I'm a little unsure to what your point is. I think using regexs is a better solution for what you're trying to do. If you rewrite that bit of VB using the System.Text.RegularExpressions.Regex class you should find you get the same functionality for even less lines of code, with the added advantage that nobody's going to call you up about the looping (cause there won't be any).
Ritchie Swann Send private email
Tuesday, April 08, 2008
 
 
... therein obviating the need for the array search, too, which would save like 3 lines of code.

You must be a lot of fun to work with.  Good thing you don't work with anybody else.
AllanL5
Tuesday, April 08, 2008
 
 
Nah, I'm not difficult to work with, but it's interesting that many of the thought processess here on JOS are that there is an extensive propensity to extend BEYOND the scope of an initial concept....

My goal was to create the MOST functionality that you could package in <10 LOC.....and my code is being scrutinized as if it needs to be refactored?

Huh?

I don't get that but hey, to each his own.....now if you can refactor my VB.Net code to <10 LOC be my guest....but if you do that the kicker here is that you MUST MAINTAIN THE SAME FUNCTIONALITY that I had....I don't think it's possible to refactor the code under these circumstances...

As for the REGEX comment.....okay.....great!

If you think REGEX would optimized the code by minimizing additional LOC, then I challenge you to re-generate the solution I provided MAINTAINING the sam functionality I have but with the use of REGEX.....

You might be able to refactor the code by limiting one LOC with a REGEX.....post a solution and let's see what you come up with....
Brice Richard Send private email
Tuesday, April 08, 2008
 
 
Sure, "the most functionality in < 10 lines of code", but if the resulting code is actually incorrect, then you haven't accomplished very much.

That's all I'm saying.  And your absolute unwillingness to even admit there's a problem there is interesting, too.
AllanL5
Tuesday, April 08, 2008
 
 
I saw a raytracer coded as a LINQ expression the other day, but I couldn't be bothered to post it.

Tuesday, April 08, 2008
 
 
<<<Sure, "the most functionality in < 10 lines of code", but if the resulting code is actually incorrect, then you haven't accomplished very much.>>>

What the f&%$ are you talking about?

The "resulting code" is correct as to form and execution.

It works, and unless you change the code to write a text file to a server where you have no permissions, then you'd have to engage additional measures to get the code to run properly.

If you are running as a user on Vista, you set the app.config file for UAC....and if you are running as a user on Win XP, you establish a permissino set under the .Net framework.....again, all of this shit WAY BEYOND the scope of the original post....

My God, I pity those of you who think like that who have to write a damn spec for a software app.......Jesus Sakes Christ.....

Talk about going O V E R B O A R D in thought.....
Brice Richard Send private email
Tuesday, April 08, 2008
 
 
"If you think REGEX would optimized the code by minimizing additional LOC, then I challenge you to re-generate the solution I provided MAINTAINING the sam functionality I have but with the use of REGEX....."

Certainly!

Public Class Tester
Public Shared Sub Main()
Dim SrchString As String = "IN,BL,KD,XL,TP,LF,AC,PR,KG,DX"
Dim Reg As New System.Text.RegularExpressions.RegEx( "(PR)," )
Dim Match As String = Reg.Match( SrchString ).Groups( 1 ).Value
My.Computer.FileSystem.WriteAllText( "test.txt", Match & _
Match.GetHashCode.ToString, False )
End Sub
End Class

That's 9 lines, including the startup code so it can run (which your original post didn't have), it's got as much error handling as your code and produces an identical output to the original.
Ritchie Swann Send private email
Tuesday, April 08, 2008
 
 
Ritchie Swann,

You don't need 2 lines of PHP and a line of BASH to do this.  You can do it all in a single line of PHP, including the file write:
file_put_contents('Test.txt', $Ar[$Count = array_search($CodeFind = "PR", $Ar = explode(',', $SrchString = "IN,BL,KD,XL,TP,LF,AC,PR,KG,DX"))].md5($Ar[$Count]));

Tuesday, April 08, 2008
 
 
"Let's turn this around. Is there a language where the OP's example would require MORE than 10 lines?"

Good ol' Java of course! I got it down to 15 LOC and that's with sacrificing some of the variables Brice used:

import java.io.*;
public class CodeTune {
  public static void main(String args[]) throws IOException {
    String data = "IN,BL,KD,XL,TP,LF,AC,PR,KG,DX";
    String[] array = data.split(",");
    for (int i = 0; i < array.length; i++) {
      if ("PR".equals(array[i])) {
        FileWriter out = new FileWriter("C:/Test.txt");
        out.write(array[i] + array[i].hashCode());
        out.close();
        break;
      }
    }
  }
}
John Topley Send private email
Tuesday, April 08, 2008
 
 
>That's all I'm saying.  And your absolute unwillingness to
>even admit there's a problem there is interesting, too.

Of course there's the problem Brice is trying to solve: finding the already known position of a 2 letter substring within a string WITHOUT resorting to actually hardcoding the position into the source and writing the result to a file.

I do that ALL the time. To code something even remotely as powerful in a comparably efficient language, take for example COBOL, would take roughly 5000 lines of code.
a2800276 Send private email
Tuesday, April 08, 2008
 
 
By the way, this algorithm is known as "moransearch" in case you want to consult Knuth about it.
a2800276 Send private email
Tuesday, April 08, 2008
 
 
"You don't need 2 lines of PHP and a line of BASH to do this."

Oh yeah, I didn't claim my solution was the best, it was just the first thing that flew into my head ;-)
Ritchie Swann Send private email
Tuesday, April 08, 2008
 
 
Underflow
Tuesday, April 08, 2008
 
 
It's a pity that .Net doesn't include a routine for finding the index of a substring within another string.  They could call it String.IndexOf, and it would make this *so* much easier!  Why, I bet you could trim it down to 9 lines of code!

Sadly, without such a method, I'll have to resort to stealing Brice's code since he made the mistake of releasing it before a foolproof protection method existed.
Simon Jester
Tuesday, April 08, 2008
 
 
I wish I could find it again, but I had a game in Apple Basic that was two lines long for a game called "Ski".

It had sidewalls, randomly spawning trees and a scoreboard.
John Goewert Send private email
Tuesday, April 08, 2008
 
 
The gauntlet was thrown thusly: "What is the most functionality you can pack within the smallest number of code lines?"

I see your VB.Net and raise you a Python (though admittedly, not my code): <http://www.goldb.org/goldblog/CommentView,guid,72f089dd-ba0c-4673-8965-b8e2415c5289.aspx>

import BaseHTTPServer

class WebRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
    def do_GET(self):
        if self.path == '/foo':
            self.send_response(200)
            self.do_something()
        else:
            self.send_error(404)
           
    def do_something(self):
        print 'hello world'
       
server = BaseHTTPServer.HTTPServer(('',80), WebRequestHandler)
server.serve_forever()

15 lines for a functioning HTTP server.
Former COBOL Programmer
Tuesday, April 08, 2008
 
 
TO: Former COBOL Programmer

!!!Awesome!!!
Brice Richard Send private email
Tuesday, April 08, 2008
 
 
http://infomesh.net/2003/wypy/

If you remove the shebang it is 10 as written. If you take out the ';' and use newlines like you normally would in python, it is, I think, 6. A fully functioning wiki. Not too bad.

I don't know if this is cheating since you are importing and using 3 libraries, but I'm not sure how that compares with using the .NET string class and My.
Bart Park
Tuesday, April 08, 2008
 
 
Dim CodeFind As String = "PR"
My.Computer.FileSystem.WriteAllText("c:\Test.txt", CodeFind & CodeFind .GetHashCode.ToString, False)

Two lines of code -> does the same thing.

Yawn.
somebody else
Tuesday, April 08, 2008
 
 
<<<That's 9 lines, including the startup code so it can run (which your original post didn't have), it's got as much error handling as your code and produces an identical output to the original.>>>

Ritchie, your solution actually entails a total of (11) LOC when you add in calling the object and then initiating it:

For example:
Dim x As New Class1
  Class1.Main()

My solution runs without the overhead of instantiating an object and yours does not.....

However, it's splitting hairs so I'll give it to you.....I think you did a great job with your solution!

That goes to show the power of programming in that there are entirely different roads which lead to the same destination!

Good job with the regex's!
Brice Richard Send private email
Tuesday, April 08, 2008
 
 
To : a2800276

I think your website is one of the most horrific websites I've ever seen.....however, it is entertaining in a "legacy" sort of way!
Brice Richard Send private email
Tuesday, April 08, 2008
 
 
"The point of this post is to demonstrate what I think is one of the most succinct programming languages in the world - VB.Net."

This post seems to have amply refuted this point, not that anybody who has ever poked there head out of the VB / Access cave really needed any convincing.
Greg Send private email
Tuesday, April 08, 2008
 
 
"Okay.  How many LOC would this be?"

I count 10 Lines Of Connection: 9 plain and 1 tee... call it 10.5 LOC?


"I disapprove of your use of LabView, but I will defend to the death your right to use it"...

- with apologies to Voltaire / Hall
AFTO Send private email
Tuesday, April 08, 2008
 
 
>>This post seems to have amply refuted this point, not that anybody who has ever poked there head out of the VB / Access cave really needed any convincing.<<

Maybe by succinct Brice simply means clear? But yeah, I don't think anybody with a clue would have accused VB<pick your flavor> of being succinct, assuming by succinct you mean 'brief', 'concise', 'expressed in few words' or 'dense'.

http://dictionary.reference.com/browse/succinct
Bart Park
Tuesday, April 08, 2008
 
 
1 line VB code without losing functionality:

My.Computer.FileSystem.WriteAllText("c:\Test.txt", "PR" & _
"PR".GetHashCode.ToString, False)

Tuesday, April 08, 2008
 
 
I've done an 11 line ruby app that dumps out what information your browser always sends up to websites, that I suppose is useful.

Link on my site.
Ritchie Swann Send private email
Tuesday, April 08, 2008
 
 
public class test {
  public static void main(String args[]) throws java.io.IOException {
    java.io.FileWriter out = new java.io.FileWriter("Test.txt");
    for (String item : "IN,BL,KD,XL,TP,LF,AC,PR,KG,DX".split(","))
      if ("PR".equals(item))
        out.write(item + item.hashCode());
    out.close();
  }
}

Here's 9-liner Java code beating your 10-liner VB.Net code, Brice, even including two empty } lines.  Stop being self-important, Brice.
rolling my eyes
Tuesday, April 08, 2008
 
 
I've written a lempel-ziv compression program in under 500 CHARACTERS as part of an entry in the obfuscated C contest. I don't recall how many LINES were involved, but I'm sure I could squash it down to about 10 lines. The contest rules that year discouraged obfuscation due to code layout, so I used a pretty "readable" layout that did no more than one "operation" per statement/line. I'll see if I can dig the old code out and post it here.
Jeffrey Dutky Send private email
Tuesday, April 08, 2008
 
 
When I saw the title of the thread, and Brice as the OP, I just knew it would be comedy gold.
Anonymous Hippopotamus
Tuesday, April 08, 2008
 
 
I thought with regex LOC == Letters of Code.
Stephen Jones Send private email
Wednesday, April 09, 2008
 
 
Brice, Tim's website rocks.

Cobol on Cogs is the future.

Join us on facebook.
Tapiwa Send private email
Wednesday, April 09, 2008
 
 
"I think is one of the most succinct programming languages in the world - VB.Net"

Ignoring the original challenge, I have to bring to your attention one of the Perl implementations of RSA encryption - not a library call but an actual implementation of the famous algorithm (this relies on the Unix dc command):

print pack"C*",split/\D+/,`echo "16iII*o\U@{$/=$z;[(pop,pop,unpack"H*",<>
)]}\EsMsKsN0[lN*1lK[d2%Sa2/d0<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<J]dsJxp"|dc`

From:

http://world.std.com/~franl/crypto/rsa-guts.html
Arethuza Send private email
Wednesday, April 09, 2008
 
 
Actually the Java example given my another poster could be reduced further, despite Java's verbosity (not always a bad thing). Not beautiful, but only 5 lines. The stream is closed on the stream's finalizer and beauty/copy-pasting wasn't outlawed. Thus, making it technically correct. This is only 1 LOC if the boiler plate lines aren't counted.

public class test {
  public static void main(String args[]) throws java.io.IOException {
  new java.io.FileWriter("Test.txt").write("IN,BL,KD,XL,TP,LF,AC,PR,KG,DX".split(",")[Collections.indexOfSubList(Arrays.asList("IN,BL,KD,XL,TP,LF,AC,PR,KG,DX".split(",")), Collections.singletonList("PR"))] + "IN,BL,KD,XL,TP,LF,AC,PR,KG,DX".split(",")[Collections.indexOfSubList(Arrays.asList("IN,BL,KD,XL,TP,LF,AC,PR,KG,DX".split(",")), Collections.singletonList("PR"))].hashCode());
  }
}
Silly post
Wednesday, April 09, 2008
 
 
foreach  (var post in thread)
{
    poster.GetOutMore();
}
Sambo
Wednesday, April 09, 2008
 
 
"That goes to show the power of programming in that there are entirely different roads which lead to the same destination!"

Hey - I said that originally!
Tim Toady
Wednesday, April 09, 2008
 
 
"What is the most functionality you can pack within the smallest number of code lines?"

How about 'em components, can we use those? If I get a database server component and call it like

  DatabaseServer.Active = true;

will that count? A single liner which in turn leads to a fully functional and operational database server, that can accept several simultaneous connections? I think that's pretty much functionality packed to a single line.

OTOH, I could just set the Active property in the property editor to be true, and be done without writing any code...

This is stupid. No?
El Dorko
Wednesday, April 09, 2008
 
 
"Cobol on Cogs is the future."

What about Visual BASIC on Vintage Bicycles?
Ritchie Swann Send private email
Wednesday, April 09, 2008
 
 
>>What about Visual BASIC on Vintage Bicycles?

Maybe the resident VB guru, Brice, might try an implementation.
Tapiwa Send private email
Wednesday, April 09, 2008
 
 
>> What is the most functionality you can pack within the smallest number of code lines? <<

Just remember that this is a game. It bears no resemblance to the usefulness or viability of a programming language in the real world.

>> The point of this post is to demonstrate what I think is one of the most succinct programming languages in the world - VB.Net <<

When you say "in the world", I suspect you mean "that I know". Have you ever played with Perl, APL, or J? These can be much more scary in their succintness. For example, this is quicksort implemented in J:

quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^: (1<#)
Mark Pearce Send private email
Wednesday, April 09, 2008
 
 
In Python one could code Brice's example as (you'll have to do the whitespace)

def dumpit(sought,source,pathname):
    open(pathname,'w').write("%s: %d\n" %
                            [(x, hash(x)) for x in source.split(',') if x == sought][0])

If you want to handle not-found conditions and close the file, it's a trifle longer:

def found_and_hash(sought,searched,pathname):
    """ sought is a string that may appear as part of a list
    comma-delimited in the string searched. Pathname is where
    where write the result if found."""

    message = '%s not found in %s' % (sought, searched)
    foo = [x for x in searched.split(',') if x == sought]
    if len(foo) > 0:
        message = '%s: %d\n' % (foo[0], hash(foo[0]))
    ofh = open(pathname, 'w')
    ofh.write(message)
    ofh.close()
George Jansen Send private email
Wednesday, April 09, 2008
 
 
Pet 2001:

WAIT 6502,100
Sunil Tanna
Wednesday, April 09, 2008
 
 
Let me rephrase my initial opinion of VB.Net:

VB.Net is one of the most succinct, intuitively constructed programming languages in the world. While other languages may be substantially minimal in their written implementation, only VB.net contains both the conciseness AND the intuitiveness needed to facilitate its understanding in an accelerated fashion.

While a quicksort in J may look like this:

quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^: (1<#)

OR.... a PHP routine which is packed full of functionality looks like this:
<?php $s="IN,BL,KD,XL,TP,LF,AC,PR,KG,DC"; $c = "PR";
if ( ereg( "(" . $c . "),", $s, $a ) ) echo md5( $a[ 1 ] ); ?>


NONE of that syntax makes any semblance of sense to me and in fact it visually looks more like gibberish than a language that should move closer to an understandable human language than an esoteric series of unintelligible character sets.
Brice Richard Send private email
Wednesday, April 09, 2008
 
 
"While other languages may be substantially minimal in their written implementation, only VB.net contains both the conciseness AND the intuitiveness needed to facilitate its understanding in an accelerated fashion."

What about VB6? Or Sinclair BASIC?
John Topley Send private email
Wednesday, April 09, 2008
 
 
>> ...than a language that should move closer to an understandable human language... <<

You're like a plumber who wants to use a single tool for everything. That might be fine if you're a plumber who only ever does a single type of job, e.g. unblocking drains. But there are many many job types, and each language has its own set of niches.

What you're really saying is that in your specific niche, VB is the most succinct language with which you're familiar. That is a *long* way from your original claim:

>> The point of this post is to demonstrate what I think is one of the most succinct programming languages in the world - VB.Net <<
Mark Pearce Send private email
Wednesday, April 09, 2008
 
 
>>While other languages may be substantially minimal in their written implementation, only VB.net contains both the conciseness AND the intuitiveness needed to facilitate its understanding in an accelerated fashion.<<

I'll take python over VB on both counts. It is more concise, more readable and more intuitive in most cases. You can make it look horrible like the wiki example I game, but idiomatic python is about as clear as you can get in a programming language. But you asked for how much functionality could you pack in 10 lines and to do that, you need to be... shall we say creative?

>>it visually looks more like gibberish than a language that should move closer to an understandable human language than an esoteric series of unintelligible character sets.<<

So you're more concerned with clarity than succinctness, which is fine. It's like math notation. To do the equivalent of a math proof that takes half a page of mathematical gibberish you would probably need a dozen pages of understandable human language to explain what is going on in those symbols.

See, the problem here is that for as much as you can't understand generalists and people that know several languages reasonably well, those sorts of people are going eat you for lunch when it comes to stuff like this.

Throw out a 'what can you do in 10 lines of code' thread and this is the hard core stuff you'll get. Fully functioning wikis vs. parse a string and write its hash to a flat file on the root drive. Or one line encryption algorithms. That's succinct. And you even said 'use any language you like' and now you have problems with the responses because they look like gibberish.

And in the spirit of succinctness, "contains both the conciseness AND the intuitiveness needed to facilitate its understanding in an accelerated fashion" can be reduced to "easy to grok" with out losing any of its meaning.
Bart Park
Wednesday, April 09, 2008
 
 
"NONE of that syntax makes any semblance of sense to me and in fact it visually looks more like gibberish than a language"

Christ help you if you ever have to read any Lisp code, I mean that's got "car" and "cdr" in it, not to mention all those brackets. I mean how can "cdr" be a word - it hasn't got any vowels! And writing "1 + 2" as ( + 1 2 ) - no humans read mathematical expressions like that!

;-)
Ritchie Swann Send private email
Wednesday, April 09, 2008
 
 
Compared to brainfuck, lisp is like reading the sunday comics.
Bart Park
Wednesday, April 09, 2008
 
 
Also, I need to call the Department of Redundancy Department about "visually looks". If it were "audibly felt" or "visually smelt", sure, you need the words.
Bart Park
Wednesday, April 09, 2008
 
 
First Brice says:

>> What is the most functionality you can pack into less than 10 LOC? Use any language you like....

Then he tries to change the rules:

>> NONE of that syntax makes any semblance of sense to me and in fact it visually looks more like gibberish than a language that should move closer to an understandable human language than an esoteric series of unintelligible character sets. <<

Brice, many developers on JoS have worked with many languages, some of which you never even heard of. As Bart say, why not just admit that you're way out of your depth?
Mark Pearce Send private email
Wednesday, April 09, 2008
 
 
Brice,

"While other languages may be substantially minimal in their written implementation, only VB.net contains both the conciseness AND the intuitiveness needed to facilitate its understanding in an accelerated fashion."

Thus you know any single one of these languages deep enough to make such an absolute statement?

http://en.wikipedia.org/wiki/Alphabetical_list_of_programming_languages

http://en.wikipedia.org/wiki/List_of_BASIC_dialects
...
Wednesday, April 09, 2008
 
 
For Brice's benefit, here is the same php code formatted to be slightly more readable, using his variable names, and adding paraphrasing comments for concepts he may be unfamiliar with.....

<?php
$srchString = "IN,BL,KD,XL,TP,LF,AC,PR,KG,DC";
$codeFind = "PR";
// Search for the value of 'codeFind' plus a comma, and
// store the resulting value (without the comma) in 'ar'
if ( ereg( "(" . $codeFind . "),", $srchString, $ar ) )
{
  // Note: $ar[ 0 ] is the whole string,
  // $ar[ 1 ] is the back reference
  echo md5( $ar[ 1 ] );
}
?>
Ritchie Swann Send private email
Wednesday, April 09, 2008
 
 
"While other languages may be substantially minimal in their written implementation, only VB.net contains both the conciseness AND the intuitiveness needed to facilitate its understanding in an accelerated fashion."

It's not every day you see someone taking this many words to say something that is so dumb in such an awkward way.
Greg Send private email
Wednesday, April 09, 2008
 
 
<<<And you even said 'use any language you like' and now you have problems with the responses because they look like gibberish.>>>

Let me clarify....in the spirit of providing a unified experience on this website, and contrary to what many of you may think of me, I attempt to craft my subject Posts for the benefit of the JOS readership....not just for me...which is why I gave my opinion about the referenced example being gibberish.

I did say and did welcome the presentation of any language wherein functionality could be reduced to <10 LOC....but that doesn't mean that I'm going to suddenly begin a learning course in the language!

However, those that graciously offered their code implementations - thank you.....an its in that spirit that I sincerely hope that others who are reading this post might educationally benefit.

I still think many of the programming languages past and present are gibberishly constructed but that doesn't mean that I am closed to them being presented in this thread. In fact, I welcome them.
Brice Richard Send private email
Wednesday, April 09, 2008
 
 
>> for the benefit of the JOS readership

Frankly, the one benefit I've received from reading this is that the next time I see a post from Brice that purpurts to teach anything, I should immediately close my browser & go do domething that's *actually useful*.
Dave Send private email
Wednesday, April 09, 2008
 
 
Brice actually provides a valuable service to the JoS pack of hyenas. His posts can be used as raw material to help us construct simple interview questions that prevent false positives.
Mark Pearce Send private email
Wednesday, April 09, 2008
 
 
Ah, it's been a couple week since a good Brice feeding time. Thanks fellow hyenas, I'm full.
KooKoo Kachoo
Wednesday, April 09, 2008
 
 
"I still think many of the programming languages past and present are gibberishly constructed..."

Not as much as that sentence! There's no such word as "gibberishly".
John Topley Send private email
Wednesday, April 09, 2008
 
 
Dave: "Frankly, the one benefit I've received from reading this is that the next time I see a post from Brice that purpurts to teach anything, I should immediately close my browser & go do domething that's *actually useful*."

See? JOS - a daily educational experience. :-)

My submission:

Windows.MessageBox(0, 'Brice is an idiot.', 'Pointing out the obvious', MT_ICONINFORMATION or MB_YES);

One line.
Ken White Send private email
Wednesday, April 09, 2008
 
 
I feel like I'm watching an episode of Da Ali G show, but only the star really is as dumb as he "pretends" to be.
Cornelius Send private email
Wednesday, April 09, 2008
 
 
"NONE of that syntax makes any semblance of sense to me and in fact it visually looks more like gibberish than a language"

Must not be ROCK SOLID, STELLAR and ROBUST then!
1st JOS Brice Fan Club
Wednesday, April 09, 2008
 
 
An 'American tourist' springs to mind reading this.

I have meet (and currently work with) VB programmers who almost uniquely among working programmers, seem to be unaware of the existence of other languages.

I remember when I had a job at one stage porting VB code to Delphi, demonstrating OO aspects of Delphi & the VCL. They just didn't get it, claiming that none of that is required.

Then VB.NET came out; much more Delphi feel to it than VB & suddenly things like inheritance was a good thing.

I still don't even get what Brice was trying to show; it is a silly example with a hard-coded string that is neither the shortest nor the easiest to read. Even if it was, just a little issue like having to 'set up a permission set within the .Net framework to run per either the computer or by user' would take more time & effort to sort than any trivial programming problem.

For small toy programs I use TAWK or C#, for bigger apps I use C++/Delphi/C#. Try using more than one language and platform & you might really spot what is good & what is not with VB.NET. As a hint however, VB appears to be a dying language with the message from Microsoft being 'use C#'.. and more importantly these days, Google pushing Python.

BTW - Can you develop for the iPhone/iTouch with VB, or is Brice just going to target the Zune platform?
Grant Black Send private email
Wednesday, April 09, 2008
 
 
Yes, because "Dim" actually a perfectly sensible keyword for declaring variables.  Its not gibberish at all.  (WTF does Dim mean?!?)

Wednesday, April 09, 2008
 
 
>> (WTF does Dim mean?!?)

"Dim" was a keyword in very old BASIC dialects, back in the 60s and the 70s. It meant "DIMension", was for arrays, and was used to specify the size of array type variables in each axis. Later DIM was co-opted to be used to declare string variables. This made sense when each string variable had a specification for its maximum length, like an array.

Finally MS decided to use DIM to indicate all variable declarations.
Bored Bystander Send private email
Thursday, April 10, 2008
 
 
"I have meet (and currently work with) VB programmers who almost uniquely among working programmers, seem to be unaware of the existence of other languages."

VB is (was; nowadays VB.NET) is the MAC of programming languages. It's good, you can do just about everything with it, and it draws narrow minded people like flies.
El Dorko
Thursday, April 10, 2008
 
 
"It draws narrow-minded people like flies."

As in, VB adherents are narrow-minded people? Or the mere mention of VB draws out narrow-minded people to bad-mouth it?
Raj Chaudhuri Send private email
Thursday, April 10, 2008
 
 
>> It's good, you can do just about everything with it, and it draws narrow minded people like flies.<<

For some reason, it also draws like flies the narrow-minded language bigots who attack it.

VB (it's no longer called VB .NET (note the extra space)) is a first-class language on the .NET platform, and is increasingly diverging from C# in what it makes easier for the developer to do. In a way, it's going back towards its roots.

It also has a quite different cultural feel to C#. In fact, it's great that the .NET platform enables these two cultures to work side-by-side. Then look at languages like F# from the functional programming culture, and you start to see the power of a single-platform multi-language model.
Mark Pearce Send private email
Thursday, April 10, 2008
 
 
There's nothing new about "single platform, multiple language"; there have been programs that combine multiple languages on a single platform for _decades_.  C programs calling out to FORTRAN libraries to crunch numbers, for example, or innumerable high-level languages calling out to C libraries.

The newish thing in .NET is that the platform is (a) object-oriented, unlike classic polylingual coding which is limited to procedural interfaces, and (b) the CLR was _designed_ to run multiple languages, unlike the JVM, which is possibly why non-Java languages on the JVM have not really taken off in the way that non-C# languages have on the CLR.
Iago
Thursday, April 10, 2008
 
 
I think we all agree that the issue here isn't VB, which really *is* a decent enough language if you use it properly (i.e. not like it was VB6), but rather Brice's typical narrow-minded viewpoint based on his tiny niche area. 

Remember, the main reason everyone is so harsh to Brice isn't because he's a VB developer, it's because he's very narrow minded and ignorant of the world around him - he has no desire to learn anything other than his VBA/VB.NET because "For me, that's all I need", which is fine and dandy, but he's also unwilling to consider anything other than what he uses to be remotely important, simply because HE finds no practical use for it.  The minute he encounters something that he can't shoehorn into his narrow mindset, it's clearly a problem with someone else, and not with himself.

Untalented and unaware of it, indeed.
WayneM. Send private email
Thursday, April 10, 2008
 
 
Don't you folks find it strange that every time Brice comes up with a post, all the people reading have something to say in response. This is a typical case in point. The comments at this point are 90+ for this post, whereas the second largest number would be in the thirties or so on this page. Is there a sadistic pleasure derived out of insulting him?

But that also makes me wonder if Brice is a masochist, that keeps posting!
V. Garg
Thursday, April 10, 2008
 
 
"if Brice is a masochist"

If that is the case, can I recommend sendmail configuration files? For the discerning syntactic masochist these do offer some of the best real-world experiences.

For example, Towers of Hanoi:

S49
RHANOI:$+    $:1 2 3$1
R$-$-$-$*[$+]    $:$1$2$3$4         
R$-$-$-        $@$1$2$3
R$-$-$-@$*    $:$>49 $1$3$2$4   
R$-$-$-$*    $:$>49 $2$3$1$4[Move Top Disk Of Peg $1 To Peg $3]     
R$-$-$-$*    $:$3$2$1@$4 

And this is a real configuration format used by one of the leading MTAs. :-)
Arethuza
Thursday, April 10, 2008
 
 
>> think we all agree that the issue here isn't VB, which really *is* a decent enough language if you use it properly (i.e. not like it was VB6), but rather Brice's typical narrow-minded viewpoint based on his tiny niche area. <<

Your apparent bias against VB6 is arguably no better than Brice's unwillingness to learn anything other than VB/VBA.

Brice is just an interesting and outspoken example of a trend that's endemic in our industry. Namely passing off cultural and technical biases as objective arguments.
Mark Pearce Send private email
Thursday, April 10, 2008
 
 
I'm not biased against VB6 - I'm biased against people who use it poorly without proper object-oriented practices.  These people then migrate to VB.NET and continue to hack together code without using industry best practices, leading the oh-so-common swamp of garbage legacy code so prolific in our industry.

While I'm certainly aware that the same can (and does) happen in any language, I've noticed a trend that the majority of code seems to come from people with a pre-.NET VB background; such things as using global functions for everything, putting whole routines in event handlers instead of functions, no objects at all, etc. all seem to be related to the fact that VB6 and prior versions made it easy to just hack together software without using any good design principles.
WayneM. Send private email
Thursday, April 10, 2008
 
 
"If that is the case, can I recommend sendmail configuration files?"

*shudders*

I take you've read "The Unix Hater's Handbook" (it's freely available now) and what it has to say on the subject. Suffice to say, sendmail is the most widely used bit of software I know of where people have written compilers (such as m4) for its configuration file.
Ritchie Swann Send private email
Thursday, April 10, 2008
 
 
>>Don't you folks find it strange that every time Brice comes up with a post, all the people reading have something to say in response.<<

I don't find it that strange, especially in this thread.

1. Many of the earlier responses in the thread actually make some attempt to respond to the OP in some non-insulting manner. There are several good examples.

2. Brice spends a lot of time putting down other people in one way or another. If it's not his way it must be stupid is what most of his comments boil down to. Which in effect is calling everybody not Brice like stupid. Most people, especially in this profession, don't like being called stupid.

3. Brice's tone (maybe it is simply the online forum medium) is often arrogant. He's a self taught programmer who chooses to not go beyond working with VB in Access and then talks down to people that have been doing this job for two or more decades, know many languages very well, that have Master's degrees or greater and solve problems that Brice, judging by his posts, could not begin to wrap his head around. Strangely some people find this insulting and feel the need to fire back.

4. Some of us hope, perhaps in vain, that some of the comments or advice will actually stick. Brice is probably a smart enough guy and I would bet in his circle he runs with probably the big fish in the little pond when it comes to brain power. But he has demonstrated on many occasions that some of his programming and design practices could use some improvement.

5. Many of Brice's posts are like a train wreck or the Howard Stern Show that was on E! You know you don't need to watch, you don't really want to, but you can't turn away.

6. Perhaps inadvertently, he attracts much of this attention himself. This thread is a great example. It starts out innocently enough. "What can you do in 10 LOC?" Some interesting examples get posted. They get dismissed as gibberish, Brice lauds regex guy and postulates "VB.Net is one of the most succinct, intuitively constructed programming languages in the world" when all of the evidence in this thread, not to mention the rest of the world, says otherwise. Sometimes one has to wonder what color the sky is in Brice's world.

7. This is honestly a lot more fun than most other threads. At least in these threads you have people interacting. And, to Brice's credit, he isn't a hit and run poster. He comes back to his threads. He responds. A nice change from the majority of people that post a question or propose something and get a few pointers and suggestions and then never even bother with a 'thanks' or 'that's interesting but it didn't help' or something. You could perhaps think somebody posted the message, then 10 minutes later walked out and got hit by a bus.
Bart Park
Thursday, April 10, 2008
 
 
>> I'm not biased against VB6 - I'm biased against people who use it poorly without proper object-oriented practices. <<

I'm sorry, possibly I misunderstood your post as there being a problem with VB6 (in the wrong hands). If you didn't mean this, my apologies for getting it wrong.

I agree that it's never the tool, it's always the developer.
Mark Pearce Send private email
Thursday, April 10, 2008
 
 
1st JOS Brice Fan Club = AllanL5 ?

Bart Park, well stated. 

Been a regular JOS visitor myself and the place wouldn't be the same without Brice's view of the world.  Love that guy. 

AllanL5 knows how to push his buttons and does a pretty dam good job of it.  Hilarious.
Keepin it real
Thursday, April 10, 2008
 
 
Well thanks to Bart Park for his insight into the issue...
Brice Richard Send private email
Thursday, April 10, 2008
 
 
this is fun.  we can use libraries and frameworks?



int result=doEverythingIWantYouToDo()


you name the functionality, I will add it.

I WIN!!!!!!!!!!
worldsSmallestViolin
Thursday, April 10, 2008
 
 
"As in, VB adherents are narrow-minded people? Or the mere mention of VB draws out narrow-minded people to bad-mouth it?"

Both, really. Mind you, I've done work in VB and VB .NET (not currently though) and a number of other languages, and I personally have nothing against it really.
El Dorko
Friday, April 11, 2008
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz