Hacker News new | past | comments | ask | show | jobs | submit login

> * C++ never requires uglier code.

No... but it sure tends to encourage it.




You've not seen ugly code until you've read 90s-era Win32 UI code written with Hungarian notation everywhere. Ugly code comes from the programmer, not the language.


I blame the early Windows team by mistaking what Simonyi meant with Hungarian notation by misunderstanding what 'type' means. Which is why Office uses his notation in a much cleaner fashion.


Yea it's a shame that Hungarian notation has gotten such a bad rap. Done right i find it occasionally useful. Done the way most windows programmers have been taught is an abomination.


Can you give an example(or a link to an article discussing this)? I've never had the displeasure of working with the Windows API(though I often shook my head when I saw code for it)


Basically he intended 'type' as not 'datatype' as in 'dwSomething' (for double word) but the purpose of the variable. For example, if you're using an integer variable to store the length of some entity, you would name it something like 'lenSomething' as opposed to 'dwSomething'.

Storing the type of the variable makes little sense as in most cases it is only a quick grep away.


In the example you used, "context" seems to be a more appropriate word than "type".



That Wikipedia page does such a better job of describing it than I did.


http://www.joelonsoftware.com/articles/Wrong.html You have to read a bit, hungarian notation doesn't really show up until maybe 4/5 of the way through.


It definitely comes from both. Objective C Block prototypes? C typedefs? blech.


Unless I misunderstand you, block type syntax is almost identical to function pointers. In both cases, you should generally typedef them and then your code is once again free from ugliness.


Having to typedef at all is a sign of deep, unfixable badness.


I am unable to reply to my sibling poster, but I believe what you're saying is that having a hideous and unreadable syntax that forces the use of typedefs just so others can understand what you have written is a sign of deep, unfixable badness. And I agree.


I'm not sure how you arrived at that belief, unless perhaps you think everything should be (visibly to the programmer) type-free? Care to elaborate? I think it would be nice if C and C++ supported more type semantics than `typedef` and `class`, say something as powerful as Haskell's system...


It's the fundamental unfixable crappiness of C declaration syntax that makes 'typedef' necessary.


Example? What language doesn't need typedefs?

Java doesn't have typedefs, and most everyone agrees that's a language bug.


typedef as type aliasing: uncontroversial. typedef to paper over hideous syntax mistakes: disgusting.


Function pointers are also blech looking.


Some say there is no such thing as ugly code, only job security.

Also ugly code is less of an issue of an ugly design as you can look past how the code looks if the design of the program is sound.

But ugly is in the eye of the beholder and in that maybe more people are growing up with C++ and with a later dealing with C as apposed to the other way around. So maybe it is in many ways the mindset of the average age of the programmers around today are more comfortable with C++ as apposed to C and in that could see nicely laid out C code as having ugly bits as its easier for them to do it prettier in C++ and a biased C programmer will see it compeletly from the other perspective.

So its one of those debates were the best move is to get the popcorn as some people see ugly code were others see something nice and some will see C++ as better than they would C and vice versa. Just be glad i'm not involved or I'd be mentioning COBOL as a reality check :).


Why would C++ encourage it? i think its just as easy to make a c of convoluted madness as a c++ one :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: