跨平台编程 linux_如何在Linux平台上开始编程

跨平台编程 linux

Unless you’ve been living in a cave for the last decade, you know that Linux has pretty much taken over the enterprise business world. From web servers, frameworks, clouds, containers, AI, and so much more, Linux powers it all.

除非您在过去十年中一直生活在洞穴中,否则您将知道Linux几乎已经接管了企业业务领域。 从Web服务器,框架,云,容器,人工智能等等,Linux为这一切提供了动力。

Because of this, businesses need programmers who can develop both for and on the Linux platform. If you’re not already savvy enough to transition back and forth between macOS or Windows to Linux, it’s time you learned.

因此,企业需要可以在Linux平台上和在Linux平台上进行开发的程序员。 如果您还不够聪明,无法在macOS或Windows到Linux之间来回转换,那么您就该学习了。

But where do you start? How do you begin programming on Linux platform? If you’re already comfortable with one or more programming languages, you already have the hard part taken care of. In fact, programming on Linux isn’t really all that much of a challenge, compared to working with other platforms. Why? The available tools.

但你从哪儿开始呢? 您如何开始在Linux平台上编程? 如果您已经熟悉一种或多种编程语言,那么您已经很辛苦了。 实际上,与使用其他平台相比,在Linux上进行编程并不是真正的挑战。 为什么? 可用工具。

With Linux, you have a lot of tools you can work with. And although some of those tools might be command line only, you’re a programmer, so the command line is second nature.

使用Linux,您可以使用许多工具。 尽管其中一些工具可能仅是命令行,但您是程序员,所以命令行是第二性。

But how do you take this necessary plunge? Let’s dive in and find out.

但是,您如何采取这种必要的尝试呢? 让我们深入了解。

How to Begin Programming on Linux Platform

第一件事第一 (First Things First)

Before you write, debug, or compile that first program on Linux, you should first read Richard Esplin’s “Advanced Linux Programming”. What this book will do is help you to quickly understand the following concepts:

在Linux上编写,调试或编译该第一个程序之前,应首先阅读Richard Esplin的“ 高级Linux编程 ”。 本书将帮助您快速理解以下概念:

  • Develop GNU/Linux software that works as expected.

    开发可以按预期运行的GNU / Linux软件。
  • Writing more sophisticated programs that take advantage of Linux multiprocessing, multi-threading, interprocess communication, and hardware interaction.

    编写更复杂的程序,以利用Linux多处理,多线程,进程间通信和硬件交互。
  • Create programs that run faster, more reliably, and more securely.

    创建运行速度更快,更可靠,更安全的程序。
  • The unique peculiarities of a GNU/Linux system (such as specific limitations, special capabilities, and standard UNIX conventions).

    GNU / Linux系统的独特功能(例如特定的限制,特殊的功能和标准的UNIX约定)。

Some of the chapters of what should be considered the Linux programming bible include:

Linux编程圣经的某些章节包括:

  • Editing with Emacs

    用Emacs编辑
  • Compiling with GCC

    用GCC编译
  • Automating with GNU Make

    使用GNU Make自动化
  • Using the GNU Debugger

    使用GNU调试器
  • Interacting with the executing environment

    与执行环境互动
  • Writing and using libraries

    编写和使用库
  • Looking at and creating processes

    查看和创建流程
  • Signals

    讯号
  • Process termination

    流程终止

Because there are fundamental differences between the Windows and Linux environments, you should consider this book a must-read, if only to gain a better understanding of how Linux works.

由于Windows和Linux环境之间存在根本差异,因此,即使只是为了更好地了解Linux的工作原理,也应该将本书视为必读书籍。

Bash脚本 (Bash Scripts)

Bash scripts are easy-to-write scripts that run from within the Linux shell. These scripts can be written to do just about anything and should be considered one of the first stepping stones for learning to program in Linux.

Bash脚本是易于编写的脚本,可在Linux Shell中运行。 这些脚本几乎可以做任何事情,应该被视为学习Linux编程的第一步。

By creating simple bash scripts, you’ll learn things like:

通过创建简单的bash脚本,您将学到以下内容:

  • Execution privileges

    执行特权
  • The Linux $PATH

    Linux $ PATH
  • How to use variables in Linux

    如何在Linux中使用变量
  • Permissions

    权限
  • Shell scripting “dialects”

    Shell脚本“方言”
  • File manipulation

    文件操作

Because bash scripts don’t need to be compiled, they are a great place to begin your journey. This is also a good way to start understanding how to problem-solve without having to employ QA services. Because bash scripts aren’t compiled, they are very easy to troubleshoot.

因为bash脚本不需要编译,所以它们是开始您的旅程的好地方。 这也是开始了解如何解决问题而无需采用QA服务的好方法。 由于bash脚本未编译,因此很容易进行故障排除。

安装工具 (Installing the Tools)

