Jump to content
Join our Facebook Group ×
An Old School Catholic Message Board

Recommended Posts

Laudate_Dominum
Posted

[quote name='kamiller42' date='07 October 2009 - 04:28 PM' timestamp='1254947316' post='1980180']
Laudate_Dominum,

The C parts of C# I do not like:

1) Case sensitivity. (That is so 1970s.)
2) Case sensitivity. (That is so 1970s.)
3) Curly braces. Begin-End reads so much more naturally and easier to format.
4) Looping syntax. Very C like. More powerful but contorted.
5) No declaration section. Pascal has section in a source file where types are declared. It is a great kind of table contents for the code that implements. C#'s work around is an IDE trick, collapsing code.

I do applaud them for adopting Pascal's dot notation for objects.
[/quote]
Lol! I can sort of recall reading articles answering all of those points and as far as I'm concerned those are all matters of opinion (for the most part)). The turbo pascal guy and the delphi guy invented the darned thing so you might get a kick out of reading their rationale.
I hear what you're saying to a point though; compared to a language like Python C# feels a bit 1970's (at least in its basic syntax), but my belief is that they wanted to lure people away from Java in hoards so opted for those conventions. If this was the intention I think they did a good job. In my opinion Java feels like a hack job compared to C#.

While 1-4 don't resonate with me #5 does make me pause and think for a minute. I'm not sure where I stand, I find pluses and minuses to both approaches. I'm not crazy about the code regions and I absolutely hate code written by region happy developers! I've seen stuff almost this bad:

[code]
#region Name Property
public string Name { get; set; }
#endregion

goto hell; // grr!
[/code]

1/2. Personal preference; I prefer case sensitivity.
3. Another personal preference but one I can't relate to at all. I can't stand verbose languages.
4. Yeah but C# now has heavy functional leanings. With 3.0 we got anonymous types, lambda expressions, etc. and they're working on concurrent programming constructs for future releases.

:idontknow:

P.S. I can't believe I'm engaging in C# apologetics. For the record Microsoft can kiss mine.

Posted

[quote name='Laudate_Dominum' date='07 October 2009 - 09:29 PM' timestamp='1254965356' post='1980468']
Lol! I can sort of recall reading articles answering all of those points and as far as I'm concerned those are all matters of opinion (for the most part)). The turbo pascal guy and the delphi guy invented the darned thing so you might get a kick out of reading their rationale.
I hear what you're saying to a point though; compared to a language like Python C# feels a bit 1970's (at least in its basic syntax), but my belief is that they wanted to lure people away from Java in hoards so opted for those conventions. If this was the intention I think they did a good job. In my opinion Java feels like a hack job compared to C#.[/quote]
They probably did ask Anders to use C syntax to win over Java and C++ developers. I think most C# developers probably came from VB roots. Not sure if they really won over tons of Java developers. A big kudo for Java is that it is every where. I mean every where, PCs, phones, Blu-ray players, web servers, and on and on.

[quote]While 1-4 don't resonate with me #5 does make me pause and think for a minute. I'm not sure where I stand, I find pluses and minuses to both approaches. I'm not crazy about the code regions and I absolutely hate code written by region happy developers! I've seen stuff almost this bad:

[code]
#region Name Property
public string Name { get; set; }
#endregion

goto hell; // grr!
[/code]
[/quote]
Wow. That is bad.

[quote]
1/2. Personal preference; I prefer case sensitivity.
3. Another personal preference but one I can't relate to at all. I can't stand verbose languages.
4. Yeah but C# now has heavy functional leanings. With 3.0 we got anonymous types, lambda expressions, etc. and they're working on concurrent programming constructs for future releases.

:idontknow:

P.S. I can't believe I'm engaging in C# apologetics. For the record Microsoft can kiss mine.
[/quote]
#3 - I used to abbreviate a good bit. I don't think too much. Over the years, I have increased my variable and method names. Code in the past tried to be terse and cute. That's great for the writer, but very poor for the reader. Your code will be read far more times than edited. My motto: "Write code for the reader, not the writer." This means being a little more verbose than you would like.

#4 - Yea, Delphi Prism has all that, and the concurrent programming constructs are already there. C# is behind the times! :) Check it out...
http://prismwiki.codegear.com/en/Futures
http://prismwiki.codegear.com/en/Parallel_Loops

Here is the summary of differences...
http://prismwiki.codegear.com/en/Delphi_Prism_vs._CSharp

Laudate_Dominum
Posted

[quote name='kamiller42' date='07 October 2009 - 10:44 PM' timestamp='1254969850' post='1980563']
#4 - Yea, Delphi Prism has all that, and the concurrent programming constructs are already there. C# is behind the times! :) Check it out...
http://prismwiki.codegear.com/en/Futures
http://prismwiki.codegear.com/en/Parallel_Loops

