flat assembler
Message board for the users of flat assembler.

Index > Heap > Programming as a hobby vs. programming for work - Opinions?

Author
Thread Post new topic Reply to topic
axlucas



Joined: 02 May 2014
Posts: 66
Location: Argentina
axlucas
Hi, guys!
I've been concerned many times about how things change in the programming world, but well, that's why I'm a hobby programmer: because that way I can do it the way I like it. Now I'm curious about how other programmers see some of these things. Namely....
While there are always people programming in assembly or middle-to-low level languages, trying to optimise their code to be faster and more efficient, this seems to be typical of hobbyists only now. That is, I don't see how I could ever get a job as a low level programmer.
OOP is so popular now that if you talk to an employer about any programming that is not OOP, they won't know what you're talking about. Personally, I don't like OOP. I think that adding more and more abstraction layers makes everything less efficient and bloats resource use. Maybe I'm exaggerating. I have never done much OOP, so maybe I'm very wrong about that. I'd like to read other people's opinions.

So what about you guys? Besides assembly, do you regularly use some other language a lot? Any OOP? Do you actually work at programming or are you all hobbyists like I am? Do you think I have nothing to "fear"? Just curious about your opinions. Thank you all! Smile
Post 02 May 2014, 22:51
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 706
Location: Belarus
DimonSoft
IMHO, just like any other tool, OOP is great for certain tasks. And it's also a great way of structuring your code, dividing it into units, etc. But like any other idea it becomes a terrible piece of shit whenever anyone uses it without understanding the idea, just because he/she is taught to. OOP patterns just for the purpose of patterns themselves, for example — what can be worse?

Assembly as hobby, for fun and teaching, PHP and JS at work, old versions of Delphi for making cool things really fast.
Post 02 May 2014, 23:32
View user's profile Send private message Visit poster's website Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
Specialised areas still use a lot of assembly and C. I work for a company that designs embedded processors so have had to learn 2/3 ISAs and write the C wrappers for drivers/testing. (There are other people who have to write the real drivers, compiler support and OS integration stuff as well.) On top of this, I'm normally writing C/C++ models that simulate the hardware.

EDIT: Something to be aware of is that programming for work might have an effect on your motivation for programming as a hobby. I personally, have had less focus/energy for it since moving from student to work life.

If you approach OOP from the standpoint that an object is just a structure and methods have a hidden first parameter called "this" that points to our structure then hopefully its more familiar to your normal asm/C programming. One nice thing about C++ is you can just write C and you can link to asm code and enjoy the benefits of a HLL for the top level view and the power of asm under-the-hood; this is something I do regularly to prototype/analyse my hobby code.

I'd say if you get some experience with, for example, asm and C or C++ and Java or Python and bash you should have good coverage (a) for knowing these four rough groups (b) for being able to apply/transfer between other languages (c) for being able to mix these in the correct quantities and for knowing where and how to apply them.
Post 03 May 2014, 10:20
View user's profile Send private message Reply with quote
nyrtzi



Joined: 08 Jul 2006
Posts: 192
Location: Off the scale in the third direction
nyrtzi
@axlucas

I find myself being a bit skeptical about many employers even understanding what OOP actually is considering that even most programmers have a somewhat limited understanding of it. But how much do the non-techie bosses even need to understand?

Then again many software houses want people who know how to write Java/C++/C# for the simple reason that everyone else is using Java too which means that "it can't be a bad choice" or so they think.

You don't like OOP? Which flavour of OOP? Mainstream class-based OOP which is often thought to be the same as OOP itself in its entirety?

But yes I can understand that view. Class-based OOP has its limitations. Then again prototype-based OOP also has its own. Most choices are tradeoffs.

I don't like the "traditional" mainstream single-dispatch class-based programming model.
I prefer multimethods and interface-orientedness when I get to pick.

I mostly have to work with languages other than assembly. At work I mainly use mainstream languages but on my own time I usually pick C or Python. I used to use Common Lisp a lot but I got bored of it. But once I get my own language done I'll be using that.
Post 03 May 2014, 13:53
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1409
Location: Toronto, Canada
AsmGuru62
I enjoy immensely my job as a coder.
Also, OOP looks like being hated by ASM coders.
Looks wrong. You can code in assembler and still follow OOP principles.
Post 03 May 2014, 14:23
View user's profile Send private message Send e-mail Reply with quote
nyrtzi



Joined: 08 Jul 2006
Posts: 192
Location: Off the scale in the third direction
nyrtzi
AsmGuru62 wrote:
Also, OOP looks like being hated by ASM coders.
Looks wrong. You can code in assembler and still follow OOP principles.


Yes, it is kind of illogical. After all OOP is just a bunch of techniques, etc. Why not simply pick the parts of OOP that are useful for doing what you do and use those? Why hate something simply because it's a part of some set of ideas called OOP?

I'm assuming that most people automatically think of dynamic dispatch and inheritance when OOP is mentioned. Dynamic dispatch is nice although it has performance consequences. James Gosling once said in an interview that if he could redesign Java one of the features he might leave out would be inheritance. Inheritance gives code reuse but it also creates dependencies which can become a mess and reduce modularity.

If I remember correctly I think the earliest mention I've seen in professional literature of OOP techniques being used would place them in the 1960s (might even have been the 1950s) in assembly code. So using an OOP-like approach in low level code is hardly a new thing. It's more like an old tradition.
Post 03 May 2014, 15:40
View user's profile Send private message Reply with quote
axlucas



Joined: 02 May 2014
Posts: 66
Location: Argentina
axlucas
You know, I think that if you can code low level, you can still do OOP, but you will see it in a different way, because you will understand what's really happening behind and you will give it a good use. By your answers, I see you all know very well what this is all about, but that's not what usually happens to me when I talk to a random programmer today. I think I'm concerned with how much most programmers can't see because of having been taught only OOP.
Having some OOP features in a language is OK to me. I agree C++ is great because you decide when you want to use OOP and you never lose contact with assembly, if you don't want to. When I write C++, I actually write C, with a few more little things. I tend not to use OOP. My worst OOP experience has been Java. That language is made in a way that you have no escape, no way to avoid classes and objects. Even Java bytecode is object oriented!
I don't really know the internals, but I guess that, when you create an object, lots of memory are reserved unnecessarily and not only the one you would use for a struct'd variable. I also feel there's code running that I can't see and that makes me doubt on how I should write what I can. In short, I feel lack of control. I'm sure there's a good use for OOP, though, like for most things.

Uhm, I've already thought of the fact that working at programming would reduce my interest in it as a hobby. I would like that not to happen, but I'm feeling like I'm going to get old and not be specialised if I don't start working as a programmer. In Argentina, so far, I've seen abundant jobs for Java programmers (but I'm not good at that right now) and very, very little for C/C++. Needless to say, people look at me with weird faces when I mention Assembly Razz
Post 03 May 2014, 20:11
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1409
Location: Toronto, Canada
AsmGuru62
I would argue that there is very little performance penalty in OOP - when calling virtual function.
It is just a call like that one:
Code:
call dword ptr [ebx + 24h]    

instead of a call to some static address:
Code:
call 00402180h    

You have to put that call in a loop of billions to get any noticeable performance hit.
The real optimization is in proper design and using efficient algorithms.
Post 03 May 2014, 21:33
View user's profile Send private message Send e-mail Reply with quote
axlucas



Joined: 02 May 2014
Posts: 66
Location: Argentina
axlucas
I see that. Sometimes that is an important difference; sometimes it isn't. But that's about clocks. How about memory usage? Don't classes and objects bloat it?
Post 04 May 2014, 03:57
View user's profile Send private message Reply with quote
nyrtzi



Joined: 08 Jul 2006
Posts: 192
Location: Off the scale in the third direction
nyrtzi
axlucas wrote:
You know, I think that if you can code low level, you can still do OOP, but you will see it in a different way, because you will understand what's really happening behind and you will give it a good use. By your answers, I see you all know very well what this is all about, but that's not what usually happens to me when I talk to a random programmer today. I think I'm concerned with how much most programmers can't see because of having been taught only OOP.


