Reply
Do you miss UNIONs?
Old 04-18-2008, 04:05 PM Do you miss UNIONs?
Learning Newbie's Avatar
Moderator

Latest Blog Post:
What’s He Looking At?
Posts: 4,986
Name: John Alexander
There are no union types in the .NET framework, and I can't remember the last time I've heard any developer mention them.

In .NET land, the runtime enforces locality for us, automatically. Variables that are declared together, occupy memory together. This is what a union does, as opposed to a class or a struct (which are the same thing in C).

Does anybody miss using unions? Am I missing anything in my analysis? What do open source linux and PHP people do?
__________________
4 ways to improve the lives of the "bottom billion"

"HEY YOU KIDS GET OFF MY LAWN!" -John McCain
Learning Newbie is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 04-18-2008, 04:19 PM Re: Do you miss UNIONs?
tripy's Avatar
Fetchez la vache!

Posts: 1,989
Name: Thierry
Location: In the void
Hmmm...
John, you lost me there.
You are not talking about union joints, aren't you ?

I don't remember having ever used an union keyword in my C days.
And let me check back my C reference.... Ok, I see now. I've used the struct definition, but never was introduced about the UNION keyword.
So I kind of used it without knowing it.

I cannot say I miss it then.
And as for the PHP question, I don't believe there is anything like that in it.
And It does sense, in a certain way...
PHP has been designed from the ground to be ran and shutdown sequentially. There are no engine nor binary that stay in memory, except when you use the POSIX extensions to thread a process, but it's a bit special, and out of the scope of 99.999% of PHP programming.

So, no, nothing similar exists in the PHP world, as far as I know.
__________________
Listen to the ducky: "This is awesome!!!"

tripy is online now
Reply With Quote
View Public Profile
 
Old 04-18-2008, 04:31 PM Re: Do you miss UNIONs?
Webmaster Talker

Posts: 560
I never really used the Unions or Strucs that much in C to begin with. Although I must admit, they did allow you to do some pretty neat things

Matt
170 Designs is offline
Reply With Quote
View Public Profile
 
Old 04-18-2008, 05:00 PM Re: Do you miss UNIONs?
Learning Newbie's Avatar
Moderator

Latest Blog Post:
What’s He Looking At?
Posts: 4,986
Name: John Alexander
Quote:
Originally Posted by tripy View Post
PHP has been designed from the ground to be ran and shutdown sequentially. There are no engine nor binary that stay in memory, except when you use the POSIX extensions to thread a process, but it's a bit special, and out of the scope of 99.999% of PHP programming.
I'm curious about this, can you expand a little bit? I would think any language is designed to run in a given sequence or series, until your code runs to its end, quits, or dies or is killed? Unless, as you say, the programmer decides to use threading, which then changes things.
__________________
4 ways to improve the lives of the "bottom billion"

"HEY YOU KIDS GET OFF MY LAWN!" -John McCain
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 04-18-2008, 05:44 PM Re: Do you miss UNIONs?
tripy's Avatar
Fetchez la vache!

Posts: 1,989
Name: Thierry
Location: In the void
Quote:
I'm curious about this, can you expand a little bit?
Sure. But those will not be strongs facts, just impressions, and things I've heard/read in the past years.

PHP was developped at first as a CGI program to replace some keywords with computed values. Nothing more than a simple parser, as explain the acronym:
PHP: Hypertext Preprocessor

Being designed to be instantiated at a time X, and destroyed at a time X+Y milliseconds, I can understand that some neat features that we found in languages like C are not present, because the PHP engine rely on the underlying system for some fundamentals.
PHP has been designed to be plain simple from beginning, and his hidding a lot of advanced concept from the developers, which lead it to the current state of disaprobation through "enterprise level" language adopters.
Try to say"php" to a C#, vb.net or java dev. crowd and look at the disgusted faces...

It can be considerd as good, or bad, following the point of view.
I personally find it more good than bad. I learned with PHP, and ended with a syntax close to C even in that loosely typed world, just because I've it to be less prone to error.
It's a personnal effort, though, that nor many PHP developpers will make.
And I think that most advanced PHP dev will sooner or later tend to C# or Java, either by interest or by necessity. It's where the jobs are, simply put. At least here, in Europa.

The main difference I see, is that compiled programs (and in an extend, .Net and Java web apps), which will be instantiated by a virtual machine and stay in memory, must have those kind of optimization available. Simply to limit the footprint it will have on the system. They are often designed to run until an exception or a particular signal telling them to shut down. PHP scripts, on the other hand are designed to die on a short notice, and if they don't it's the exception.

PHP don't thread process, it forks them. A notable difference:
http://gauss.ececs.uc.edu/Users/Fran...ads/forks.html

You can clone a process and detach it in the background, but some limitations that the engine put will stay. Not the limited run time (when you are in a console based PHP script, it's automatically set to infiny), but on the max memory size that the script can grow to.
This can bring to a severly imparied server, f you don't handle GC nor emergency exit correctly. Been there, done that and realised more realistically how desktop and web app yould be different...
__________________
Listen to the ducky: "This is awesome!!!"


Last edited by tripy : 04-18-2008 at 05:47 PM.
tripy is online now
Reply With Quote
View Public Profile
 
Old 04-20-2008, 10:28 AM Re: Do you miss UNIONs?
willcode4beer's Avatar
Webmaster Talker

Posts: 695
Name: Paul Davis
Location: San Francisco
Quote:
Originally Posted by Learning Newbie View Post
There are no union types in the .NET framework, and I can't remember the last time I've heard any developer mention them.

In .NET land, the runtime enforces locality for us, automatically. Variables that are declared together, occupy memory together. This is what a union does, as opposed to a class or a struct (which are the same thing in C).

Does anybody miss using unions? Am I missing anything in my analysis? What do open source linux and PHP people do?
I know I miss them. Especially when working with binary file types.
I mostly work with Java, the new memory mapped io don't really match up. When I need something similar now, I end up using byte arrays.

I kind of understand why Java doesn't have them (platform independence), it was always a bit of work making the code behave the same on both big and little endian CPUs.

I java at least gave us pointers, then it could be done with some byte code engineering. I suppose you face the same issues with c# and .net
__________________
Paul Davis
willCode4Beer.com (coding for all the right reasons)
willcode4beer is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Do you miss UNIONs?
 

Thread Tools

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

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




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.15416 seconds with 13 queries