Here is the summary of differences...
http://prismwiki.codegear.com/en/Delphi_Prism_vs._CSharp
[/quote]
Ya know, I have to admit that I'm being swayed. Delphi Prism looks like great fun!

Laudate_Dominum
Posted

[quote name='Winchester' date='07 October 2009 - 08:44 PM' timestamp='1254962688' post='1980427']
Thank you, Wesley.
[/quote]
For some reason that is the funniest post of the day for me.

Posted

I code pretty Python pretty well, and am passable in C++. I was learning Ruby at one point too. But Python is my favorite language. Here's some sample code I was working on a while ago. Python makes very beautiful code, in my opinion.

[code]
from pyinotify import ThreadedNotifier, WatchManager, EventsCodes, ProcessEvent
import os, sys

class EventProcessor( ProcessEvent):
"""
Processes filesystem events.
"""

def getPathName( self, event):
"""
Return the pathName of a given event.
"""

pathName = event.path + "/" + event.name
return pathName

def checkExclude( self, pathName):
excludesManager = self.manager.master.excludesManager
return excludesManager.checkExclude( pathName)

def process_IN_CREATE( self, event):
"""
File created.
"""
pathName = self.getPathName( event)
doExclude = self.checkExclude( pathName)
if not doExclude:
dbusDaemon = self.manager.master.dbusDaemon
dbusDaemon.fileCreated( pathName)

def process_IN_MODIFY( self, event):
"""
File modified.
"""
pathName = self.getPathName( event)
excluded = self.checkExclude( pathName)
if not excluded:
dbusDaemon = self.manager.master.dbusDaemon
dbusDaemon.fileModified( pathName)

def process_IN_DELETE( self, event):
"""
File deleted.
"""
pathName = self.getPathName( event)
doExclude = self.checkExclude( pathName)
if not doExclude:
dbusDaemon = self.manager.master.dbusDaemon
dbusDaemon.fileDeleted( pathName)

class NotifyManager:
"""
Initializes watch process.
"""

def __init__( self, master):
self.master = master
self.topPath = self.path.expanduser( "~")
self.mask = EventsCodes.IN_MODIFY | EventsCodes.IN_DELETE | EventsCodes.IN_CREATE
self.watchManager = WatchManager()
self.notifier = ThreadedNotifier( watchManager, EventProcessor())

# Find the EventProcessor() object initialized by
# ThreadedNotifier() above.
#
# _default_proc_fun is an attribute of ThreadedNotifier()
# found in the Notifier() class. It contains EventProcessor().
# See pyinotify source.
self.processor = self.notifier._default_proc_fun
# Make this instance of PyNotifyManager an attribute
# of self.processor for communication between objects.
self.processor.manager= self

self.notifier.start()
self.watchManager.add_watch( path=self.topPath, mask=self.mask, rec=True, auto_add=True)

# Walk through directories below self.topPath, calling self.addPath for each one.
#os.path.walk( self.topPath, self.addPath, None)

def addPath( self, arg, dirName, names):
"""
Add the directory dirName to the list of directories
that self.watchManager watches for changes.

This is called by os.path.walk() in self.__init__().
"""
self.watchManager.add_watch( dirName, self.mask)
[/code]

Posted

Wow. The phorums do an excellent job of highlighting python correctly! Even recognizing class names after their definition!

Laudate_Dominum
Posted
:clap:

Very cool! And yeah, I agree about Python making attractive code, I like your style of coding it too. :smokey:
Laudate_Dominum
Posted

[quote name='mommas_boy' date='07 October 2009 - 11:18 PM' timestamp='1254971887' post='1980591']
Wow. The phorums do an excellent job of highlighting python correctly! Even recognizing class names after their definition!
[/quote]
Lol! My thoughts exactly. haha. I've seen some pretty sweet opensource libraries for code highlighting so I wonder which library this board uses? Maybe something proprietary but I doubt it.

Posted

You guys were on the committee that helped compose the 1983 CIC?

Laudate_Dominum
Posted

[quote name='Resurrexi' date='07 October 2009 - 11:28 PM' timestamp='1254972525' post='1980610']
You guys were on the committee that helped compose the 1983 CIC?
[/quote]
:sweat: Good one.

Wouldn't that be a trip? :blink:

Posted

[quote name='mommas_boy' date='07 October 2009 - 11:15 PM' timestamp='1254971715' post='1980589']
I code pretty Python pretty well, and am passable in C++. I was learning Ruby at one point too. But Python is my favorite language. Here's some sample code I was working on a while ago. Python makes very beautiful code, in my opinion.[/quote]
That is nice code. It is neatly formatted. That adheres to my other rule of development: A good cook keeps a clean kitchen. I have seen many "clever coders" who create nice functional software but leave a mess behind in source, inconsistent indention, variable naming, etc. It becomes a nightmare to follow.