Being taught how to write OOP code still doesn't mean that they understand how it really works under the hood. Then again many people aren't even interested in such a thing.
Post 04 May 2014, 06:54
View user's profile Send private message Reply with quote
sid123



Joined: 30 Jul 2013
Posts: 340
Location: Asia, Singapore
sid123
At OSDev IRC wrote:

<username> OOP is a state of mind

Razz
Post 04 May 2014, 07:47
View user's profile Send private message Reply with quote
nyrtzi



Joined: 08 Jul 2006
Posts: 192
Location: Off the scale in the third direction
nyrtzi
AsmGuru62 wrote:
I would argue that there is very little performance penalty in OOP - when calling virtual function.
It is just a call like that one:
Code:
call dword ptr [ebx + 24h]    

instead of a call to some static address:
Code:
call 00402180h    

You have to put that call in a loop of billions to get any noticeable performance hit.


You picked a rather simple case as your example.
You won't get more than single dispatch without overloading with that code.
Then again if that is all you need.

The more complex alternatives which require computing the correct jump address at runtime based on type information don't perform that well.
I'm not sure how many widely used OOP languages use something as simple as your example.
Post 04 May 2014, 07:50
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1409
Location: Toronto, Canada
AsmGuru62
C++ code does it with any type of overloading or RTTI.
Java, on the other hand may dispatch differently, because it is interpreted language.
I think, Java is bloated way more than C++.
Post 04 May 2014, 12:44
View user's profile Send private message Send e-mail Reply with quote
nyrtzi



Joined: 08 Jul 2006
Posts: 192
Location: Off the scale in the third direction
nyrtzi
AsmGuru62 wrote:
C++ code does it with any type of overloading or RTTI.


I should check how they do they implement that. I'm having trouble deciding how I should implement multimethods in my own toy language.

AsmGuru62 wrote:
Java, on the other hand may dispatch differently, because it is interpreted language.


Yes, the virtual machine interprets the compiled bytecode at runtime but don't they use a JIT compiler or something to compile performance critical sections of the bytecode into native code for better speed?

AsmGuru62 wrote:
I think, Java is bloated way more than C++.


I'm feeling a bit iffy about that. They say that the C++ spec is 800 pages long but then again I'm wondering if it's the same thing with it as it's with Common Lisp which has a big spec because the standard library is also included in it. The specs of Scheme are said to be only 24 pages but then again that probably only includes the core language and not the libraries. I'd need to check. I have no clue how long the Java spec is but the standard library for Java is probably bigger while the core language should be smaller and simpler than C++. C++ having a lot more features, etc compared to many other languages.

In practise the main bloat problem I have with C++ is that of the normal libraries being so big that they slow down the compile times to a crawl. I'm not sure about this and I haven't checked but I saw someone write that including the Boost headers adds multiple hundred thousand of lines of stuff to compiled. Then again Java seems to have a problem because it lacks a module system which would allow one to cut down on the amount of libraries that get pulled into programs because of all sorts of dependencies.

So I decided to do a little test. I wrote a program which does nothing more than reads a line of input from standard input and then writes it back to standard output. I wrote that in C, C++, Python and Java and then compared what the pmap tools says about how much memory the programs used while they were waiting for that input. So basically we're talking about programs on the same complexity level as a Hello world! program. And the results made me laugh.

C 1704kB

C++ 2924kB

Python 7624kB

Java 382056kB

So as far as slurping up memory because of dependencies of the standard libraries go Java is hogging close to 373 megs. I knew I heard from somewhere that even small Java programs are big as far as memory use is concerned. Then again much of that comes from the fact that it borrows internationalization libraries and so on from the system which should already be loaded in memory by other programs anyway. Either way the figure is just ludicrous. In that sense I can fully agree that Java is bloated. Perhaps that is why some people in the Java community are worried about the startup times of Java programs.
Post 05 May 2014, 05:46
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1409
Location: Toronto, Canada
AsmGuru62
Good test!
But it is obvious that in C/C++ you did not use any options to remove the bloat.
For console I/O instead of printf() it is better to use Win32 Console API and exclude the RT Lib from EXE.
Then you'll get an EXE about 2K or so.
Post 05 May 2014, 14:58
View user's profile Send private message Send e-mail Reply with quote
axlucas



