Live data from Hacker News

Being confidently programming language agnostic

blog.bradfieldcs.com

51–60 of 131 posts

Re: Being confidently programming language agnostic

#51
post #43

Earlier quoted context omitted.

I just wish those universities actually produced programmers who understand the low level mechanics of how computers work. I.e. Why your program runs 100x slower if you're not careful about cache misses, pretty basic stuff like that. Moore's law is over, it's time to start caring about performance again.

What makes you think universities produce people who don't care about performance and aren't educated about low level mechanics? That's an honest question, I'm not challenging your experience. I don't know what your experience is, of course. In my experience, people with CS degrees do understand the low level mechanics statistically more often, on average, than people who don't have a formal education, or people who…

> What makes you think

Personal experience. I've been trying to hire moderately competent, junior software engineers would be able to write and optimize C++ without much supervision. They're now more rare than the Sasquatch. Today, "caring about performance" means picking a language that's only 5x slower than C, rather than 100x slower. Hardly anyone even knows why alignment might be desirable, or how long it takes to fetch memory after a cache miss, or how concurrency primitives actually work. For my generation, "caring about performance" means that C compiler generates suboptimal assembly, and you handcode it because you know better and need that extra oomph.

> It depends on what you're doing

It sure does. You don't have to worry about the lower level stuff every day. We deal with extremely high performance code, and even _we_ don't think about it every day. But it definitely pays to know what's going on. Otherwise it's not software engineering, it's cargo cult science and rain dancing, prone to fall apart at the first sign of difficulty. It's like having a certified car mechanic who doesn't know how to open the hood. You can have a few of those to change tires and broken tail lights on the cheap, but you also need the dudes/dudettes who know what to do when "check engine" light comes on.

Re: Being confidently programming language agnostic

#52

Earlier quoted context omitted.

I think the top-10 universities do it right and the rest don't. (This is a bit of an exaggeration but you most likely know what I mean). Most of my classmates don't usually "learn" a language. They do an assignment by copying, hammering at the computer, or just asking for help. The basis of how university is set up is antithetical to the learning and exploration of new programming languages. This is based on one simp…

There are three problems with "Don't mandate a programming language" -- I'm a lecturer and I've done it for advanced practicals in later years. * Students expect to be able to get help when they have problems. There is a good chance no member of staff knows Julia / Moonscript / ... * Some languages make tasks trivial -- while this is nice when you are in the real world, if I want to test student's ability to create s…

> Students expect to be able to get help when they have problems. There is a good chance no member of staff knows Julia / Moonscript / ...

For this I have two answers. Past the first year people shouldn't be getting help with "my code won't compile". They should be able to develop the skills needed to search that on google and find SOF links.

The second answer is a question: Why don't members of staff know "Julia / Moonscript / ..." and if they don't why can't they logically reason about what's going on in the language without having used it? I don't know Go but when people have asked me to look at some Go code to see there is a bug I can still reason about what's happening. Isn't that what this article is about? All languages are just mix-matches of common idioms with new ways of expressing them. If the best of the best, those who are teaching the future generations of computer scientists, can't do this it would seems strange to me.

> Some languages make tasks trivial -- while this is nice when you are in the real world, if I want to test student's ability to create something I don't want some students missing most of the work. How do I then mark it?

If the student understands how to use the abstraction then they have likely learned something far more valuable. If you're assigning labs that consist of basic idioms that can be whisked away by common library functions then you might consider changing your curriculum to focus more on solving problems rather then codifying solutions.

> Similarly, if the question was "implement a malloc-like memory manager", well you really have to do that in C,C++,Objective-C, maybe Rust, but it makes less sense in python.

