Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



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

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
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?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-18-2008, 05:19 PM Re: Do you miss UNIONs?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
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.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 04-18-2008, 05:31 PM Re: Do you miss UNIONs?
Webmaster Talker

Posts: 560
Trades: 0
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
__________________

Please login or register to view this content. Registration is FREE
170 Designs is offline
Reply With Quote
View Public Profile
 
Old 04-18-2008, 06:00 PM Re: Do you miss UNIONs?
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
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.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 04-18-2008, 06:44 PM Re: Do you miss UNIONs?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
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...
__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 04-18-2008 at 06:47 PM..
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 04-20-2008, 11:28 AM Re: Do you miss UNIONs?
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
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
__________________

Please login or register to view this content. Registration is FREE

willcode4beer is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Do you miss UNIONs?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 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.29032 seconds with 12 queries