And that leads into my third rule of "Between consistency and logic, always choose consistency." It much easier to deal with code that is consistently illogical than code that is logical and inconsistent. I think I have been at this too long. ;-)

Posted

[quote name='kamiller42' date='08 October 2009 - 12:26 AM' timestamp='1254975971' post='1980658']
That is nice code. It is neatly formatted. That adheres to my other rule of development: A good cook keeps a clean kitchen. I have seen many "clever coders" who create nice functional software but leave a mess behind in source, inconsistent indention, variable naming, etc. It becomes a nightmare to follow.

And that leads into my third rule of "Between consistency and logic, always choose consistency." It much easier to deal with code that is consistently illogical than code that is logical and inconsistent. I think I have been at this too long. ;-)
[/quote]

Lol. Probably ;). One of the things that I love about Python is that it forces indentation on you. A lot of coders coming over from C, et al. are a little nervous about this at first. But it really helps to organize and somewhat standardize the code across implementations. Having learned Python first, when I started to learn C++, I started doing it The Python Way (tm).

My one pet peeve: I HATE using underscores. Underscores to me denote internals. I will only use them in my own code to denote an internal function of the Python API (such as the __init__() function of an object that is called when the object is initialized), or to denote a private function (Python doesn't make a distinction between public and private functions like C++ does. All functions are public by default. I create private functions, denoted with a single underscore, just for my own sanity in keeping the code organized). In the above code, the only reason why underscores were present in the variable names was because the library I was using required them. Bugs the heck out of me -- I like having good-looking code.

Posted

[quote name='mommas_boy' date='08 October 2009 - 12:36 AM' timestamp='1254976613' post='1980667']
My one pet peeve: I HATE using underscores. Underscores to me denote internals. I will only use them in my own code to denote an internal function of the Python API (such as the __init__() function of an object that is called when the object is initialized), or to denote a private function (Python doesn't make a distinction between public and private functions like C++ does. All functions are public by default. I create private functions, denoted with a single underscore, just for my own sanity in keeping the code organized). In the above code, the only reason why underscores were present in the variable names was because the library I was using required them. Bugs the heck out of me -- I like having good-looking code.
[/quote]
I am no fan of underscores either. What is worse than using underscores is using them with method names in all caps like HERE_IS_MY_PROCEDURE_NAME. Ugh! CamelCaps for me.

Posted

You guys are still all ubernerds. :mellow:

Posted

[quote name='kamiller42' date='13 October 2009 - 02:59 PM' timestamp='1255467568' post='1984740']
I am no fan of underscores either. What is worse than using underscores is using them with method names in all caps like HERE_IS_MY_PROCEDURE_NAME. Ugh! CamelCaps for me.
[/quote]

I'm kind of back and forth on underscores myself. I think they have their purpose, I just try to limit their use. I agree with your example of method names though, that's just bad.

Posted

[quote name='scardella' date='06 October 2009 - 12:35 PM' timestamp='1254846955' post='1979170']
Well... It's not like I've got a choice on the languages used...
[/quote]

C#, SQL, VB .Net, ASP, Javascript.

Posted

[quote name='kamiller42' date='13 October 2009 - 04:59 PM' timestamp='1255467568' post='1984740']
I am no fan of underscores either. What is worse than using underscores is using them with method names in all caps like HERE_IS_MY_PROCEDURE_NAME. Ugh! CamelCaps for me.
[/quote]

Often, I will define global variables/constants in all-caps and underscores, though. Just another way to help differentiate.

Posted

I use Hungarian notation sometimes to help differentiate globals, but I still haven't found a naming convention that I'm completely happy with.

Posted

I used to use caps and maybe Hungarian notation to denote the scope of a variable. I dropped pretty much all of it because code, if kept tight in scope, should not care where a value is coming from. If code wants a value stored in something called Xyz, the consuming code should not be concerned whether it's from the class or global. These are the remaining cases where I do use some differentiating notation:

1) Local variables, usually prefixed with "l". The reason is because the variable's lifetime is short, and I don't want my procedure to set a value thinking it will live beyond the procedure.

2) Components. I use a basic form of Hungarian here to avoid name conflicts. For instance, drop a label and a text edit to edit a customer name. I can't call them both "Customer." And "CustomerEdit" and "CustomerLabel" is too long. By basic, I mean all my edits for "edt" whether it's a text edit, date edit, etc.

3) Resource strings and string constants. They are just used so much that prefixing with an "s" makes it easy to avoid name conflicts and stand out in the code as something than can be localized to foreign languages if necessary.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...