I see no reason why you'd have to write that in C/C++/Objective-C/Rust. If you're going after the idea of writing a working memory manager, and not write me a kernel that has a memory manager, then Python would work great for it. Here is an example:

   class Allocation: 
           def __init__(self, start, size):
                   self.start = start 
                   self.size = size
   
           @property
           def end():
                   return self.start + self.size + 1

   class FirstFit:
           def __init__(self, total_memory):
                   self.allocations = []
                   self.total_memory = total_memory
   
           def alloc(self, size):
                   if not self.allocations:
                           allocation = Allocation(0, size)
                   else:
                           allocation = None 
                           for i in range(len(self.allocations)):
                                   current = self.allocations[i]  
   
                                   if i + 1 = size:
                                                   continue
                                   else:
                                           # Check to see if we can fit inbetween this end allocation and the end of memory
                                           if not self.total_memory - current.end >= size:
                                                   continue 

                                   # We can so allocate
                                   allocation = Allocation(current.end, size)

                           if not allocation: # We can't so return NULL
                                   return None

                   self.allocations.push(allocation) # Store this allocation in our memory allocation table 
                   return allocation[0]
           def free(self, start): 
                   for i in self.allocations:
                           if self.allocations[i].start == start: # Find out pointer
                                   self.allocations = self.allocations[:i] + self.allocations[i + 1:] # Slice it out
                                   return True # We made it!
                   return False # We couldn't find this! PANIC!


