🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.java
Article #209

Re: Advice to Java proponents (was Re: Will Java kill C++?)

#209
From: Alan L. Lovejoy
Date: Fri, 12 Apr 1996 10:05
124 lines
5455 bytes
Gord Wait wrote:
> 
> Rick DeNatale wrote:
> >
> > It doesn't bode well for the ultimate fate of a language when important
> > things that people want to do with the language aren't provided in
> > standard ways in the language. This is one of the reasons that we don't
> > have Pascal to kick around much anymore, one of the reasons that C took
> > over Pascal's predominant place as a personal computer programming
> > language is that Pascal left any kind of reasonable I/O as an exercise to
> > the reader, and there was no common way of doing it, while C's (actually
> > Unix's) stdio package was easily supported on most of the common operating
> > systems.
> 
> I tend to feel this way about the AWT portion of Java: one week into the
> language and you get the urge to toss out AWT and roll your own UI
> classes. (Don't do it!! pester the Javasoft people to fix AWT quickly!)
> 
> One thing nice in the language is the easy TCP/IP hooks already there!
> Since the base library set already includes "easy" TCP/IP support, java
> just might live up to the title of king of the "networking" languages..
> 
> As for non-networked tasks, Java really needs work to compete with the
> established languages (tools, Standard libs etc).
> 
> Gord Wait       S-MOS Systems Vancouver Design Centre
>                 (B.C. Canada eh!)
> gord@vdc.smos.com
> 
> ---------------
> This sig is under constru

Proud of the networking functions in the Java library, are we?

VisualWorks Smalltalk has had such for quite a while now.  Consider
one of the example class methods of the class SocketAccessor (the
other examples show a simple server and a simple client, and a simple
talk server and talk client):

SocketAccessor class>>requestTimeService
	"This example uses the IP/UDP time service, which returns the 
	time in seconds since Jan 1, 1900 as a four-byte integer. 
	Thus, we are demonstrating raw access through a socket instead
	of using an external stream.  We explicitly convert the raw result
	and print it in the transcript. We assume that a time server is 
	running on the host that you name."

	"[SocketAccessor requestTimeService] <-- to run the example"

	| socket address buffer replySize host time |

	"Get the host name from the user."
	host := Dialog
		request: 'Which host is running a time server?'
		initialAnswer: 'localhost'.

	"Create a datagram socket."
	socket := SocketAccessor newUDP.

	"The following is kept in an unwind block in case an exception is 
raised."
	[
		"Bind the socket to the server's address."
		address := IPSocketAddress
			hostName: host
			port: (IPSocketAddress servicePortByName: 'time').
		socket connectTo: address.
	
		"Any message will trigger the time server."
		socket writeAll: 'What time is it?'.

		"Initialize the buffer for a four-byte response."
		buffer := ByteArray new: 4.

		"Get the raw time from the server -- timeout after 10 seconds."
		(socket readWaitWithTimeoutMs: 10000) 
			ifFalse: [replySize := socket readInto: buffer]
			ifTrue: [Transcript cr; nextPutAll: 'No reply'. ^nil]

	] valueNowOrOnUnwindDo: [socket close].
	"If the stack is unwound due to an error, or the block terminates
	normally, the socket will be closed in either case."

	replySize = 4

		"If four bytes were returned, convert to time and display it."
		ifTrue: [
			
			"Convert the byte array to an integer (seconds since 
1900)."
			time := (UninterpretedBytes from: buffer)
				unsignedLongAt: 1
				bigEndian: true.

			"Convert the integer to time.
			Subtract one year (Smalltalk time begins in 1901)."
			time := Time aTimeString: time - (60*60*24*365).

			"Display the time."
			Transcript cr; nextPutAll: 'The server''s clock says: ', 
time]

		"If four bytes were not returned, it's either nothing (zero) or 
invalid."
		ifFalse: [
			replySize = 0
				ifTrue: [Transcript cr; nextPutAll: 'No 
response']
				ifFalse: [Transcript cr; nextPutAll: 'Invalid 
reply format']].
	Transcript endEntry


I believe it was at OOPSLA '87 in Orlando that I first saw Smalltalk processes
on different workstations connected to a LAN using sockets to simulate a ball
traveling from one screen to the next.  That's 8.5 years ago.  At the time,
I was working on a network management system implemented in Smalltalk and
Objective-C.  The Smalltalk clients exchanged objects with the Objective-C
sever system--using TPC/IP over Ethernet.  I'm glad that Java will finally
force everyone to put this functionality in the standard package.

I wonder how easy this stuff is in Telescript?  

--Alan
Technical Details
Message-ID: <316E2AD0.17C3@concentric.net>
Path: arc1-ca.pugleaf.net!newsfeed.concentric.net!news
References: <315BFB16.B74@isg.de> <4jgv6t$hon@kadath.zeitgeist.net> <4k3cdo$np5@taurus.adnc.com> <DpG1s1.GC9@research.att.com> <4k71f5$ot5@news2.ios.com> <31684F33.2528@ibm.net> <denatale-0804960926250001@grail1213.nando.net> <316DA213.767B@vdc.smos.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!newsfeed.concentric.net!news
From: "Alan L. Lovejoy" <alovejoy@concentric.net>
Newsgroups: comp.lang.java,comp.lang.c++,comp.lang.smalltalk
Subject: Re: Advice to Java proponents (was Re: Will Java kill C++?)
Date: Fri, 12 Apr 1996 03:05:04 -0700
Organization: Modulation
Message-ID: <316E2AD0.17C3@concentric.net>
References: <315BFB16.B74@isg.de> <4jgv6t$hon@kadath.zeitgeist.net> <4k3cdo$np5@taurus.adnc.com> <DpG1s1.GC9@research.att.com> <4k71f5$ot5@news2.ios.com> <31684F33.2528@ibm.net> <denatale-0804960926250001@grail1213.nando.net> <316DA213.767B@vdc.smos.com>
Reply-To: alovejoy@concentric.net
NNTP-Posting-Host: cnc009032.concentric.net
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 3.0B2 (Win95; I)