Every tool you’ll need is either already installed or can be quickly installed. A good example is a build-essential package, which can be installed on Ubuntu-based Linux distributions. By installing this one package, you’ll wind up with tools like:

您所需的每个工具都已经安装或可以快速安装。 一个很好的例子是构建必需的软件包,可以将其安装在基于Ubuntu的Linux发行版上。 通过安装此软件包,您将获得以下工具:

  • dpkg-dev – Debian package development tools

    dpkg-dev – Debian软件包开发工具
  • g++ – GNU C++ compiler

    g ++ – GNU C ++编译器
  • gcc – GNU C compiler

    gcc – GNU C编译器
  • libc6-dev – GNU C Library

    libc6-dev – GNU C库
  • make – Utility for direction program compilation

    make –定向程序编译实用程序

These are, as the name implies, essential tools for building applications on Linux. To install this software on a Ubuntu-based Linux distribution, you only need to issue the command:

顾名思义,这些是在Linux上构建应用程序的基本工具。 要将软件安装在基于Ubuntu的Linux发行版上,只需发出以下命令:

sudo apt-get install build-essential -y

须藤apt-get install build-essential -y

学习编辑 (Learn an Editor)

Although you will find plenty of graphical tools available for developing with Linux, you should consider it a must-do to learn the ins and outs of one of the available editors. Although you could do well with the simplicity of nano, you will probably find a tool like vim or emacs to be better suited to the task of programming on Linux.

尽管您会发现许多可用于Linux开发的图形工具,但您仍应认为这是学习其中一种可用编辑器来龙去脉的必经之路。 尽管可以用nano的简单性做得很好,但是您可能会发现像vim或emacs这样的工具更适合Linux上的编程任务。

And although you might think using a text editor is a simple affair, you would be wrong. In order to get the most out of the vim text editor, you really need to take the time to understand how the tool is used. For example, the simple act of saving a file requires you to hit Escape and then type :wq. That’s right, vim isn’t like Notepad.

而且,尽管您可能认为使用文本编辑器是一件简单的事情,但这是错误的。 为了充分利用vim文本编辑器,您确实需要花一些时间来了解如何使用该工具。 例如,保存文件的简单操作要求您单击Escape,然后键入:wq。 是的,vim不像记事本。

In fact, vim is incredibly powerful. The vim editor includes features like:

实际上,vim非常强大。 vim编辑器包含以下功能:

  • Perform complex tasks with a few quick commands

    通过一些快速命令执行复杂的任务
  • Highly configurable

    高度可配置
  • Powerful plugin system, to expand the feature set

    强大的插件系统,扩展功能集
  • Multi-window/buffer support

    多窗口/缓冲区支持
  • Tab support

    标签支持
  • Macro support

    宏支持
  • Syntax highlighting

    语法高亮
  • Auto indent

    自动缩进

There is no way around learning a solid editor. No matter if you’re programming heavy duty, enterprise-grade software or if you’re working with a software QA outsourcing, you’ll need to know the ins and outs of this tool.

没有办法学习可靠的编辑器。 无论您是在编写重型企业级软件,还是正在使用软件质量检查外包,您都需要了解此工具的来龙去脉。

了解小部件工具包 (Learn a Widget Toolkit)

If you plan on creating GUI applications, you’ll need to learn one (or more) of the Widget toolkits. You’ll be surprised at how many toolkits there are. For example:

如果计划创建GUI应用程序,则需要学习一个(或多个)Widget工具箱。 您会对其中有多少个工具包感到惊讶。 例如:

  • GTK – used for the GNOME desktop

    GTK –用于GNOME桌面

  • Qt – used by the KDE desktop

    Qt –由KDE桌面使用

  • Tcl – used for web and desktop programming

    Tcl –用于Web和桌面编程

  • SWT – used with the Java platform.

    SWT –与Java平台一起使用。

  • FLTK – cross-platform C++ GUI toolkit.

    FLTK –跨平台的C ++ GUI工具箱。

You will not be creating any graphical applications on Linux without knowing one of the toolkits. Make sure to go through the official documentation for whichever toolkit you decide to work with.

在不知道其中一个工具箱的情况下,您将不会在Linux上创建任何图形应用程序。 确保您决定使用的任何工具包都经过正式文档处理。

结论 (Conclusion)

This short list of tips will get you started on your Linux programming journey. Of course, no matter how well of a start you get, you’re going to have to have a solid grasp on the fundamentals of programming first. So before you dive into coding for the open-source community, make sure you know how to write those first lines of code.

这些简短提示将使您开始进行Linux编程之旅。 当然,无论您的起步有多好,都必须首先牢牢掌握编程的基础知识。 因此,在深入研究开源社区的编码之前,请确保您知道如何编写这些第一行代码。

翻译自: https://www.thecrazyprogrammer.com/2020/02/programming-on-linux.html

跨平台编程 linux

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值