This is crappy code but it can be done very eligently and I think this gets across the theory better then doing this in C. In this you can also experiment is far more complex datastructures easily. (What if I think of memroy as a Tree and divide the value of my node by 2 every time it's size is too big?)

> Also, getting a "quick tour" of (say) C++ isn't really useful, students who try to pick it up by just googling are likely to write terrible code. Learning a language properly takes work.

I'd say that's just because of the poor design of modern C++. You can do a quick tour of python and easily get basics, of C and easily get the basiscs, of Java and get the basics, of Common Lisp and get the basics. You don't need to master a language to see where it is applicable.

Re: Being confidently programming language agnostic

#53

I've been programming for 20+ years, and recently moved over to Python. Sure, I could code on day one and figure out how to get programs working pretty easily. But the nuances with it are still things I need to work on a lot. I still don't program Pythonicly, I program like a C programmer writing Python. In fact, I probably program in all languages like I would a C programmer, and that's not good enough, in my opinio…

As a Python programmer of 10+ years, here's the most Pythonic tip you can get:

Don't try to be clever, do the simplest (and most readable) thing that will work.

Try "import this" in an interpreter to read a bit more on the above.

Re: Being confidently programming language agnostic

#54
post #7

I think nowadays people spend too much time learning new tools and too less time doing something really valuable using that tools. I wish I had only one language, so I can concentrate on more interesting things rather than learning yet another random set of operators and library function's names.

While using fewer, better languages for more is fantastic, I doubt you really want a single language. Try replacing shell, Structured Query Language, and C with the same language. I won't say that it can't be done, but I think you'll lose a lot if you succeed.

I'd hope that with embedded DSLs we can get closer. People are already doing lots of it in Haskell, including domains you listed. Of course there is always the risk that one invents an "inner language" with poorer semantics and tools.

Re: Being confidently programming language agnostic

#55

I've been programming for 20+ years, and recently moved over to Python. Sure, I could code on day one and figure out how to get programs working pretty easily. But the nuances with it are still things I need to work on a lot. I still don't program Pythonicly, I program like a C programmer writing Python. In fact, I probably program in all languages like I would a C programmer, and that's not good enough, in my opinio…

As a Python programmer of 10+ years, here's the most Pythonic tip you can get: Don't try to be clever, do the simplest (and most readable) thing that will work. Try "import this" in an interpreter to read a bit more on the above.

... Except generators and comprehensions are often faster than for loops in your hot path.

Apart from that... What's readable tends to be the best option.

Re: Being confidently programming language agnostic

#56
post #40

Earlier quoted context omitted.

I still find the "frameworks and libraries" argument to be false, but enough people say it that I believe it must be at least partially true. I'll settle for a belief that the argument is overstated. IMO the largest issue is the breadth of one's experience, or lack thereof. And by that I don't mean simply the number of languages but how well versed one is in different languages and their surrounding ecosystems. For i…

I think it's about how much newness you have to handle at the same time. I can happily take a project using a framework or two I've never touched before. Or something in a new language but similar domain. But when you have the perfect storm of new language, tools and framework (and maybe OS) that's when it hurts. I'm not saying I totally couldn't switch, but it made me change me attitude a bit from '2 weeks and I'll…

This is also true, I would say it's a combo of the two. The more new things at once the more likely it is that you'll be working with something without a good correlation to something in your previous experience. But at the same time having a broader and richer base of experience will make it more likely that you'll have an easier go of it for any of those individual things.

Re: Being confidently programming language agnostic

#57
post #43

Earlier quoted context omitted.

What makes you think universities produce people who don't care about performance and aren't educated about low level mechanics? That's an honest question, I'm not challenging your experience. I don't know what your experience is, of course. In my experience, people with CS degrees do understand the low level mechanics statistically more often, on average, than people who don't have a formal education, or people who…

> What makes you think Personal experience. I've been trying to hire moderately competent, junior software engineers would be able to write and optimize C++ without much supervision. They're now more rare than the Sasquatch. Today, "caring about performance" means picking a language that's only 5x slower than C, rather than 100x slower. Hardly anyone even knows why alignment might be desirable, or how long it takes t…

Optimizing C++ code is enough of a niche requirement nowadays that it is totally reasonable for you have to train junior devs in this area rather than hiring them ready to go.

If you don't want to train them, pay the price for an experienced C++ developer instead.

Re: Being confidently programming language agnostic

#58
post #43

Earlier quoted context omitted.

What makes you think universities produce people who don't care about performance and aren't educated about low level mechanics? That's an honest question, I'm not challenging your experience. I don't know what your experience is, of course. In my experience, people with CS degrees do understand the low level mechanics statistically more often, on average, than people who don't have a formal education, or people who…

> What makes you think Personal experience. I've been trying to hire moderately competent, junior software engineers would be able to write and optimize C++ without much supervision. They're now more rare than the Sasquatch. Today, "caring about performance" means picking a language that's only 5x slower than C, rather than 100x slower. Hardly anyone even knows why alignment might be desirable, or how long it takes t…

> junior software engineers would be able to write and optimize C++ without much supervision

"Junior" and "optimize c++" just do not typically go together. Even more so if you're talking about deep optimizations like cache hit misses, and not just algorithm decisions or breaking down problems properly.

Re: Being confidently programming language agnostic

#59

I've been programming for 20+ years, and recently moved over to Python. Sure, I could code on day one and figure out how to get programs working pretty easily. But the nuances with it are still things I need to work on a lot. I still don't program Pythonicly, I program like a C programmer writing Python. In fact, I probably program in all languages like I would a C programmer, and that's not good enough, in my opinio…

> I probably program in all languages like a C programmer As the old "Real Programmers Don't Use PASCAL" article says, > The determined Real Programmer can write FORTRAN programs in any language.

Real Programmer can write FORTRAN programs in any language.

That's why Haskell exists. It's the computer scientists' best attempt so far to create a language in which it's impossible to write FORTRAN programs.

Re: Being confidently programming language agnostic

#60
post #42

Earlier quoted context omitted.

> Those shortened links take you to amazon Just FYI: Hacker News already shortens links, no need to pass them through a 3rd party service. I personally prefer seeing a readable domain name before clicking (as I'm sure many others do as well).

Had no idea. I do appreciate this. I must of missed the 'splainer. I'll remember that for next time.

Just FYI, you can remove all the parameters from Amazon URLs and they still work. EG: https://www.amazon.com/Fluent-Python-Concise-Effective-Progr...

You can also emit the title: https://www.amazon.com/dp/1491946008/ works fine.

Post reply on HN