Joined: 02 May 2014
Posts: 66
Location: Argentina
axlucas
Geesh! I knew Java was all bloat, but even disliking it, like I do, I didn't expect such an extreme!
I remember when, in the 90s, I used to make very simple programs in QuickBASIC and it was horrific to DIR and find out the EXEs took up some 70K for just a few lines of code. Ha, ha. Good old times.

I believe it's OK if users are not interested in knowing how applications work in their computers, and maybe even some programmers might not need to know the internals of the high level compilers they use, but when you come to figures like this, I believe it's a programmer's responsibility to make their code efficient. The fact that hard drives are huge today and memory is abundant should be no excuse. My younger brother thinks it's reasonable that a game takes up 4GB of disk space, even when it plays no video. Very Happy
Post 05 May 2014, 17:22
View user's profile Send private message Reply with quote
nyrtzi



Joined: 08 Jul 2006
Posts: 192
Location: Off the scale in the third direction
nyrtzi
AsmGuru62 wrote:

But it is obvious that in C/C++ you did not use any options to remove the bloat.
For console I/O instead of printf() it is better to use Win32 Console API and exclude the RT Lib from EXE.
Then you'll get an EXE about 2K or so.


Is that something people do normally when writing console apps on Windows?
I wouldn't know as I usually just write backend code on Linux.

But yes, I didn't have any of the optimization flags enabled while compiling C and C++. Turning them on probably would have mattered in a bigger program but in this scenario they didn't seem to have much of an effect on memory use when I tried them afterwards.
Post 05 May 2014, 19:45
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1409
Location: Toronto, Canada
AsmGuru62
Well, if you do Hello program with Run-Time attached - you get about 80Kb EXE in release build, so it is not horribly bad.
You get over 1Mb probably because that was a debug build done by default, so you got the debug info attached for the whole Run-Time.

P.S. Yes, normally you do not exclude the Run-Time, but you CAN do it.
I wrote a few routine (read: simple) utilities for some clients and I always include RT,
but if I code for myself - I usually exclude it, since I have my own RT, which I am not willing to share, because client requires code I have written - he owns the code once he pays me.
Post 05 May 2014, 19:52
View user's profile Send private message Send e-mail Reply with quote
nyrtzi



Joined: 08 Jul 2006
Posts: 192
Location: Off the scale in the third direction
nyrtzi
axlucas wrote:
Geesh! I knew Java was all bloat, but even disliking it, like I do, I didn't expect such an extreme!


I'm still thinking that there should be some kind of a reasonable explanation for that absurdly large result. Perhaps I should simply ask some Java expert what it's all about.

axlucas wrote:

but when you come to figures like this, I believe it's a programmer's responsibility to make their code efficient. The fact that hard drives are huge today and memory is abundant should be no excuse.


Yep, but then again is this guy taking it a bit too far?

http://www.muppetlabs.com/~breadbox/software/tiny/teensy.html

axlucas wrote:

My younger brother thinks it's reasonable that a game takes up 4GB of disk space, even when it plays no video. Very Happy


Are kids, nerds, programmers, etc nowadays spoiled rotten by modern hardware? I still remember working with a Commodore 64 with a tape drive back when I was a kid.
Post 05 May 2014, 19:55
View user's profile Send private message Reply with quote
axlucas



Joined: 02 May 2014
Posts: 66
Location: Argentina
axlucas
I still have a Commodore 64 somewhere here Smile

Quote:
Yep, but then again is this guy taking it a bit too far?

http://www.muppetlabs.com/~breadbox/software/tiny/teensy.html


Wow! What this guy is doing is really playing with the file structure! What he's doing is really a great show, even when that overlapping is doomed to fail with the slightest change from a computer to another or from an OS version to the next. But yeah... it's amazing!

Yeah, when I say "efficient", I don't mean that much, of course Razz
Post 06 May 2014, 04:57
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.